AI security · red teaming · guardrails

LLM Red-Team & Guardrail Lab

I attacked a deliberately vulnerable AI support chatbot with 78 prompt-injection and data-leak attacks, added seven guardrails, and measured what each one really does — including on attacks the guardrails were never tuned on.

All data is synthetic: a fictional company with planted fake secrets. Runs locally on a local model via Ollama. Scored by code, not by an AI judge.

Main attack set

– → –

attack success rate, no guardrails → all guardrails

Hold-out set (never tuned on)

– → –

attack success rate on unseen attacks

Normal questions blocked

–

across all guardrail configurations

Leaks with all guardrails

0

no secret leaked, no other customer's order fetched, no phishing link

What each guardrail does on its own

Attack success rate per configuration. Lower is better. The hold-out bar is the honest one: those attacks were written separately and never used for tuning.

Main set Hold-out set

Results by attack category

CategoryOWASP LLM Top 10 (2025)MITRE ATLASMain: none → allHold-out: none → all

Key findings

  1. Pattern-based defences overfit. Input screening (G5) cut main-set successes from 21 to 14 — and had zero effect on the hold-out set. Document quarantine (G4) stopped all known poisoned documents and none of the new ones.
  2. Root-cause fixes generalise. An ownership check in code (G2) and keeping internal documents out of search (G1) held on both sets. A hardened prompt alone still allowed unauthorised order lookups: asking a model to enforce access control is not access control.
  3. Format-based output checks generalise too. The output check (G6) stopped every planted-secret leak on both sets without knowing the secret values.
  4. Fixes have side effects. Removing the secret from the system prompt (G3) increased tool misuse and jailbreak successes. Every change needs a full regression run.
  5. Injection is not solved — its impact can be. With all guardrails, the only attacks that still work make the bot append an attacker's word to a correct, safe answer.

The guardrails

G1 · Document access control

Customers can only search public documents.

G2 · Tool authorisation

Orders are returned only to their owner, enforced in code.

G3 · No secrets in the prompt

Nothing confidential is given to the model.

G4 · Untrusted documents

Documents are marked as data; sections that instruct the AI are quarantined.

G5 · Input screening

Known injection patterns are refused.

G6 · Output check

Secret-shaped strings, copied private text and foreign links are blocked.

G7 · Hardened prompt

Clear scope and instruction priority.

Keeping the numbers honest