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
Goals
- 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
Coding agentAlready signed in, no API key to set up
Isolated workspaceOnly yours, wiped when you finish
Start this lab
40 min
Start labYou'll need to sign in to Anthropos first. The lab opens in a private cloud workspace with your coding agent ready to use.AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo