Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 2024-10-26 - Command Injection via `execSync` Path Formatting
**Vulnerability:** Command injection vulnerability identified in `packages/core/src/reconcile.ts` where a shell string was constructed using `execSync(\`node --check "\${tempFile}"\`, { stdio: "pipe" });`. Since `tempFile` derives from `options.workspace`, any shell metacharacters (e.g. `"; <cmd> ;"`) within the path could lead to arbitrary command execution by the Node.js shell.
**Learning:** `execSync` passes the entire command string to the system shell. When constructing commands that include dynamic or file paths, passing it as a string allows shell injection if the dynamic parts contain unescaped shell operators.
**Prevention:** Avoid `execSync` with template strings containing dynamic paths. Instead, use `execFileSync` (or `spawnSync`) which executes the binary directly without passing the command through a shell. The arguments are passed as an array to `execFileSync`, naturally preventing any shell injections: `execFileSync(process.execPath, ["--check", tempFile], { stdio: "pipe" });`.
4 changes: 2 additions & 2 deletions packages/core/src/reconcile.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { execSync } from "node:child_process";
import { execFileSync } from "node:child_process";
import crypto from "node:crypto";
import fs from "node:fs";
import path from "node:path";
Expand Down Expand Up @@ -139,7 +139,7 @@ export function reconcile(options: ReconcileOptions): ReconcileResult {
fs.writeFileSync(tempFile, extractedCode, "utf8");

try {
execSync(`node --check "${tempFile}"`, { stdio: "pipe" });
execFileSync(process.execPath, ["--check", tempFile], { stdio: "pipe" });
log.audit("Syntax check passed");
} catch (err) {
const stderr =
Expand Down
Loading