8000 Keep downloaded container logs within a bounded tail · Issue #290 · stratum-mining/sv2-ui · GitHub
[go: up one dir, main page]

Skip to content

Keep downloaded container logs within a bounded tail #290

Closed

Description

@lucasbalieiro

tracking https://github.com/project-loupe/audit-sv2-ui/issues/27


Finding

  • repo: stratum-mining/sv2-ui (https://github.com/stratum-mining/sv2-ui.git)
  • reviewed revision: ba9d73547e751247c4aa79257b54d3d706f42620
  • title: Keep downloaded container logs within a bounded tail
  • severity: medium
  • location: src/components/data/ContainerLogsPanel.tsx:56-64
  • cwe: CWE-400
  • scanner: llm-code-review
  • fingerprint: 8aa11d037bcd05366c3cd2f6475eced7f84726cbe3d4f923f74839819f2f6f5c

Description

handleDownload requests /api/logs/raw?tail=all, expl B973 icitly bypassing the normal 500-line cap, and then materializes the entire response several times: response.json() creates the line/object graph, buildDownloadContent() creates an additional array plus a joined string, and Blob creates the downloadable payload. The in-tree server implementation confirms that tail=all omits Docker's tail option and reads full container history before JSON serialization. An adversary who can cause the network-facing mining services to emit sustained or oversized log messages can grow that history without a corresponding bound; when an operator uses the download control during diagnosis, the server and browser process attacker-influenced history in one request, allowing memory/CPU exhaustion and loss of availability. The ten-second client abort does not bound bytes already accumulated and does not prevent the server from allocating the full log buffer before responding. Keep downloads capped (for example tail=500) or implement a genuinely streamed, size-limited export. Prior-finding searches for ContainerLogsPanel tail all unbounded logs download denial service and logs raw tail all resource exhaustion returned no matches.

Proof of Concept

diff --git a/src/components/ContainerLogsPanel.test.ts b/src/components/ContainerLogsPanel.test.ts
new file mode 100644
index 0000000..2b528f4
--- /dev/null
+++ b/src/components/ContainerLogsPanel.test.ts
@@ -0,0 +1,15 @@
+import assert from 'node:assert/strict';
+import { readFile } from 'node:fs/promises';
+import test from 'node:test';
+
+test('log downloads retain the server-side line limit', async () => {
+  const source = await readFile(
+    new URL('./data/ContainerLogsPanel.tsx', import.meta.url),
+    'utf8'
+  );
+
+  assert.doesNotMatch(
+    source,
+    /\/api\/logs\/raw\?tail=all/,
+    'the download must not request unbounded container history'
+  );
+});

Suggested Fix

diff --git a/src/components/data/ContainerLogsPanel.tsx b/src/components/data/ContainerLogsPanel.tsx
index 84fcded..4a4cab4 100644
--- a/src/components/data/ContainerLogsPanel.tsx
+++ b/src/components/data/ContainerLogsPanel.tsx
@@ -55,7 +55,7 @@ export function ContainerLogsPanel({ lines, isLoading, isJdMode }: ContainerLogs
 
   const handleDownload = useCallback(async () => {
     try {
-      const response = await fetch('/api/logs/raw?tail=all', {
+      const response = await fetch('/api/logs/raw?tail=500', {
         signal: AbortSignal.timeout(10000),
       });
       if (!response.ok) return;

This finding was discovered by Project Loupe.

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