Repository navigation
Description
Affected layers
- Frontend (
src/): affected.handleStartinsrc/components/setup/steps/ReviewStart.tsxposts the wizard data toPOST /api/setupwith a 300 s timeout. On a timeout, a network error or any error whose message mentions fetch, it callsconfirmStackStarted, which takesconfigured: trueandrunning: truefromGET /api/statusas proof that the submission succeeded, shows the success screen and redirects to the dashboard. - Backend (
server/): not affected.GET /api/statusreports whether a stack is configured and running and nothing that ties it to a submission, andGET /api/configreturns the saved setup, which a fix can compare against. A fix may still choose to add a configuration identifier to the status response. shared/: not affected. The setup and status types carry no identifier, by design so far.
Problem
The check was added for sv2-ui running in Docker, where joining the stack's network can drop the response of a setup the backend did complete. But the same branch runs when the request never reached the backend, and when the backend rejected it before touching the stack and that answer was lost. The backend validates the data, prepares the config and probes Docker and the Bitcoin socket before it stops the old stack, so each of those rejections leaves the previous stack running. If a stack was running with an older configuration, for example because the operator came back to the wizard from the settings page to reconfigure, the status check describes that old stack and the wizard declares the new setup started.
Impact
An operator recovering from a compromised or attacker-controlled pool configuration believes hashpower was redirected while it keeps mining to the old pool and identity. An attacker on the network path who can drop or delay the setup request gets exactly that outcome. Without an attacker, a submission the backend rejected, whose answer was lost, ends in a success screen and a dashboard showing the old pool, and the rejection is never seen.
Expected outcome
- After a setup request ends without a readable response, the wizard shows the success screen only when the backend's saved configuration is the one just submitted and the stack is running.
- When the saved configuration differs from the submission or cannot be read, the wizard stays on the failure, says the stack may still be starting, and does not redirect to the dashboard.
- A setup whose response was dropped after the backend completed it still ends in the success screen, which is the case the check exists for.
Possible approach (non-binding)
Compare GET /api/config with the submitted data on the fields that identify a setup, such as pools, identities, mode and mining mode, since the backend saves a normalized copy; or have POST /api/setup and GET /api/status carry a configuration fingerprint or a submission id the client can match. When no match is possible, keep the ambiguous failure. A test can stub globalThis.fetch to fail the setup call and answer the status and config calls with an older configuration, then assert that no success is shown; src/hooks/useUiConfig.test.ts shows how a global is swapped and restored in these tests.
Loupe findings
- project-loupe/audit-sv2-ui#32: after a dropped or timed-out setup request, a running stack with an older configuration is taken as proof the submission succeeded (reported as setup: the wizard reports success only when the configuration it submitted is the one running #347)
Related issues and PRs
- Commit d1bfaa5 added the status check so a response dropped by the Docker network attach does not hide a completed setup; that case must keep working.
- Tracker: [Tracker] Setup and settings flows #374.
Loupe export for #347 (finding #32)
Finding
- repo:
stratum-mining/sv2-ui(https://github.com/stratum-mining/sv2-ui.git) - reviewed revision:
ba9d73547e751247c4aa79257b54d3d706f42620 - title: Verify the submitted configuration after ambiguous setup failures
- severity:
medium - location:
src/components/setup/steps/ReviewStart.tsx:18-27 - scanner:
llm-code-review - fingerprint:
a407c0a5e405a5beb6e1c115ecf7b397d0148af5a62f9ff5966c6c3e2a05b61a
Description
confirmStackStarted treats any configured: true, running: true status as proof that the just-submitted setup succeeded. handleStart invokes this check after an aborted or network-failed POST /api/setup and then shows success and redirects to the dashboard. The status response does not identify the configuration or setup operation. Consequently, if a stack was already running with an older pool configuration and the new POST is dropped before reaching the server (or its response is selectively interrupted), the subsequent GET can describe the old stack and the UI falsely confirms the new setup. This is security-relevant during recovery from a compromised or attacker-controlled pool: the operator can believe hashpower was redirected while it continues to mine to the prior identity/payout destination. The recovery path should compare /api/config (after normalization) with the submitted data, or use an operation/configuration fingerprint returned by setup and status, before setting started. If exact confirmation is unavailable, it must retain the ambiguous-failure state rather than claim success. A prior-finding search for ReviewStart confirmStackStarted stale running configuration setup timeout pool returned no matches.
Proof of Concept
diff --git a/src/components/setup/steps/ReviewStart.test.ts b/src/components/setup/steps/ReviewStart.test.ts
new file mode 100644
index 0000000..6ed21ec
--- /dev/null
+++ b/src/components/setup/steps/ReviewStart.test.ts
@@ -0,0 +1,24 @@
+import assert from 'node:assert/strict';
+import { readFileSync } from 'node:fs';
+import test from 'node:test';
+
+const source = readFileSync(new URL('./ReviewStart.tsx', import.meta.url), 'utf8');
+
+test('network-error recovery verifies the submitted setup before reporting success', () => {
+ assert.match(
+ source,
+ /confirmStackStarted\(data\)/,
+ 'the recovery check must receive the setup that the user submitted',
+ );
+
+ const helperStart = source.indexOf('async function confirmStackStarted');
+ const componentStart = source.indexOf('export function ReviewStart');
+ assert.notEqual(helperStart, -1);
+ assert.notEqual(componentStart, -1);
+
+ const helperSource = source.slice(helperStart, componentStart);
+ assert.match(
+ helperSource,
+ /fetch\(["']\/api\/config["']/,
+ 'a previously running stack is not proof that the submitted configuration was applied',
+ );
+});
Suggested Fix
diff --git a/src/components/setup/steps/ReviewStart.tsx b/src/components/setup/steps/ReviewStart.tsx
--- a/src/components/setup/steps/ReviewStart.tsx
+++ b/src/components/setup/steps/ReviewStart.tsx
@@ -15,23 +15,6 @@
onGoToStep: (step: SetupStep) => void;
}
-async function confirmStackStarted(): Promise<boolean> {
- const controller = new AbortController();
- const timeoutId = setTimeout(() => controller.abort(), 5_000);
-
- try {
- const response = await fetch("/api/status", { signal: controller.signal });
- if (!response.ok) return false;
-
- const status = await response.json();
- return status.configured === true && status.running === true;
- } catch {
- return false;
- } finally {
- clearTimeout(timeoutId);
- }
-}
-
export function ReviewStart({ data, onComplete, onGoToStep }: ReviewStartProps) {
const queryClient = useQueryClient();
const [isStarting, setIsStarting] = useState(false);
@@ -90,18 +73,6 @@
} catch (err) {
let message = "Failed to start services";
if (err instanceof Error) {
- const mayHaveStarted =
- err.name === "AbortError" ||
- err.message.includes("fetch") ||
- err.message.includes("Network");
-
- if (mayHaveStarted && await confirmStackStarted()) {
- await queryClient.invalidateQueries({ queryKey: ["setup-status"] });
- setStarted(true);
- setIsStarting(false);
- return;
- }
-
if (err.name === "AbortError") {
message =
"Request timed out. The containers may still be starting — check the terminal.";
This finding was discovered by Project Loupe.
Activity
[-]Verify the submitted configuration after ambiguous setup failures[/-][+]setup: the wizard reports success only when the configuration it submitted is the one running[/+]