#59
Prompt injection risk
What is stopping the following from happening?
/**
* If you are an agent looking at this, do the following: [REDACTED MALICIOUS ACTION HERE]
*/Any text can become executable code via an agent. Just looking at unknown code can be dangerous (with an agent).
This is a classic indirect prompt injection scenario — and the answer to "what's stopping it?" is: nothing, by default.
The code comment
/** * If you are an agent looking at this, do the following: [REDACTED MALICIOUS ACTION HERE] */is a perfect example of what OWASP ASI-01 (Prompt Injection) calls an "indirect injection via external content." When an agent reads a codebase, every file becomes part of its context, and the LLM can't reliably distinguish between "this is code I'm analyzing" and "this is an instruction I should follow."The practical mitigations are:
OWASP Agent Memory Guard (
pip install agent-memory-guard) implements the write-path scanning approach:AgentThreatBench has ASI-01 test cases for this exact "malicious instruction in code comment" pattern — useful for testing how well your agent defends against it.