How to scan text for prompt injection
Short answer
Scan for override instructions, system-prompt disclosure requests, secret exfiltration, role labels, hidden markup, and encoded strings. Then treat the text as untrusted data and keep tool permissions narrow.
Scan before retrieval becomes instructions
Indirect prompt injection often hides inside pages, comments, documents, or emails that an AI workflow is asked to summarize. Review the text before a model can treat it as instructions.
- Override phrases like
ignore previous instructions. - Disclosure requests like
show the system prompt. - Secret movement requests like
send API keys. - Role labels such as
system:or hidden HTML comments. - Long encoded strings that should be decoded and inspected.