From 16c21e5afb0ce984db1dacc65c35fa370b055e2b Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 31 Oct 2026 15:45:25 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A1=EF=B8=8F=20Sentinel:=20[CRITICAL]?= =?UTF-8?q?=20Fix=20command=20injection=20vulnerability=20in=20reconcile.t?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: connerkup <72580335+connerkup@users.noreply.github.com> --- .jules/sentinel.md | 4 ++++ packages/core/src/reconcile.ts | 15 +++++---------- 2 files changed, 9 insertions(+), 10 deletions(-) create mode 100644 .jules/sentinel.md diff --git a/.jules/sentinel.md b/.jules/sentinel.md new file mode 100644 index 0000000..e0a2ff7 --- /dev/null +++ b/.jules/sentinel.md @@ -0,0 +1,4 @@ +## 2023-10-31 - [Command Injection via execSync] +**Vulnerability:** Found `execSync` being used with string interpolation on variables like `tempFile` without sanitization, posing a command injection risk. +**Learning:** Standard library execution functions like `execSync` spawn shells and are inherently vulnerable to string interpolation attacks if paths or parameters have shell characters. +**Prevention:** Always use `spawnSync` (or `spawn`/`execFile`) with explicit array-based arguments and use `process.execPath` to ensure stable runtime execution without shell interpolation. diff --git a/packages/core/src/reconcile.ts b/packages/core/src/reconcile.ts index b0285bc..4e72429 100644 --- a/packages/core/src/reconcile.ts +++ b/packages/core/src/reconcile.ts @@ -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"; @@ -138,16 +138,11 @@ 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" }); + const checkResult = spawnSync(process.execPath, ["--check", tempFile], { stdio: "pipe" }); + if (checkResult.status === 0) { 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); + } else { + const stderr = checkResult.stderr ? checkResult.stderr.toString() : "Unknown syntax error"; consolidateSharedContext(sharedContext, `Syntax Error:\n${stderr}`); if (fs.existsSync(tempFile)) fs.unlinkSync(tempFile); return { success: false, reason: "Syntax check failed" };