Repository navigation
Description
Affected layers
- Frontend (
src/): affected.FallbackIdentitySectioninsrc/components/pools/FallbackIdentitySection.tsxkeys each fallback row by its array index. ItsPoolIdentityFieldschild is stateful for SRI pools:SriPoolIdentityFieldskeeps the last payout address and worker name in component state, and keeps the address while a 100% donation identity carries none. The section is rendered by the setup wizard and by the settings page, and in both thePoolPriorityEditorabove it moves and removes rows. - Backend (
server/): not affected. It receives the final pool list and cannot tell which address the operator meant for which pool. shared/: not affected. It holds no form state.
Problem
When a fallback is moved or removed, React keeps the component instance at each index and hands it the pool that now sits there. If the pool arriving in the slot is also an SRI pool, the instance keeps the previous pool's saved payout address; a different pool type would remount the fields. A full-donation identity shows no address field, so the stale address is invisible. Lowering that pool's donation builds the new identity from the stale address, and the row now shows a valid partial-donation identity paying out to the other pool's address. Since the two SRI presets share one endpoint and cannot both be listed, the second SRI entry is a custom pool entered with the SRI authority key.
Impact
The configuration validates and, once saved, the non-donated part of that pool's reward goes to the address of the pool that used to sit in the slot. It takes a fallback entry holding the attacker's address, for example one added by following pasted instructions, a move or removal that puts a full-donation SRI entry in its slot, and a later donation edit, which is why the export calls medium conservative. Without an attacker the same mechanism moves the operator's own addresses between pools, so a fallback can pay out to an address the operator set for another pool.
Expected outcome
- The identity fields of a fallback pool show and use only values that belong to that pool, before and after any move or removal in the list.
- Lowering the donation of a full-donation SRI fallback never produces an identity with an address the operator did not enter for that pool.
- The setup wizard and the settings page both hold these guarantees.
Possible approach (non-binding)
Key fallback rows by a stable per-row id rather than by index. PoolPriorityEditor already keeps a rowIds list for this reason and moves it with the pools; lifting those ids to the parent lets FallbackIdentitySection reuse them. Keying by address, port and key, as the Loupe suggestion does, remounts the fields while an address is being typed and collides when two rows share an endpoint, so a stable id is safer. Alternatively SriPoolIdentityFields can drop its saved address whenever the pool it renders changes endpoint. A test needs a render that can change props between updates; src/components/layout/Shell.test.tsx shows the static react-dom/server harness, and this case needs a small DOM-level one, as #312 notes for its dismiss case.
Loupe findings
- project-loupe/audit-sv2-ui#46: fallback identity rows are keyed by index, so a moved or removed row hands its saved payout address to another pool (reported as setup: a fallback pool's identity fields never carry another pool's payout address #343)
Related issues and PRs
PoolPriorityEditorkeys its own rows by a stable id so per-row state follows the pool across moves and removals; the identity section below it does not share those ids.- Tracker: [Tracker] Setup and settings flows #374.
Loupe export for #343 (finding #46)
Finding
- repo:
stratum-mining/sv2-ui(https://github.com/stratum-mining/sv2-ui.git) - reviewed revision:
b610455ac2d1e017c1df5db8787c0b2e505eabdc - title: Key fallback identity state by pool, not array index
- severity:
medium - location:
src/components/pools/FallbackIdentitySection.tsx:98 - cwe: CWE-664
- scanner:
llm-code-review - fingerprint:
7d7cd343bc4c0503a03fe4610c1707989ff9ce382d81f086c399833a1430e9a7
Description
Each fallback row is keyed as ${idPrefix}-${index}, although its PoolIdentityFields descendant is stateful. In SRI solo mode, SriPoolIdentityFields retains savedPayoutAddress specifically while a 100%-donation identity has no address. Reordering or removing fallback pools keeps the React instance at an index and substitutes a different pool prop, so that hidden address remains associated with the slot rather than the pool. If two SRI-style entries have different payout state, place an attacker-supplied entry containing the attacker address in a slot, reorder a full-donation entry into that slot, then lower its donation percentage. The slider handler builds the new identity from the stale savedPayoutAddress, writing the attacker's address into the other pool's valid configuration. Saving can consequently redirect that pool's non-donated reward. The trigger requires a reorder/removal plus a later donation edit, so medium severity is conservative. Use a stable connection identity (or an explicit persistent pool ID) as the React key, or explicitly reset all child state when the pool identity changes. Prior finding #4649 concerns cross-operator username inheritance and #8068 concerns trusted branding; neither covers React state reuse across reordered pools.
Proof of Concept
diff --git a/src/components/pools/FallbackIdentitySection.test.ts b/src/components/pools/FallbackIdentitySection.test.ts
new file mode 100644
--- /dev/null
+++ b/src/components/pools/FallbackIdentitySection.test.ts
@@ -0,0 +1,25 @@
+import assert from 'node:assert/strict';
+import { readFileSync } from 'node:fs';
+import test from 'node:test';
+
+test('keys fallback identity state by pool rather than mutable array position', () => {
+ const source = readFileSync(
+ new URL('./FallbackIdentitySection.tsx', import.meta.url),
+ 'utf8',
+ );
+ const fallbackRow = source
+ .split('\n')
+ .find((line) => line.includes('<div key='));
+
+ assert.ok(fallbackRow, 'the fallback row must have an explicit React key');
+ assert.doesNotMatch(
+ fallbackRow,
+ /\bindex\b/,
+ 'an index key reuses PoolIdentityFields state for a different pool after reordering',
+ );
+ assert.match(
+ fallbackRow,
+ /\bpool\./,
+ 'the key must follow the pool connection identity across reordering',
+ );
+});
Suggested Fix
diff --git a/src/components/pools/FallbackIdentitySection.tsx b/src/components/pools/FallbackIdentitySection.tsx
--- a/src/components/pools/FallbackIdentitySection.tsx
+++ b/src/components/pools/FallbackIdentitySection.tsx
@@ -95,7 +95,7 @@ export function FallbackIdentitySection({
const displayName = selectedPreset?.name ?? pool.name ?? `Fallback ${index + 1}`;
return (
- <div key={`${idPrefix}-${index}`} className="rounded-lg border border-border bg-card p-4">
+ <div key={`${idPrefix}-${pool.address}:${pool.port}:${pool.authority_public_key}`} className="rounded-lg border border-border bg-card p-4">
<div className="mb-3 flex min-w-0 items-center gap-3">
<PoolIcon
logoUrl={selectedPreset?.logoUrl}
This finding was discovered by Project Loupe.
Activity
[-]Key fallback identity state by pool, not array index[/-][+]setup: a fallback pool's identity fields never carry another pool's payout address[/+]