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 @@
## 2026-10-24 - [Command Injection via execSync in Reconciler]
**Vulnerability:** Use of execSync with a dynamically constructed string containing a file path.
**Learning:** File paths can contain shell metacharacters which could lead to command injection if passed directly to execSync.
**Prevention:** Always use spawnSync with an array of arguments, avoiding the use of a shell where possible.
16 changes: 5 additions & 11 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 { spawnSync } from "node:child_process";
import crypto from "node:crypto";
import fs from "node:fs";
import path from "node:path";
Expand Down Expand Up @@ -138,20 +138,14 @@ export function reconcile(options: ReconcileOptions): ReconcileResult {
fs.mkdirSync(path.dirname(tempFile), { recursive: true });
fs.writeFileSync(tempFile, extractedCode, "utf8");

try {
execSync(`node --check "${tempFile}"`, { stdio: "pipe" });
log.audit("Syntax check passed");
} catch (err) {
const stderr =
err && typeof err === "object" && "stderr" in err
? String((err as { stderr?: Buffer }).stderr ?? "")
: err instanceof Error
? err.message
: String(err);
const checkResult = spawnSync(process.execPath, ["--check", tempFile], { stdio: "pipe", encoding: "utf8" });
if (checkResult.status !== 0 || checkResult.error) {
const stderr = checkResult.stderr ?? (checkResult.error ? checkResult.error.message : "Syntax check failed");
consolidateSharedContext(sharedContext, `Syntax Error:\n${stderr}`);
if (fs.existsSync(tempFile)) fs.unlinkSync(tempFile);
return { success: false, reason: "Syntax check failed" };
}
log.audit("Syntax check passed");

if (options.benchmark) {
const staticResult = runBenchmarkStaticVerification(options.workspace, options.benchmark);
Expand Down
Loading