/command-injection
Detect OS command injection via shell execution sinks where user-controlled input reaches system commands without proper sanitization.
$ npx -y skills add ByamB4/find-cve-agent --skill command-injection --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.
- You can call itInvoke it directly when you want it.
- Slash command
/command-injection
Context preview
The summary Claude sees to decide when to auto-load this skill.
Detect OS command injection via shell execution sinks where user-controlled input reaches system commands without proper sanitization.
SKILL.md
command-injection.SKILL.mdname: command-injection
description: "Detect OS command injection via shell execution sinks where user-controlled input reaches system commands without proper sanitization."
metadata:
filePattern:
- "**/*.js"
- "**/*.ts"
- "**/*.py"
- "**/*.go"
- "**/*.rb"
- "**/*.php"
bashPattern:
- "semgrep.*cmdi"
- "grep.*(exec|spawn|system|popen)"
priority: 90Command Injection Detection
When to Use
Audit any package that wraps CLI tools, runs build commands, processes files via external programs, or interfaces with git/ffmpeg/imagemagick/pandoc/etc.
CVSS is typically CRITICAL 9.8 for confirmed RCE.
Key Distinctions
Command Injection vs Argument Injection
- **Command injection**: Attacker breaks out of the intended command entirely (`; rm -rf /`)
- **Argument injection**: Attacker adds flags to the intended command (`--upload-pack=malicious`)
- Both are reportable. Command injection is CRITICAL, argument injection is HIGH.
Shell vs No-Shell Execution
- **Shell execution** (exec, system, os.popen): Command string passed to shell interpreter. Metacharacters (`;`, `|`, `&&`, backticks, `$()`) are interpreted. DANGEROUS.
- **Direct execution** (execFile, spawn without shell, subprocess with list args): Arguments passed directly to the program. No shell interpretation. SAFER but argument injection may still work.
Process
Step 1: Find Shell Execution Sinks
# JavaScript/TypeScript — look for child_process usage
grep -rn "child_process" .
grep -rn "\.exec\('" .
grep -rn "\.execSync\(" .
grep -rn "spawn.*shell.*true" .
grep -rn "shelljs" .
# Python
grep -rn "os\.system\|os\.popen" .
grep -rn "subprocess.*shell.*True" .
grep -rn "commands\.getoutput\|commands\.getstatusoutput" .
# Go
grep -rn 'exec\.Command.*"bash"\|exec\.Command.*"sh"' .
# Ruby
grep -rn "system(\|%x{" . --include="*.rb"
grep -rn "IO\.popen\|Open3" .
# PHP
grep -rn "system(\|passthru(\|shell_exec(\|popen(" .
grep -rn "proc_open\|pcntl_exec" .Step 2: Trace User Input to Sink
For each sink: 1. What command string is constructed? 2. Is any part from user input (HTTP params, filenames, config values)? 3. Is the user input interpolated into a shell string or passed as an argument array?
Step 3: Check Sanitization
grep -rn "escapeshellarg\|escapeshellcmd\|shlex\.quote\|shellescape" .
grep -rn "sanitize\|escape\|clean\|validate" .
Verify sanitization is:
- Applied to ALL user-controlled parts (not just some)
- Using the right function (escapeshellarg vs escapeshellcmd)
- Not bypassable (blocklists are almost always bypassable)
Step 4: Check for Argument Injection
Even with execFile/spawn (no shell), check for:
- `--flag` injection: user input starts with `-` or `--`
- Git-specific: `--upload-pack`, `-c core.fsmonitor`, `--config`
- Arguments that accept commands: `--exec`, `--filter`, `--diff-filter`
- Double-dash (`--`) separator missing before user-controlled args
Common Vulnerable Patterns
Pattern 1: String Interpolation in Shell Execution
// VULNERABLE — shell interprets metacharacters
const cp = require('child_process');
cp.exec(`convert ${inputFile} ${outputFile}`);
// Exploit: inputFile = "; id; #"Pattern 2: Filename-Based Injection
cp.exec(`file "${filename}"`);
// Exploit: filename = '$(id).txt' or filename = '"; id; #"'Pattern 3: Git Argument Injection
// Even without shell, git interprets dangerous flags
cp.execFile('git', ['clone', userUrl, '--config', 'core.fsmonitor=id']);Pattern 4: Environment Variable Injection
cp.exec(command, { env: { ...process.env, USER_INPUT: untrusted } });
// If command references $USER_INPUT or uses env vars unsafelyPattern 5: Newline Injection
cp.execFile('program', ['--option=' + userInput]);
// Exploit: userInput = "value\n--dangerous-flag"Grep Patterns by Vulnerability Type
Direct Shell Injection
grep -rn "exec\(.*\+" . # String concatenation in exec
grep -rn "exec\(.*\$\{" . # Template literal in exec
grep -rn "exec\(.*%" . # Format string in exec (Python)Argument Injection
grep -rn "execFile\|spawn" .
# Then check if user input is in the args array without -- separator
CVSS Guidance
- Unauthenticated RCE: CRITICAL 9.8
- Authenticated RCE (low-priv): HIGH 8.8
- Argument injection (limited impact): HIGH 7.5-8.1
- Requires specific config/setup: HIGH 7.2 (AC:H)
References
- [Sinks](references/sinks.md) — Shell execution sinks by language
- [False Positive Indicators](references/false-positive-indicators.md) — When this isn't exploitable
- [PoC Skeleton](references/poc-skeleton.md) — Command injection PoC template
Read more
name: command-injection
description: "Detect OS command injection via shell execution sinks where user-controlled input reaches system commands without proper sanitization."
metadata:
filePattern:
- "**/*.js"
- "**/*.ts"
- "**/*.py"
- "**/*.go"
- "**/*.rb"
- "**/*.php"
bashPattern:
- "semgrep.*cmdi"
- "grep.*(exec|spawn|system|popen)"
priority: 90Command Injection Detection
When to Use
Audit any package that wraps CLI tools, runs build commands, processes files via external programs, or interfaces with git/ffmpeg/imagemagick/pandoc/etc.
CVSS is typically CRITICAL 9.8 for confirmed RCE.
Key Distinctions
Command Injection vs Argument Injection
- **Command injection**: Attacker breaks out of the intended command entirely (`; rm -rf /`)
- **Argument injection**: Attacker adds flags to the intended command (`--upload-pack=malicious`)
- Both are reportable. Command injection is CRITICAL, argument injection is HIGH.
Shell vs No-Shell Execution
- **Shell execution** (exec, system, os.popen): Command string passed to shell interpreter. Metacharacters (`;`, `|`, `&&`, backticks, `$()`) are interpreted. DANGEROUS.
- **Direct execution** (execFile, spawn without shell, subprocess with list args): Arguments passed directly to the program. No shell interpretation. SAFER but argument injection may still work.
Process
Step 1: Find Shell Execution Sinks
# JavaScript/TypeScript — look for child_process usage
grep -rn "child_process" .
grep -rn "\.exec\('" .
grep -rn "\.execSync\(" .
grep -rn "spawn.*shell.*true" .
grep -rn "shelljs" .
# Python
grep -rn "os\.system\|os\.popen" .
grep -rn "subprocess.*shell.*True" .
grep -rn "commands\.getoutput\|commands\.getstatusoutput" .
# Go
grep -rn 'exec\.Command.*"bash"\|exec\.Command.*"sh"' .
# Ruby
grep -rn "system(\|%x{" . --include="*.rb"
grep -rn "IO\.popen\|Open3" .
# PHP
grep -rn "system(\|passthru(\|shell_exec(\|popen(" .
grep -rn "proc_open\|pcntl_exec" .Step 2: Trace User Input to Sink
For each sink: 1. What command string is constructed? 2. Is any part from user input (HTTP params, filenames, config values)? 3. Is the user input interpolated into a shell string or passed as an argument array?
Step 3: Check Sanitization
grep -rn "escapeshellarg\|escapeshellcmd\|shlex\.quote\|shellescape" . grep -rn "sanitize\|escape\|clean\|validate" .
Verify sanitization is:
- Applied to ALL user-controlled parts (not just some)
- Using the right function (escapeshellarg vs escapeshellcmd)
- Not bypassable (blocklists are almost always bypassable)
Step 4: Check for Argument Injection
Even with execFile/spawn (no shell), check for:
- `--flag` injection: user input starts with `-` or `--`
- Git-specific: `--upload-pack`, `-c core.fsmonitor`, `--config`
- Arguments that accept commands: `--exec`, `--filter`, `--diff-filter`
- Double-dash (`--`) separator missing before user-controlled args
Common Vulnerable Patterns
Pattern 1: String Interpolation in Shell Execution
// VULNERABLE — shell interprets metacharacters
const cp = require('child_process');
cp.exec(`convert ${inputFile} ${outputFile}`);
// Exploit: inputFile = "; id; #"Pattern 2: Filename-Based Injection
cp.exec(`file "${filename}"`);
// Exploit: filename = '$(id).txt' or filename = '"; id; #"'Pattern 3: Git Argument Injection
// Even without shell, git interprets dangerous flags
cp.execFile('git', ['clone', userUrl, '--config', 'core.fsmonitor=id']);Pattern 4: Environment Variable Injection
cp.exec(command, { env: { ...process.env, USER_INPUT: untrusted } });
// If command references $USER_INPUT or uses env vars unsafelyPattern 5: Newline Injection
cp.execFile('program', ['--option=' + userInput]);
// Exploit: userInput = "value\n--dangerous-flag"Grep Patterns by Vulnerability Type
Direct Shell Injection
grep -rn "exec\(.*\+" . # String concatenation in exec
grep -rn "exec\(.*\$\{" . # Template literal in exec
grep -rn "exec\(.*%" . # Format string in exec (Python)Argument Injection
grep -rn "execFile\|spawn" . # Then check if user input is in the args array without -- separator
CVSS Guidance
- Unauthenticated RCE: CRITICAL 9.8
- Authenticated RCE (low-priv): HIGH 8.8
- Argument injection (limited impact): HIGH 7.5-8.1
- Requires specific config/setup: HIGH 7.2 (AC:H)
References
- [Sinks](references/sinks.md) — Shell execution sinks by language
- [False Positive Indicators](references/false-positive-indicators.md) — When this isn't exploitable
- [PoC Skeleton](references/poc-skeleton.md) — Command injection PoC template
Open Source CVE Hunting Harness for Claude Code A Claude Code plugin that systematically finds real CVEs in open source packages through coordinated multi-agent security research.
Repo: ByamB4/find-cve-agent
Other skills on find-cve-agent.
- /advisory-mining
Mine GitHub Security Advisories and CVE databases for incomplete fixes, finding variant vulnerabilities in patched code or similar patterns in related packages.
Open skill - /auth-bypass
Detect authentication and authorization bypass vulnerabilities including missing auth middleware, JWT algorithm confusion, IDOR, and session fixation.
Open skill - /code-injection-codegen
Detect code injection vulnerabilities in packages that dynamically generate or evaluate code via new Function(), eval(), vm.run*, or template literal interpolation.
Open skill - /cross-pollination
Cross-pollination multiplier technique: find a vulnerability in one package, then search for the same pattern across all similar packages to multiply findings.
Open skill - /decompression-bomb
Detect decompression bomb vulnerabilities where compressed input can expand to exhaust memory, targeting buffer-based decompression without size limits.
Open skill - /entity-expansion
Detect XML/SVG/YAML entity expansion (Billion Laughs) vulnerabilities in parsers that allow unbounded entity definitions.
Open skill

