Skip to content

AAK-TAINT-001: Tool parameter flows to shell command

Severity
CRITICAL
Category
Taint Analysis (taint-analysis)
Scanner
agent_audit_kit/scanners/rust_pattern_scan.py, agent_audit_kit/scanners/taint_analysis.py, agent_audit_kit/scanners/typescript_pattern_scan.py
Auto-fixable
No.
SARIF name
TaintShellInjection

What it detects

A @tool function parameter is passed to os.system(), os.popen(), an os.exec*() function, a blocking subprocess call, subprocess.getoutput() or asyncio.create_subprocess_shell() without sanitization. CVE-2026-90617 (GH05TCREW PentestAgent) is the 2026 exemplar: the run_task MCP tool hands its caller-supplied task string to asyncio.create_subprocess_shell through LocalRuntime, reachable remotely because the same server binds 0.0.0.0 with no credential (that half is AAK-MCP-HTTP-NOAUTH-SERVER-001).

How to fix

Sanitize all inputs. Use subprocess with shell=False and explicit argument lists.

To confirm the finding is gone, report only this rule:

agent-audit-kit scan . --rules AAK-TAINT-001

Limitations

Only functions decorated @tool, @mcp.tool, @server.tool, @langchain.tools.tool, @crewai.tool or @autogen.tool, and a low-level @<server>.call_tool() handler, are analysed, so a FastMCP instance under another name (@app.tool()) is skipped. A call to os.system, os.popen, an os.exec* function, a subprocess function or asyncio.create_subprocess_shell is reported only when its argument is a parameter or an item read from one (arguments["cmd"], arguments.get("cmd")), or, in a call_tool handler, a local holding one at most two assignments away (cmd = arguments["cmd"]). A local in a @tool function (cmd = command) is not followed. Outside os.exec*, a literal first argument reads as a fixed command and the call is not reported whatever else it passes, so a fixed interpreter fed the caller's text on stdin (subprocess.run(["python3"], input=code)) is missed. A command built from the parameter (f"ls {path}", "ls " + path) is not, although AAK-SHELL-QUOTED-INTERP-001 reports the f-string form. A sink imported under another name is read through the file's imports (from subprocess import run, import subprocess as sp), but one bound by an assignment (sh = subprocess.run), or imported under a name the file also binds some other way anywhere, a method or another function's parameter included (def run(self) in an unrelated class), is matched by its spelling only, so a call through that name is not reported. A file with a star import reads no name through its imports, so from subprocess import * never resolves run. The TypeScript and JavaScript arm reports exec, execSync, spawn and spawnSync called on child_process or on require("child_process"), on a name bound to the module, or under a name imported from it, also when the call is split across two lines at its dot. A name is bound by an assignment of require(...) or import(...), awaited or in parentheses (a second declarator, and a name declared first and assigned later, included), by an import (import cp from, import * as cp from, TypeScript's import cp = require(...), a default item), by a .then callback, or as this.cp; it is imported by an import or destructuring list, from the module or from a name bound to it (const { exec } = cp). So execFile, a wrapper (promisify(exec), execa, cross-spawn) and a process API outside child_process (Bun.spawn, node-pty, an SSH client's exec) are not reported. Nor is a binding written another way: a typed const cp: typeof import("child_process") = require(...), a backtick require(...), module.require(...), a list with a comment in it or an item with a default value ({ exec = null }), a method copied off a bound name (const run = cp.exec), the property of an object other than this (deps.cp.exec(...)), or an exec re-exported through a local module. It reads a .js, .jsx, .mjs or .cjs file only when the file imports the SDK's server modules (@modelcontextprotocol/sdk/server/...), registers a tool (server.tool(, server.registerTool() or handles CallToolRequestSchema, so a tool module that does none of these, or a FastMCP server (server.addTool), is not reported. A JavaScript file is skipped as a bundle when its name holds .min., or when it is over 10,000 characters and its median non-blank line (the longer of the middle two, for an even number) is over 500 characters long or most of it is lines over 5,000 characters in which ( and ; make up at least 1%. So a one-line bundle of 10,000 characters or fewer is read, and a hand-written file most of whose text is one long line of inlined data with ; in it, such as a stylesheet or an SVG, is skipped, and its findings with it.

References


All rules. This page is generated from the rule registry when the documentation is built; to change it, change the rule in agent_audit_kit/rules/builtin.py. To give the rule a hand-written write-up, add docs/rules/AAK-TAINT-001.md: the page then shows that text, with the registry reference appended under it.