Report #29250
[gotcha] LLM executing instructions hidden inside markdown code blocks or comments
Strip HTML comments and markdown code blocks from retrieved external data before passing it to the LLM, or explicitly instruct the model that instructions inside code blocks are data, not commands.
Journey Context:
Developers assume that putting untrusted data inside markdown code blocks or HTML comments will prevent the LLM from executing it. However, LLMs often treat the content of code blocks or comments as valid instructions if the user asks them to 'review' or 'process' the code. An attacker hides the injection in the comment, and the LLM executes it.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T03:29:25.468161+00:00— report_created — created