Skip to content

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

Open
bobdivx wants to merge 1 commit into
devfrom
sentinel/fix-docker-logs-injection-10186215259954644985
Open

🛡️ Sentinel: [CRITICAL] Fix command injection in docker logs API#29
bobdivx wants to merge 1 commit into
devfrom
sentinel/fix-docker-logs-injection-10186215259954644985

Conversation

@bobdivx
Copy link
Copy Markdown
Owner

@bobdivx bobdivx commented May 12, 2026

🚨 Severity: CRITICAL
💡 Vulnerability: Command injection where unsanitized user query parameters (id and tail) were directly concatenated into a shell command (docker logs --tail ${tail} ${containerId}) and executed using execSync.
🎯 Impact: Attackers could inject arbitrary bash commands using &, ;, or | operators to execute malicious code on the host machine.
🔧 Fix: Used execFile wrapped with util.promisify to execute docker directly, avoiding the bash shell, passing arguments as an array. Added flag injection checks and error sanitization.
✅ Verification: Ensure tests pass and the logs endpoint correctly fetches standard docker logs while discarding injected commands.


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

- Replaced vulnerable `execSync` with `execFile` from `child_process`
- Passed parameters `tail` and `containerId` via arguments array to prevent shell injection
- Validated inputs to ensure `containerId` doesn't start with a hyphen (flag injection)
- Parsed and sanitized `tail` to ensure it is a positive integer or fallback to '100'
- Sanitized error message returned to the client to avoid leaking sensitive internal stack trace info
- Documented findings in `.jules/sentinel.md`
- Tests and checks pass

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

vercel Bot commented May 12, 2026

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

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

@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.

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 by replacing execSync with execFile and using argument arrays. It also introduces validation for the containerId to prevent flag injection and sanitizes error messages to avoid leaking system details. Feedback was provided to cap the tail parameter to a maximum value to prevent potential resource exhaustion or buffer overflows.

Comment on lines +28 to +29
const tailParsed = parseInt(tailRaw, 10);
const tailStr = isNaN(tailParsed) || tailParsed < 0 ? '100' : tailParsed.toString();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The tail parameter is parsed but not capped. An excessively large value could lead to high memory usage or cause the execFile buffer to overflow (the default limit is 1MB). Enforcing a maximum limit improves API stability and prevents potential resource exhaustion.

Suggested change
const tailParsed = parseInt(tailRaw, 10);
const tailStr = isNaN(tailParsed) || tailParsed < 0 ? '100' : tailParsed.toString();
const tailParsed = parseInt(tailRaw, 10);
const tailStr = isNaN(tailParsed) || tailParsed < 0 ? '100' : Math.min(tailParsed, 1000).toString();

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