Skip to content

🛡️ Sentinel: [CRITICAL] Fix command injection in docker logs#78

Open
bobdivx wants to merge 1 commit into
devfrom
jules-fix-docker-logs-injection-7391640736258588607
Open

🛡️ Sentinel: [CRITICAL] Fix command injection in docker logs#78
bobdivx wants to merge 1 commit into
devfrom
jules-fix-docker-logs-injection-7391640736258588607

Conversation

@bobdivx
Copy link
Copy Markdown
Owner

@bobdivx bobdivx commented May 30, 2026

🚨 Severity: CRITICAL
💡 Vulnerability: Command injection vulnerability in src/pages/api/docker-logs.ts where unvalidated id and tail query parameters were directly interpolated into an execSync shell command.
🎯 Impact: An attacker could execute arbitrary shell commands on the server running the API by providing crafted id or tail values.
🔧 Fix: Refactored the endpoint to use execFileSync with an array of arguments, entirely bypassing shell execution. Added strict input validation to ensure parameters only contain alphanumeric characters, hyphens, or underscores, and do not start with a hyphen to prevent flag injection.
✅ Verification: Ran pnpm run check and pnpm test to ensure no regressions.


PR created automatically by Jules for task 7391640736258588607 started by @bobdivx

Co-authored-by: bobdivx <6737167+bobdivx@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
forge Ready Ready Preview, Comment May 30, 2026 5:47pm

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses a critical command injection vulnerability in the Docker logs API route by replacing execSync with execFileSync and adding strict input validation for the containerId and tail parameters. It also documents this vulnerability in a new sentinel markdown file. The review feedback recommends refactoring the synchronous process execution (execFileSync) to an asynchronous approach (execFile wrapped in promisify) to prevent blocking the Node.js event loop and degrading API performance under concurrent load.

import type { APIRoute } from 'astro';
import { execSync } from 'child_process';
import type { APIRoute } from "astro";
import { execFileSync } from "child_process";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using synchronous process execution (execFileSync) blocks the single-threaded Node.js event loop. This can severely degrade the performance and responsiveness of the API under concurrent requests. It is highly recommended to use asynchronous execution instead.

import { execFile } from "child_process";
import { promisify } from "util";

const execFileAsync = promisify(execFile);

Comment on lines +49 to +54
const output = execFileSync(
"docker",
["logs", "--tail", tail, containerId],
{ stdio: ["pipe", "pipe", "pipe"] },
).toString();
logs = output.trim().split("\n");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Refactor the synchronous execution to use the asynchronous execFileAsync to prevent blocking the event loop.

Suggested change
const output = execFileSync(
"docker",
["logs", "--tail", tail, containerId],
{ stdio: ["pipe", "pipe", "pipe"] },
).toString();
logs = output.trim().split("\n");
const { stdout } = await execFileAsync(
"docker",
["logs", "--tail", tail, containerId]
);
logs = stdout.trim().split("\n");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant