command-injection
Skill17 starsChanged 47 days agoMITView on GitHub
Analyze OS command and shell injection in application code — use when reviewing subprocess, exec, system, shell=True, or user-influenced shell strings (CWE-78 / CWE-77 / A03:2021).
We split this skill into the rules it gives an agent
6 rules. 0 are common, 4 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 42
After AXguard hits injection.* shell/exec rules.
- Distinctive: line 59
Read secrets, pivot laterally, install persistence.
- Distinctive: line 67
Check whether “sanitization” is denylist-based (usually insufficient) vs allowlisted tokens.
- Distinctive: line 84
Test harnesses intentionally calling shells on fixtures
- Distinctive: line 88
Prefer native libraries over shelling out.
- Very specific: line 89
Use argv arrays; never shell=True with untrusted data.
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Command Injection Analysis
Purpose
Teach defensive analysis of OS command injection and unsafe shell invocation: untrusted input alters the command line interpreted by a shell or exec API, yielding RCE on the application host.
When to Use / When Not to Use
Use when:
- Code uses
os.system,subprocesswithshell=True,exec/spawnwith string commands,Runtime.exec, backticks,child_process.exec, CI hooks, image/ffmpeg wrappers, ping/traceroute utilities. - After AXguard hits
injection.*shell/exec rules. - Agent/tool runners execute model-suggested shell commands (
/axguard-agentadjacency).
Do not use when:
- Process APIs use fixed argv arrays with no shell and no user-controlled binary path (still review path traversal on filenames separately).
- Pure in-process
evalof language code (different skill /injection.python-evalclass — still injection, but not OS command).
Security Concepts
Shell metacharacters (|;$&\\n) change command **structure**. Argument arrays avoid the shell; they do not fix a user-controlled **executable path** or unsafe flags. shell=False` + argv is the default safe pattern when an external binary is required.
Threat Model
Attacker goals:
- Execute arbitrary OS commands as the app user.
- Read secrets, pivot laterally, install persistence.
- Abuse privileged wrappers (sudoers, setuid helpers, container breakout via mounts).
Analysis Workflow
- Find sinks:
system,popen,subprocess.*,exec(,spawn(,Runtime.exec,ProcessBuilderwith concatenated strings. - Determine if a shell is involved (
shell=True,/bin/sh -c, string form ofexec). - Trace attacker influence on command string, argv elements, env, or cwd.
- Check whether “sanitization” is denylist-based (usually insufficient) vs allowlisted tokens.
- Confirm whether the binary itself is fixed or user-selectable.
- Assess runtime privileges (container root, cloud role, access to secrets mounts).
- For AI agents: treat model/tool output as untrusted input to the same sinks.
Evidence Requirements
- Sink location and shell vs argv mode
- Source of taint into command/args
- Missing allowlist or unsafe concatenation
- Privilege/impact context of the process
False Positive Controls
- Hard-coded argv, no user influence
- Validated allowlist of subcommands/flags mapped server-side
- Library wrappers that only accept typed enums
- Test harnesses intentionally calling shells on fixtures
Remediation
- Prefer native libraries over shelling out.
- Use argv arrays; never
shell=Truewith untrusted data. - Allowlist executables and arguments; reject metacharacters by refusing shell entirely.
- Drop privileges; isolate in a locked-down worker/container.
- For agents: require human approval / strict tool allowlists for shell tools.
Verification
Detect shell sinks → Convert to argv/allowlist → Re-run axguard → Confirm no string-built shell calls remainRelated Skills
ssti-analysis,deserialization-security— alternate RCE classespath-traversal,file-upload-security— often chained into command toolssecurity-triage,security-remediation
Framework Mapping
- CWE-78 (OS Command Injection), CWE-77 (Command Injection)
- OWASP Top 10 2021 A03:2021 Injection
References
- https://owasp.org/Top10/A03_2021-Injection/
- https://cwe.mitre.org/data/definitions/78.html
- https://cwe.mitre.org/data/definitions/77.html
Research Provenance
Primary sources:
- OWASP Top 10:2021 A03 (accessed 2026-09-15)
- CWE-78, CWE-77 (accessed 2026-09-15)
Secondary / internal:
- AXGuard
rules/injection.json,/axguard-inject - AwareXone Agentic-Bug-Hunter command-injection methodology (concepts only; not copied)
Datasets:
- UVID HF dataset — category linkage concepts only (MIT license metadata review 2026-09-15)
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- cdxiaodong/cain-agent★ 953same name
- blacklanternsecurity/red-run★ 296same name
- langbyyi/websec-skills★ 4same name
- ajtazer/heckit★ 2same name
- KaanBicaklar/mona-sast-skills★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Used alongsideProjects with it also use open-redirect.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
yaklangSkillopen-redirect
Open redirect playbook. Use when URL parameters, form actions, or JavaScript sinks control navigation targets and may redirect users to attacker-controlled destinations.
Also in 3 projects that use this
In this repository39 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- ai-agent-securitySkill
- ai-application-securitySkill
- api-securitySkill
- attack-surface-mappingSkill
- authentication-analysisSkill
- authorization-analysisSkill
- axguard-auditSkill
- axguard-csoSkill
- axguard-knowledgeSkill
- axguard-preshipSkill
- axguard-remediateSkill
- axguard-reportSkill
- axguard-securitySkill
- axguard-triageSkill
- cloud-securitySkill
- configuration-securitySkill
- deserialization-securitySkill
- file-upload-securitySkill
- graphql-securitySkill
- jwt-securitySkill
- mcp-securitySkill
- oauth-securitySkill
- path-traversalSkill
- prompt-injectionSkill
- prototype-pollutionSkill
- secrets-detectionSkill
- security-architecture-reviewSkill
- security-remediationSkill
- security-triageSkill
- session-securitySkill
- sql-injectionSkill
- ssrf-analysisSkill
- ssti-analysisSkill
- supply-chain-securitySkill
- threat-modelingSkill
- websocket-securitySkill
- xss-analysisSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

