STAGE 8 · SECURITY MIDDLEWARE
PII Vault and Injection Shield
Raw PII never reaches the model, another agent's output is treated as hostile until sanitized, and tool scopes are enforced, not suggested.
1 · PII vault tokenize before the model ever sees the message
VAULT (TOKEN → MASKED VALUE, TYPE)
No tokens yet. Run the tokenizer.
EXACTLY WHAT THE MODEL SEES
Run the tokenizer to see the model-visible text.
SAMPLE MODEL REPLY (WRITTEN AGAINST TOKENS)
The reply template fills in once tokens exist.
REHYDRATED REPLY (TOKENS SWAPPED BACK, INSIDE YOUR TRUST BOUNDARY ONLY)
Nothing rehydrated yet.
2 · Injection shield Agent A's output is untrusted data, not instructions
WHAT AGENT B ACTUALLY RECEIVES
Sanitizer rules
- Instruction-like lines are removed: role headers (SYSTEM:, Assistant:, Developer:), "ignore your instructions", embedded tool calls like db.delete_all, "you must", "disregard", "override".
- Markdown image URLs are removed whole: an image beacon can smuggle data out in its query string.
- Plain links to hosts outside the allowlist (northwind.example.com) are defanged to hxxps so nothing auto-fetches them.
- Whatever survives is wrapped in a block labeled UNTRUSTED DATA, so the receiving agent reads it as data, never as commands.
3 · Scope check least privilege, enforced by the middleware
AGENT TOKEN SCOPES
Scope middleware ready. Every attempt is checked and logged.
WHAT THIS PROVES
- Tokenization at the boundary means a model breach leaks UUIDs, not card numbers: the vault is the only place PII and tokens meet.
- Prompt injection is a data problem before it is a model problem: strip, defang, and label, and the poisoned text loses its teeth.
- Scopes beat intentions: an agent holding only db.read cannot delete anything, no matter what a poisoned input tells it to do.