Repository navigation
Description
tracking https://github.com/project-loupe/audit-sv2-ui/issues/14
Finding
- repo:
stratum-mining/sv2-ui(https://github.com/stratum-mining/sv2-ui.git) - reviewed revision:
1c81ce5d2e9b6df4c81c1478af9350de9c5e6efc - title: Unbounded raw-log request can exhaust server memory
- severity:
medium - location:
server/src/index.ts:409-426 - cwe: CWE-400
- scanner:
llm-code-review - fingerprint:
438e85c316952dc2ea60a478b25c571959487a55ea1d6429d6be94d0a57dcd8e
Description
GET /api/logs/raw accepts tail=all and deliberately calls readContainerLogs(container) without a tail limit. The reachable helper asks Dockerode for the full log history as one Buffer, converts each chunk to strings, splits all lines into arrays, collates the containers, sorts the complete result, and then Express serializes it again as JSON. Thus memory use scales with the entire lifetime logs rather than a bounded response size and is amplified by several in-memory copies. The two-second Docker request timeout limits elapsed time, not response bytes; a local Docker daemon can return a very large existing log quickly.
The route has no authentication, so any network client able to reach the documented Docker-published service can repeatedly request /api/logs/raw?tail=all. On a long-running or noisy mining stack, one or a few requests can exhaust the Node process heap and terminate or stall the management service, disrupting monitoring and stack control. Remove the all option, enforce a finite maximum tail for every request, or implement byte-bounded streaming/pagination.
Prior searches for “logs raw tail all”, “unbounded container logs memory”, “container logs denial service”, and “readCollatedLogLines memory” found no matching report. Finding #892 was reviewed but concerns wildcard CORS/data access, not this independent unbounded-memory path.
Proof of Concept
diff --git a/server/src/index-security.test.ts b/server/src/index-security.test.ts
new file mode 100644
--- /dev/null
+++ b/server/src/index-security.test.ts
@@ -0,0 +1,18 @@
+import assert from 'node:assert/strict';
+import { readFileSync } from 'node:fs';
+import { test } from 'node:test';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const TEST_DIR = path.dirname(fileURLToPath(import.meta.url));
+const INDEX_SOURCE = path.join(TEST_DIR, 'index.ts');
+
+test('raw log requests always impose a finite Docker log tail', () => {
+ const source = readFileSync(INDEX_SOURCE, 'utf8');
+
+ assert.doesNotMatch(
+ source,
+ /readContainerLogs\(container\)/,
+ 'the HTTP API must not load complete container log history into memory',
+ );
+});
This finding was discovered by Project Loupe.
Activity