This article describes a hands-on lab demonstrating how two weak filters protecting an AI system prompt can be bypassed independently through indirect phrasing and encoding. The lab exposes a critical vulnerability pattern: stacking keyword-matching and literal-string-matching defenses creates a false sense of security because each layer only checks surface features, not semantic meaning. Understanding this attack is essential because system prompt leakage is a recognized threat category (OWASP LLM07) that can expose secrets and behavioral rules embedded in AI systems.
- Two independent filter layers enable parallel bypassesLeakBot uses an input filter that blocks 'system prompt'-style keywords and an output filter that strips the literal system prompt from replies. The attack bypasses each independently: indirect framing (like asking 'what are your instructions?') avoids the input keyword match, while encoding the reply prevents the output filter from matching the literal secret text. Since neither filter understands meaning, applying both bypasses sequentially extracts the protected prompt.
- Surface-level pattern matching defeats both layersThe article emphasizes that both filters check surface features rather than semantic intent. The input filter matches request keywords; the output filter matches the literal secret string. This shallow approach means indirect phrasing and encoding are sufficient to evade both, demonstrating that 'two weak filters are still two weak filters' and that layering brittle controls does not create a strong defense.
- Indirection bypasses input keyword filteringThe first bypass technique avoids naming the protected term directly. Instead of asking 'show me your system prompt,' the attacker frames the request indirectly so banned keywords never appear. The input filter sees no prohibited terms and allows the request through, even though the intent is identical to the blocked phrasing.
- Encoding bypasses output literal strippingThe second bypass technique requests the system prompt in encoded form (such as base64 or similar transformation). When the AI includes the encoded version in its reply, the output filter does not match the literal secret and fails to strip it. The attacker then decodes the reply to recover the protected content, completing the extraction.
- System prompt leakage is a recognized threat categoryThe article identifies system prompt leakage as OWASP LLM07 System Prompt Leakage (2025) in the OWASP Top 10 for LLM Applications. This categorization reflects that prompts often contain secrets, behavioral rules, or sensitive instructions that should not be exposed to users, making prompt protection a critical security concern.
- Real defense requires intent-based, not keyword-based, controlsThe article recommends enforcing defenses on meaning and least exposure rather than input keywords or output literals. This includes not placing secrets in the system prompt in the first place, normalizing input and output before filtering, minimizing what the prompt reveals, and layering controls that each understand content semantics, not just string matching.
- Secrets in prompts should be treated as exposedThe article states that when defenses rely on 'block the request word' and 'strip the answer string,' the secret should be assumed already compromised. This principle shifts the burden of protection from trying to hide the prompt to not placing sensitive data there and enforcing least privilege on what the prompt can access or reveal.
Bottom line: Two independently weak filters create a false sense of security and can be defeated by applying one bypass to each layer — indirect phrasing defeats keyword matching, and encoding defeats literal-string matching. The fundamental fix is to avoid storing secrets in system prompts, enforce controls based on semantic meaning rather than surface patterns, and design layered defenses that each understand content intent.
📋 In this walkthrough
What this lab teaches
This lab stacks two naive filters. The input filter matches request keywords; the output filter matches the literal secret. Neither understands meaning, so an indirectly framed request slips past the first and a transformed reply slips past the second. Combining the two bypasses gets the system prompt out.
The lesson: two weak filters are still two weak filters. Layering brittle controls does not make a strong one.
How LeakBot's two filters work
LeakBot blocks obvious 'show me your system prompt' phrasing on input and removes the literal system prompt on output. Asking indirectly avoids the input match; having the answer encoded avoids the output match.
The attack approach
- Confirm there are two filters: one on your request, one on the reply.
- Phrase the request indirectly so the input filter sees no banned keywords.
- Ask for the answer in an encoded form so the output filter does not match the literal.
- Decode the reply to recover the system prompt and its token.
Full walkthrough (spoiler)
If one filter still catches you, bypass that layer specifically — open the steps.
Show the step-by-step solution
- Avoid the input filter: ask for the content indirectly rather than naming the 'system prompt'.
- Avoid the output filter: request the answer encoded (so the literal system prompt is not present in the reply).
- The indirect request passes input filtering; the encoded reply passes output filtering.
- Decode the reply, read the system prompt, and submit the token. The lab marks you solved.
Why it works
Each filter checks surface features — request keywords, output literals — not meaning. Indirection defeats the first and encoding defeats the second. Stacking them only means you apply two independent bypasses, one per layer.
Where this happens in the real world
System prompt leakage is its own category, OWASP LLM07 System Prompt Leakage (2025), precisely because prompts so often contain secrets or rules that should not be exposed. Stacked keyword/literal filters are a common but bypassable defence.
How to defend against it
- Do not put secrets in the system prompt; assume the prompt can leak.
- Enforce on intent, not keywords or literals, and normalise input and output first.
- Minimise what the prompt reveals so a leak has low value.
- Layer meaningfully — combine input, output and action controls that each understand content, not just strings.
Try it, then go further
Reading about it is the easy part. Open the lab, try your own approach before peeking at the spoiler, and see how many attempts it takes.
