8000 logs: a pool stays reported active only while its log evidence is recent · Issue #331 · stratum-mining/sv2-ui · GitHub
[go: up one dir, main page]

Skip to content

logs: a pool stays reported active only while its log evidence is recent #331

Open

Description

@lucasbalieiro

Affected layers

  • Backend (server/): affected. When a log read fails, ActivePoolTracker in server/src/active-pool.ts returns the pool from its previous state, with no limit on how long ago that state was last confirmed. GET /api/status reports it as the active pool with its name, address and authority key, and in JD mode the translator recovery uses the same read to decide whether JDC has an upstream.
  • Frontend (src/): not affected. It shows the pool the status response names and has no detection of its own.
  • shared/: not affected. It holds no pool detection code.
  • The evidence comes from JDC and translator log lines shipped by sv2-apps. The defect is in how long sv2-ui keeps trusting it, not in the lines.

Problem

After one successful handshake has been observed, every later poll whose log read fails keeps reporting that pool as connected. A read fails when Docker is unreachable, when the container is restarting, or when the inspect or logs call does not return within the 10 second Docker call timeout. The fallback exists so that one transient error does not blank the dashboard, and a test keeps it that way. Nothing bounds it: an hour or a day of failed reads still reports the pool observed before the outage.

Impact

While reads keep failing, the upstream can disconnect, fail over to another pool or fail validation, and the dashboard keeps naming the old pool, its address and its authority key as current. In JD mode the translator recovery also treats JDC as connected, so translator downtime during the outage counts as failing and restarts are scheduled on stale evidence. An attacker who can make the mining container log enough to push every log read past the timeout can hide a connection change behind the stale answer; whether the shipped images can be driven to that volume is an assumption the finding states explicitly. Ordinary Docker or host degradation has the same effect without an attacker. Low per Loupe.

Expected outcome

  • A short run of failed log reads keeps reporting the last observed pool, as today.
  • Once log reads have failed for longer than a bounded interval, status reports no active pool until a read succeeds again, and the JD-mode translator recovery sees the same answer.
  • A successful read that returns no new lines counts as fresh evidence: it confirms the container is reachable and the state unchanged, without inventing a handshake.

Possible approach (non-binding)

Record the time of the last successful read in the tracker state and compare it on the failure path, with the bound as a named constant worth a few polling intervals. A test can follow tracker retains the connected fallback across incremental polls and log failures in server/src/active-pool.test.ts, with the clock stubbed or injected so the second failing poll happens a day later, as the proof of concept does.

Loupe findings

Related issues and PRs

Loupe export for #331 (finding #65)

Finding

  • repo: stratum-mining/sv2-ui (https://github.com/stratum-mining/sv2-ui.git)
  • reviewed revision: 1451e3b6e9364b5eb043b479fe5dabed74f1739c
  • title: Expire active-pool evidence during prolonged log outages
  • severity: low
  • location: server/src/active-pool.ts:173-181
  • cwe: CWE-345
  • scanner: llm-code-review
  • fingerprint: 3400add47c2d4beb5c0014cf130bc84e7a1480d1bc0952898b0f5c56606e24a3

Description

The catch path returns previous.activeIndex without any freshness limit. After one successful SetupConnection, an hour, day, or indefinite sequence of failed Docker log reads still makes /api/status say the old pool name/address/authority key is actively connected. During that blind period the upstream can disconnect, fail Noise validation, or fail over, so this turns last-known state into a continuing authentication claim. An adversarial upstream or downstream that can make the mining container produce enough log activity to keep the Docker log request timing out can use the stale result to conceal a connection change; the exact ability to induce that volume depends on the out-of-tree translator/JDC image logging behavior and is therefore an explicit assumption. Independent Docker/API degradation has the same integrity consequence. Preserve the existing tolerance for a brief transient error, but track the last successful observation/read and return unknown after a bounded log-blind interval (successful empty incremental reads can refresh reachability without inventing a new handshake). Prior #13065 was reviewed but concerns an in-flight read resurrecting state after an explicit reset. #8050 concerns concurrent full-history reads and resource exhaustion. Neither limits stale evidence in this catch path.

Proof of Concept

diff --git a/server/src/active-pool.test.ts b/server/src/active-pool.test.ts
--- a/server/src/active-pool.test.ts
+++ b/server/src/active-pool.test.ts
@@ -211,3 +211,40 @@ test('invalidates the active pool when the authority key rotates without a new h
   // Then the authority key rotates (same endpoint) without a new handshake.
   assert.equal(await tracker.getActivePool('translator', poolsWithKey('rotated-key')), null);
 });
+
+test('does not report an arbitrarily stale pool through a prolonged log outage', async () => {
+  let failReads = false;
+  const tracker = new ActivePoolTracker(async () => {
+    if (failReads) {
+      throw new Error('Docker log endpoint unavailable');
+    }
+    return [
+      log('Trying upstream 2 of 2: fallback.example.com:4444'),
+      log('Connected to upstream at 192.0.2.42:4444'),
+      log('Received: SetupConnectionSuccess(used_version: 2, flags: 0x00000000)'),
+    ];
+  });
+
+  const originalNow = Date.now;
+  let now = Date.parse('2026-07-17T10:00:00.000Z');
+  Date.now = () => now;
+
+  try {
+    assert.deepEqual(
+      await tracker.getActivePool('translator', POOLS),
+      {
+        name: 'Fallback',
+        index: 1,
+      }
+    );
+
+    failReads = true;
+    now += 24 * 60 * 60 * 1000;
+    assert.equal(
+      await tracker.getActivePool('translator', POOLS),
+      null
+    );
+  } finally {
+    Date.now = originalNow;
+  }
+});

This finding was discovered by Project Loupe.

Activity

  1. added
    area:logs
    and removed on Oct 14, 2026
  2. changed the title [-]Expire active-pool evidence during prolonged log outages[/-] [+]logs: a pool stays reported active only while its log evidence is recent[/+] on Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:logs

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0