Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
gpt-5.4-mini's ticket payload no longer gets past the defenses on gpt-5.6-luna, so Step 3's canary demo had nothing to catch. The new policy payload leaks past delimiters and tripwire in about half of runs (19 of 38 measured) and is always withheld by the canary check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the app into the src/acme_support package and the tests into tests/. Replace requirements.txt with a pyproject.toml (uv_build, pytest in a dev group) and a uv.lock. Add a `demo` script entry point, so the demo runs as `uv run demo rag policy`, and document setup and usage in the README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On gpt-6-luna, the hardened system prompt stops every payload in the corpus, and the starter still leaks rephrased and policy. Both test suites pass unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the clean and poisoned documents out of corpus.py into docs/clean/ and docs/poisoned/, so the knowledge base looks like data the app retrieves rather than source code. corpus.py now loads them from disk and keeps the same CLEAN and PAYLOADS names. Rename the "direct" payload to "override", since "direct prompt injection" means an attack typed into the chat, and every payload here arrives through a retrieved document. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Clean and poisoned documents now sit side by side in docs/, the way a poisoned document would hide in a real knowledge base. corpus.py names the attack files in a POISONED set to split CLEAN from PAYLOADS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rag.py is now the undefended starter that readers harden step by step, so starter.py and the finished tests are gone. demo.py takes a single payload name, and the README describes the build-along workflow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The script fires one poisoned document at the app and prints the reply, so `uv run attack policy` says what it does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
corpus.py now loads every document in docs/ without a list of attack files, the way a real app has to trust its knowledge base. The four poisoned documents move to attacks/, and attack.py plays the malicious user: it plants one of them among the real documents and asks an ordinary question. The attack list now lives only in attack.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Where to put new files:
my-awesome-articleHow to merge your changes:
Code examples for the How to Defend a Python RAG App Against Prompt Injection tutorial. Files live in the
prompt-injection-python/top-level folder, named after the article slug.Generated from the tutorial markdown with the
post-materialsskill, then verified locally on Python 3.14 with the pinned requirements:pytestpasses offline (4 passed, 5 skipped, 1 xfailed) and end to end (9 passed, 1 xfailed), anddemo.pyreproduces the article's outputs.🤖 Generated with Claude Code