AAK-PROMPT-DELIMITER-001: Untrusted text sits between prompt delimiters with the closing one unescaped
- Severity
- LOW
- Category
- Taint Analysis (
taint-analysis) - Scanner
agent_audit_kit/scanners/llm_call_shapes.py- Auto-fixable
- No.
- SARIF name
PromptDelimiterUnescaped
What it detects
A Python f-string puts a function's parameter straight between prompt delimiters (<user_input>{message}</user_input>, or a repeated fence such as three backticks, ### or ---), in a file that calls a model, with nothing done to the value. Delimiters beat bare concatenation, but text that contains the closing delimiter closes it itself and writes what comes after it as if the prompt's author had. A value run through a call in the braces, or rebound from a call first, does not fire.
How to fix
Escape or strip the closing delimiter from the value before it goes in, or pass the text as a separate message or a structured field rather than inside the instruction string. Add a test whose input contains the closing delimiter and an instruction after it, and assert the output does not change.
To confirm the finding is gone, report only this rule:
agent-audit-kit scan . --rules AAK-PROMPT-DELIMITER-001
Limitations
Reads Python f-strings, one function at a time, in a file that mentions a model API (chat.completions, ChatCompletion, messages.create, responses.create, ChatOpenAI, ChatAnthropic, generate_content, litellm, ollama, openai, anthropic, langchain). The value must be a parameter, or an attribute or item of one, with the delimiter text right beside it on both sides. So a local from elsewhere, .format, %, + and string.Template are not read, and neither is another language. A tag from a list of HTML tags (div, span, p and the like) is left out. A call in the braces or a name rebound from a call counts as escaping, with nothing to show it handles the closing delimiter, so {str(message)} is missed. Whether the value can come from an attacker is not read, so an id passed as a parameter fires. Paths with a tests, fixtures, examples, samples or demos directory, and test_*.py and conftest.py, are skipped. A source file over 512 KB is not read.
References
- OWASP Agentic Top 10: ASI01 (Agent Goal Hijack)
- Adversa AI MCP Top 25 (AAK-defined ids): ADV-INJECT-04 (Tool Param Shell Injection)
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-PROMPT-DELIMITER-001.md: the page then shows that text, with the registry reference appended under it.