Prompt injection, demonstrated against a live model
This is the real code from the llm-security-lab repository, running in your browser through Pyodide, which is Python compiled to WebAssembly. There is no server and no API key. A deterministic mock model stands in for a real one and fails in the way real models do, by giving too much weight to the most forceful instruction it sees. Type an attack below and watch the same request go through a vulnerable path and a hardened path side by side.
Scenario A. Direct injection
The attacker talks to the assistant directly and tries to make it reveal the confidential operator key it was told to protect.
Vulnerable
Hardened
Scenario B. Indirect injection, through a poisoned document
The attacker never talks to the assistant. They hide an instruction inside a document the assistant is later asked to summarize. This is the vector that grows as agents read web pages, emails, and tool output.