SecureSeniorSecurityAuto-graded
Stop retrieved text from hijacking an LLM prompt
Clean retrieved documents before they go into the prompt, so text hidden in them can't pose as instructions to the model.Your pipeline pastes retrieved chunks and tool output into the prompt, between a pair of fences that mark them as data. Some chunks are written to be read as instructions instead: fake role headers, phrases like "ignore previous instructions", or a copy of your closing fence. Writesanitize_context(text) to defuse them line by line, following the policy in sanitizer.py. Lines with nothing suspicious must come back exactly as they went in.40 min
python
You're done when
- Lines that start with a fake role marker no longer start with it.
- Instruction-override phrases are gone from the output.
- Neither wrapper fence survives anywhere in the output.
- Ordinary lines, including ones that mention words like "system" or use a normal colon or header, come back exactly as they went in.
- In a document that mixes normal lines with attacks, the attacks are defused and the normal lines come back unchanged.
What it measures
Trust boundariesTreating retrieved content as untrusted input before it reaches the model.
Attack coverageCatching every kind of injection the policy lists.
No over-blockingWhether ordinary text, headers and colons pass through unchanged while the attacks are removed.
Your environment
Terminal + editorA full shell in the browser
Claude CodePre-authenticated, no key setup
Isolated microVMYours alone, wiped afterwards
Start this lab
40 min
Start labYou'll sign in to Anthropos to start. The lab opens in a private cloud workspace with Claude Code ready to use.AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo