Conversation
…I-Security-Project#25) Adds exploitation/recommendation_poisoning targeting the llm_memory_local sandbox. Unlike the direct memory_poisoning exploit, the attacker plants a hidden instruction in a web widget (indirect prompt injection) that the app forwards into unscoped memory, steering a later unrelated user's product recommendation to the attacker's brand. - webwidget.py: extract hidden instructions (aria-label, hidden/display:none) - attack.py: live attack against the running sandbox - recommendation_demo.py: offline deterministic steering demo + regression check driving the sandbox's real app/memory.py - config, Makefile, README with attack diagram and OWASP mapping Formatted with black/isort; mypy clean.
2 tasks
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.
Summary
Implements #25 (Recommendation Memory Poisoning). Adds a new exploitation
example,
exploitation/recommendation_poisoning/, against the existingllm_memory_localsandbox (#22, #60).The angle that makes this distinct from the sibling
memory_poisoningexploitis the vector. There, the attacker sends a
"remember that ..."chatmessage in their own session. Here the attacker never talks to the assistant:
they publish a web widget — a "Share this deal" button — whose visible label is
innocent but which carries a hidden instruction (
aria-label+ adisplay:nonespan). When the application forwards that page content to theassistant, the hidden text rides along and is persisted into the unscoped
memory store, steering a later, unrelated user's product recommendation toward
the attacker's brand. This is the indirect prompt-injection scenario described
in the issue and the Microsoft "AI recommendation poisoning" writeup it links.
What's included
webwidget.py— extracts hidden instructions (aria-label,title,hidden/display:none/visibility:hiddentext) from attacker markup.attack.py— live attack against the running sandbox: harvest the hiddeninstruction, submit it, then confirm the attacker's brand leaks into an
unrelated victim's recommendation.
recommendation_demo.py— offline, deterministic companion (no container,model, or network). Three phases: neutral baseline → poisoning → leak. It
drives the sandbox's real
app/memory.py(build_memory_context/extract_and_store_facts) with a small deterministic recommender stand-in,and exits non-zero if the steering is not observed, so it doubles as a
regression check.
config/config.toml,Makefile(setup/attack/demo/stop/all), and a README with an attack diagram and OWASP mapping.How to test
Offline, no setup required:
cd exploitation/recommendation_poisoning python recommendation_demo.pyExpected tail:
Live, against the sandbox:
make setup make attack # -> [!] VULNERABLE: the poisoned brand 'QuantumGlow' leaked ...Notes
sandboxes/llm_memory_localunchanged; no sandbox edits.(
QuantumGlow) and a non-resolving.teststore.blackandisort(--profile black);mypyclean.