Detection Rules Catalog

AgentShield ships 20 built-in rules mapping to CWE and OWASP MCP Top 10 categories, catching toxic data flows, command execution, and prompt surfaces.

SHIELD-001 Command Injection CRITICAL CWE-78 OWASP MCP05

Detects process executions (subprocess.run, os.system, exec) where commands or arguments originate from tool parameters or interpolated variables. Supports cross-function interprocedural tracing.

❌ Vulnerable Example
@mcp.tool()
def execute(cmd: str):
    return subprocess.run(cmd, shell=True)
✔ Safe Pattern
@mcp.tool()
def execute(safe_target: str):
    return subprocess.run(["git", "status", safe_target])
SHIELD-002 Credential Exfiltration CRITICAL CWE-522 OWASP MCP06

Flags files accessing sensitive environment variables or local credentials while simultaneously initiating outbound HTTP requests.

SHIELD-003 Server-Side Request Forgery (SSRF) CRITICAL CWE-918 OWASP MCP05

Detects outbound HTTP calls (fetch, requests.get, axios.get) fetching URLs derived from unvalidated tool inputs without allowlist protection.

SHIELD-004 Arbitrary File Access HIGH CWE-22 OWASP MCP02

Catches file system reads and writes where file paths are constructed directly from user parameters, enabling directory traversal (../../etc/passwd).

SHIELD-016 Unsafe Deserialization HIGH CWE-502 Auto-Fixable

Identifies dangerous deserializers such as yaml.load without SafeLoader or pickle.loads. Can be automatically remediated with agentshield fix.

SHIELD-020 Composite Read-Exfiltrate Flow HIGH CWE-200 Multi-Stage

Analyzes composite value-flow graphs where a local file or environment variable is read, transformed, and subsequently placed into an outbound HTTP network request body.

SHIELD-021 SQL Injection in Database Tools CRITICAL CWE-89 MCP05

Detects unparameterized or dynamically interpolated SQL queries (cursor.execute(f"..."), pool.query(`...`), $queryRawUnsafe) in AI agent tools and MCP database servers.

SHIELD-022 Local File Exfiltration via Webhook CRITICAL CWE-200 MCP06

Flags patterns where local file system contents (open().read(), fs.readFileSync()) are read and transmitted directly to external HTTP webhooks, POST endpoints, or multipart uploads.

SHIELD-023 System Prompt Injection Surface HIGH CWE-74 MCP04

Detects unsanitized parameters, tool inputs, or user variables interpolated directly into LLM system instructions (system_prompt = f"...", systemPrompt: `...`) without structural delimiters.

SHIELD-024 Insecure Network Bind HIGH CWE-1327 MCP08

Flags MCP servers and agent transports that bind to wildcard interfaces (host="0.0.0.0", app.listen(port, "0.0.0.0")) without explicit authentication, preventing unauthorized network exposure and DNS rebinding attacks.

SHIELD-025 Insecure Temporary File Creation MEDIUM CWE-377 MCP02

Detects temporary file creation using predictable paths in shared directories (/tmp/..., /var/tmp/...) or deprecated functions like tempfile.mktemp() subject to race conditions and symlink attacks.