Guide

How to detect prompt injection in a document

Find visible instructions, disguised text, and concealed content in a document, then keep a clean copy without the hidden text.

Last reviewed

A document can tell an AI assistant to change the task, disclose information, or follow a link. Those instructions may be plainly visible. Review what the document asks the assistant to do, as well as what it hides.

What counts as prompt injection?

Prompt injection happens when an assistant treats untrusted content as instructions. A resume that tells an automated reviewer to award the highest score is one example. The UK National Cyber Security Centre uses a candidate CV to explain the risk.

Hidden text is a clue, not proof. Accessibility text, multilingual writing, and security training documents can produce findings too. Judge the instruction in the context of the task.

Which scenarios should you check?

  • Task changes: ignore the criteria, approve this request, or omit an unfavorable fact.
  • Fake authority: text claiming to be a system message, administrator override, or trusted tool response.
  • Disclosure requests: reveal private instructions, conversation history, credentials, or other records.
  • Action requests: send information, open a destination, run a command, or change a file.
  • Concealment: tiny, covered, off-page, or background-matched text, plus content outside the visible page.
  • Disguised words: invisible Unicode, lookalike letters, escaped codes, encoded text, or ASCII art.
  • Planted questions: an assignment sheet with a hidden, easy extra question that a student never sees, so an answer to it shows an assistant read the sheet.

OWASP documents instruction, encoding, and tool-abuse patterns. Microsoft describes hidden-text attacks in documents and markup. A visual check alone cannot cover these scenarios.

How can Unicode and ASCII disguise instructions?

Invisible Unicode can split words or carry hidden character data. Direction controls can reorder displayed text. Lookalike letters can disguise familiar words. Unicode guidance also explains legitimate uses of these characters, so deleting every unusual character is not a reliable fix.

Encodings replace words with character codes. ASCII art arranges ordinary symbols into large letters. The ArtPrompt research demonstrates why a model may interpret those shapes as words. Decoding text can expose an instruction; it does not make that instruction trustworthy.

What does the detector tell you?

Drop in a PDF, picture, web page, or pasted text. The detector reads every page and lists each finding in the sidebar with the hidden words themselves, so you can judge how serious it is at a glance. Encoded text shows up twice, as written and decoded, like a passage beside its translation. Select a finding and its words appear on the page, right where they were hidden.

The document you see is the clean copy. Hidden text starts out redacted, while visible instructions stay in until you decide, because you can already read them. Redact or restore any finding, then copy or download exactly what is on screen. When nothing turns up, the sidebar still lists every check that ran, so a clean result tells you what was ruled out.

Checks use local rules and OCR rather than a guess about the author's intent. Instruction wording is matched mainly in English. OCR can misread text, and different readers can pull different text from the same file. A check that could not finish is marked Partly checked.

What has changed lately?

New techniques keep turning up in real documents. This guide and the detector are updated as they do.

  • Added in . Planted questions: an assignment sheet with a hidden, easy extra question that a student never sees, so an answer to it shows an assistant read the sheet.

What remains outside a document scan?

A single-file scan cannot assess instructions spread across conversations, retrieved documents, or persistent memory. It cannot predict what an assistant will do. ASCII-art interpretation, arbitrary encodings, and embedded-file contents also need separate review. No findings means only that the checks found no match.

What should you do with a finding?

  1. Read the hidden or decoded words as evidence. Do not follow instructions found inside them.
  2. Compare them with the visible document and the task you actually asked for.
  3. Redact unexpected instructions, then use the clean copy in your assistant workflow.
  4. Keep sending data, running commands, and changing records behind a separate approval step.

Microsoft recommends layered defenses and human verification. Limit the assistant's access and actions even after reviewing its inputs.

Review before sharing.

Common questions

What is indirect prompt injection?
Indirect prompt injection is when external content, such as a document, is processed by an assistant and treated as an instruction instead of material to analyze.
Is concealed text the same as prompt injection?
No. Concealed text is presentation evidence that a person may miss while extraction or processing can still receive it. It can be accidental, and it does not establish the author's intent.
Can visible text still be prompt injection?
Yes. An indirect prompt injection can be visible to a person. Concealed text is one way external instructions may be missed during a normal document review.
What does the prompt injection detector check?
It checks every page for tiny or faint text, hidden or covered text, invisible or unusual characters, encoded text, instructions to an AI, extra document content, and PDF text differences. Each finding shows the hidden words in the sidebar, and the sidebar lists every check that ran, even when nothing is found.
What should I do when a finding appears?
Read the hidden words in context and treat them as content to inspect, never as instructions. Hidden text starts out redacted and visible instructions start out kept. Redact or restore each finding, then copy or download the clean copy you see on screen.