🛡️ Sentinel: [CRITICAL] Fix command injection in logs endpoint#101
🛡️ Sentinel: [CRITICAL] Fix command injection in logs endpoint#101bobdivx wants to merge 1 commit into
Conversation
🚨 Severity: CRITICAL 💡 Vulnerability: Command Injection vulnerability via dynamically constructed shell strings in `src/pages/api/forge-logs.ts`. 🎯 Impact: Attackers could inject arbitrary shell commands by manipulating input query parameters, leading to Remote Code Execution (RCE). 🔧 Fix: Replaced synchronous `execSync` with asynchronous, shell-less `execFileAsync` utilizing argument arrays. ✅ Verification: Tested locally via vitest and manually audited code. Co-authored-by: bobdivx <6737167+bobdivx@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Code Review
This pull request refactors the forge-logs API endpoint to use execFile asynchronously instead of execSync, effectively mitigating a command injection vulnerability. It also adds a sentinel file documenting this security improvement. The review feedback correctly identifies a potential issue where invalid or extremely large values for the lines parameter could cause process failures or memory exhaustion, and suggests validating and constraining this input.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| export const GET: APIRoute = async ({ url }) => { | ||
| try { | ||
| const type = url.searchParams.get('type') || 'watchdog'; | ||
| const lines = parseInt(url.searchParams.get('lines') || '50', 10); |
There was a problem hiding this comment.
If the lines query parameter is not a valid number (e.g., ?lines=abc), parseInt will return NaN. Passing "NaN" to the tail command will cause the child process to fail and throw an error. Additionally, extremely large values for lines could lead to high memory consumption or Denial of Service (DoS) by reading too many lines into memory.\n\nWe should validate that lines is a safe positive integer and limit it to a reasonable maximum (e.g., 500 lines).
| const lines = parseInt(url.searchParams.get('lines') || '50', 10); | |
| const lines = Math.min(Math.max(parseInt(url.searchParams.get('lines') || '50', 10) || 50, 1), 500); |
🚨 Severity: CRITICAL
💡 Vulnerability: Command Injection vulnerability via dynamically constructed shell strings in
src/pages/api/forge-logs.ts.🎯 Impact: Attackers could inject arbitrary shell commands by manipulating input query parameters, leading to Remote Code Execution (RCE).
🔧 Fix: Replaced synchronous
execSyncwith asynchronous, shell-lessexecFileAsyncutilizing argument arrays.✅ Verification: Tested locally via vitest and manually audited code.
PR created automatically by Jules for task 1612945354801737101 started by @bobdivx