CVE-2026-63496: augment-virShell allows Command Injection in `grep()` via Unsanitized `searchPattern`

High CVSS 7.8

OSV id
GHSA-xvcc-vqjv-phqh
Also known as
CVE-2026-63496
Published
Last modified

Affected packages

PackageAffected versionsFixed in
@augment-vir/node
npm
< 31.73.5 31.73.5

How to fix it

Upgrade @augment-vir/node to 31.73.5 or later.

npm install @augment-vir/node@31.73.5
# if it is an indirect dependency: npm update @augment-vir/node (or npm audit fix)
  • If it is an indirect dependency, upgrade the package that depends on it, or force the version with "overrides" (npm), "resolutions" (Yarn) or "pnpm.overrides" (pnpm) in package.json.
  • Check the changelog for breaking changes (especially across major versions), update the lockfile with the package manager, and run your tests.

Not sure whether your project uses an affected version? Check your lockfile below for free.

Details

Shell Command Injection in grep() via Unsanitized searchPattern

Summary

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. CVSS Base Score: 7.8 (High).

Details

Root cause: packages/node/src/augments/fs/grep.ts:310 maps each search pattern into the shell fragment -e "${searchPattern}" with no sanitization:

// grep.ts:310
...searchPatterns.map((searchPattern) => `-e "${searchPattern}"`),

The resulting full command string is forwarded to runShellCommand (grep.ts:320), which calls streamShellCommand (shell.ts:221-224), which ultimately calls:

// shell.ts:98-99
const childProcess = spawn(command, {
    shell,   // defaults to 'bash' (shell.ts:92)

Because shell is 'bash', bash interprets $() within the double-quoted pattern as a command substitution and executes it before grep ever runs.

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.

Data flow (source → sink):

Step Location Description
1 packages/node/src/index.ts:3 export * from './augments/fs/grep.js' — exposes grep() as a public npm API
2 packages/node/src/augments/fs/grep.ts:223-226 grep() accepts caller-controlled grepSearchPattern and grepSearchLocation
3 packages/node/src/augments/fs/grep.ts:228 searchPatterns derived from grepSearchPattern.patterns || [grepSearchPattern.pattern]
4 packages/node/src/augments/fs/grep.ts:269-314 fullCommand built as a plain shell string
5 packages/node/src/augments/fs/grep.ts:310 Sink: searchPattern inserted as `-e "${searchPattern}"` — no escaping applied
6 packages/node/src/augments/fs/grep.ts:320 fullCommand passed to runShellCommand
7 packages/node/src/augments/terminal/shell.ts:221-224 Forwarded to streamShellCommand
8 packages/node/src/augments/terminal/shell.ts:98-99 spawn(command, { shell: 'bash' }) executes the constructed command string

Suggested remediation:

--- a/packages/node/src/augments/fs/grep.ts
+++ b/packages/node/src/augments/fs/grep.ts
@@
-function escape(input: string) {
-    return input.replaceAll('"', String.raw`\"`).replaceAll('\n', '');
+function shellQuote(input: string) {
+    return `'${input.replaceAll("'", String.raw`'\''`).replaceAll('\n', '')}'`;
 }
@@
-        ...searchPatterns.map((searchPattern) => `-e "${searchPattern}"`),
+        ...searchPatterns.map((searchPattern) => `-e ${shellQuote(searchPattern)}`),
+        '--',
         ...searchParts,

Alternatively, replace the shell-string approach with spawn('grep', args, { shell: false }) to avoid shell interpretation entirely.

PoC

Prerequisites: Docker installed on the host. All steps run locally inside a container — no network exposure, no real credentials, no DoS.

Step 1 — Build the Docker image:

docker build -t augment-vir-vuln-001-poc \
  vuln-001

Step 2 — Run the exploit container:

docker run --rm --name augment-vir-vuln-001-run augment-vir-vuln-001-poc

Core exploit (exploit.mjs inside the container):

import { grep } from '@augment-vir/node';

await grep(
  { pattern: '$(touch /tmp/augment-vir-poc-triggered)no-match' },
  { file: 'package.json' },
);

The $() 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.

Expected output:

[*] Calling grep() with injected $() command substitution pattern...
[*] Pattern: $(touch /tmp/augment-vir-poc-triggered)no-match

=== VULNERABLE ===
[+] COMMAND INJECTION CONFIRMED: sentinel file exists at /tmp/augment-vir-poc-triggered
[+] The $() substitution in pattern was executed by bash via spawn({shell:"bash"})

Minimal reproduction without Docker:

```bash mkdir /tmp/av-grep-poc && cd /tmp/av-grep-poc npm init -y npm install @augment-vir/node@31.73.2

cat > poc.mjs <<'EOF' import { grep } from '@augment-vir/node'; await grep( {

References

Am I affected?

Upload or paste your lockfile. We check every package version in it against OSV.dev, this advisory included, and email you the vulnerable ones with the version that fixes them. Free, and no account needed.

or paste its content

Needed when you paste. package.json and pyproject.toml only have version ranges: use the lockfile next to them.

Only package names and versions are checked; the file itself is not kept. We use your email to send this report and nothing else unless you tick the box above. Privacy policy.

About this data

Source: GitHub Advisory Database via OSV.dev (CC-BY 4.0). Severity comes from the advisory's own rating when it has one, else from its CVSS score.