AAK-DEEPSEEK-V4-MOE-TOOL-INJ-001: DeepSeek V4 MoE-routed tool description injection
- Severity
- HIGH
- Category
- Tool Poisoning (
tool-poisoning) - Scanner
agent_audit_kit/scanners/deepseek_v4_tool_injection.py- Auto-fixable
- No.
- SARIF name
DeepSeekV4MoeToolInjection
What it detects
A function that targets DeepSeek V4 (OpenAI-compatible client with base_url= containing 'deepseek', or import deepseek) reads from an untrusted source (request body, document loader, file read) and passes the value into a tools=[{description: ...}] payload without calling sanitize_tool_description. DeepSeek V4 (Apache 2.0, 2026-04-24) exposes MoE routing via its tool-call envelope — untrusted text inside a tool description can poison expert selection (LLM01 with MoE-specific surface). Speculative shape until corpus refresh.
How to fix
Pipe untrusted tool descriptions through agent_audit_kit.sanitizers.deepseek.sanitize_tool_description before assembling the tools= payload. The sanitiser strips ANSI / control characters and routing-poison tokens ([ROUTE: ...], <|route_id|>, __route__=, etc.) and truncates to a max length. Calling it in the same function suppresses this rule.
To confirm the finding is gone, report only this rule:
agent-audit-kit scan . --rules AAK-DEEPSEEK-V4-MOE-TOOL-INJ-001
Limitations
Python only, per function. A DeepSeek target is recognised only from a string literal containing deepseek in base_url=, or a deepseek import: a URL held in a constant is not seen. An untrusted source is recognised only from a short list (request.json, request.args, pdfplumber.open, unstructured.partition, open(...).read()), so a page fetched with requests.get(url).text is not one. A call to sanitize_tool_description counts anywhere in the function, whichever value it cleans. A substitution (re.sub, re.subn, or .sub or .subn on a compiled pattern, held by a name or compiled in place) counts only when its pattern is a string literal, or a name bound to one (by an assignment in the function, in a function around it or in the module, a module-level block included, directly or through re.compile), that names route or expert (in any case), the words in the routing tokens [ROUTE: ...], <|route_id|>, __route__= and {{expert: ...}}, and its result is a description built in the same function (a "description" dict value, a description= keyword or a ["description"] assignment) or is assigned to the variable a name in one stands for: by =, += or :=, or as the first name a subn(...) unpacks into (clean, n = re.subn(...)). The substitution counts anywhere inside that value, so doc + re.sub(ROUTE, "", suffix) clears the function although doc goes out raw. A name, a pattern's included, is the variable Python resolves it to: that of the nearest function, this one or one around it, that binds it (a parameter, an assignment, an import), which a function nested in that one can also assign through nonlocal; a name a class body, a comprehension or a lambda inside the function binds counts as the function's own. The function is judged as a whole, the functions nested in it included, so one of them that cleans its description clears it too; a nested function is also judged on its own. One cleaned description clears a function, even when another tool's description goes out raw, the cleaned name is rebound to the raw text, or the keyword belongs to something else (argparse.ArgumentParser(description=re.sub(...))). What the pattern removes is not checked, so re.sub(r"route", "path", doc) counts, and a pattern built at run time or held on a class never does. A file over 512 KB is not read.
References
- OWASP Agentic Top 10: ASI01 (Agent Goal Hijack), ASI02 (Tool Misuse and Exploitation)
- CSA AI Controls Matrix (AICM): AIS-07
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-DEEPSEEK-V4-MOE-TOOL-INJ-001.md: the page then shows that text, with the registry reference appended under it.