Repository navigation
Description
Affected layers
- Frontend (
src/): affected.ConfigurationTabinsrc/components/settings/ConfigurationTab.tsxloads the configuration once, when the tab mounts, and refreshes it only after its own saves.saveEditcopies that snapshot, overwrites the edited field and sends the whole object toPOST /api/setup, which replaces the saved configuration.useControlApialready exposesupdateConfig, aPUT /api/configcarrying a partial update, but nothing calls it. - Backend (
server/): not affected as the cause.PUT /api/configmerges a partial update into the saved configuration per top-level key, so a nested section such astranslatororjdcis still replaced whole, and no precondition rejects a write based on a stale read. A fix may need either. shared/: not affected. It holds theSetupDatatype and no merge logic.
Problem
Two browser tabs, or two operators, hold the settings page. One changes a security-relevant value, such as the primary pool, a payout identity or coinbase verification, and saves. The other, still holding the earlier snapshot, edits an unrelated field such as the telemetry subnet or the minimum hashrate and saves. The second save sends the complete earlier configuration, so every change the first save made is reverted, while the page reports that only the unrelated field was saved.
Impact
Someone who temporarily set an attacker-controlled payout or pool value can undo the operator's remediation through a session that is still open, or by waiting for the operator's own other tab to save anything, and redirect later rewards or disable payout verification. The operator sees a successful save of an unrelated field and nothing that points at the reverted values. The attacker needs a session or an open tab that loaded the page before the remediation. Without an attacker, two tabs are enough to lose a change.
Expected outcome
- Saving one field from the settings page changes only that field in the saved configuration; every other value stays as the backend held it at the moment of the save, not as the page held it when it loaded.
- A page that loaded before another save cannot revert that save by editing something else: either its edit applies on top of the current configuration, or it is refused and the operator is told to reload.
- After a save, the page shows the configuration the backend holds.
Possible approach (non-binding)
Send only the edited field through the existing updateConfig, and for a nested section either re-read the configuration right before building the update or make the backend merge within sections, since the shallow merge in PUT /api/config would otherwise still restore a stale verify_payout from a hashrate edit. A revision or ETag returned by GET /api/config and checked by PUT /api/config turns a stale save into a refusal. A handler test can save a configuration, send a partial update that carries stale nested values and assert that the saved file keeps the newer ones; server/src/auth-recovery.test.ts shows how the server is started against a fresh config directory.
Loupe findings
- project-loupe/audit-sv2-ui#31: inline settings edits submit the page's load-time snapshot through the setup endpoint, reverting concurrent changes (reported as setup: an inline settings edit changes only the field being edited #348)
Related issues and PRs
- auth: changing the password ends every other session #319 covers administrator sessions that stay valid after a password change, which is what keeps a stale tab usable by someone who no longer knows the password.
- Tracker: [Tracker] Setup and settings flows #374.
Loupe export for #348 (finding #31)
Finding
- repo:
stratum-mining/sv2-ui(https://github.com/stratum-mining/sv2-ui.git) - reviewed revision:
ba9d73547e751247c4aa79257b54d3d706f42620 - title: Merge inline edits against current configuration
- severity:
medium - location:
src/components/settings/ConfigurationTab.tsx:227-269 - cwe: CWE-362
- scanner:
llm-code-review - fingerprint:
63dfa5376fa780aefb60bc0c6a8d3d8a45c2af16fb7edd8d1aaacff1ac10dbf1
Description
ConfigurationTab builds every inline edit by shallow-copying the configuration snapshot fetched when the page loaded (const updated = { ...config }) and then sends that entire stale object through the setup endpoint. The repository already exposes a partial updateConfig API whose server handler merges updates into the current saved state, but this component does not use it. Consequently, two tabs or clients can race: client A changes a security-critical field such as a solo-mining payout identity, upstream pool identity, or translator.verify_payout; client B, which loaded the previous value, edits an unrelated field such as telemetry or hashrate and then calls setup(updated). B's request silently restores every stale security-critical value from its snapshot while appearing to save only the unrelated field. An adversary who temporarily set an attacker-controlled payout/pool value can exploit an already-open stale session, or induce a concurrent settings save, to undo the operator's remediation and redirect subsequent mining rewards or disable payout verification. Fix by sending only the field being edited through updateConfig, optionally with a revision/ETag precondition for conflict detection. Prior-finding searches for ConfigurationTab stale config lost update payout setup updated and lost update stale configuration race payout returned no matches.
Proof of Concept
diff --git a/src/components/settings/ConfigurationTab.security.test.ts b/src/components/settings/ConfigurationTab.security.test.ts
new file mode 100644
index 0000000..c584d15
--- /dev/null
+++ b/src/components/settings/ConfigurationTab.security.test.ts
@@ -0,0 +1,20 @@
+import assert from 'node:assert/strict';
+import { readFileSync } from 'node:fs';
+import test from 'node:test';
+
+const source = readFileSync(
+ new URL('./ConfigurationTab.tsx', import.meta.url),
+ 'utf8',
+);
+
+test('inline edits do not overwrite concurrent security-critical configuration changes', () => {
+ assert.match(
+ source,
+ /\bupdateConfig\s*\(/,
+ 'inline settings must use the partial-update API, which merges against current server state',
+ );
+ assert.doesNotMatch(
+ source,
+ /\bsetup\s*\(\s*updated\b/,
+ 'submitting the stale configuration snapshot can restore an old pool or payout identity',
+ );
+});
This finding was discovered by Project Loupe.
Activity
[-]Merge inline edits against current configuration[/-][+]setup: an inline settings edit changes only the field being edited[/+]