Skip to content

Add llm_memory_local sandbox and Conversation Memory Poisoning exploit (#22) - #60

Open
fasinet wants to merge 3 commits into
GenAI-Security-Project:mainfrom
fasinet:memory-poisoning-sandbox
Open

Add llm_memory_local sandbox and Conversation Memory Poisoning exploit (#22)#60
fasinet wants to merge 3 commits into
GenAI-Security-Project:mainfrom
fasinet:memory-poisoning-sandbox

Conversation

@fasinet

@fasinet fasinet commented Sep 4, 2026

Copy link
Copy Markdown

Summary

Implements #22: a new llm_memory_local sandbox with persistent
conversation memory, plus a working Conversation Memory Poisoning exploit.

As discussed in #22 with @felipepenha, this is the contribution intended to
lead the memory-poisoning implementation.

What's included

Sandbox — sandboxes/llm_memory_local/

  • SQLite-backed conversation memory (app/memory.py), with an
    intentionally unscoped long-term fact store that models the
    vulnerability
  • FastAPI mock OpenAI endpoint wired to memory, plus /v1/memory/facts
    and /v1/memory/reset debug endpoints
  • session_id support across the API, Gradio UI, and automated test client

Exploit — exploitation/memory_poisoning/

  • attack.py plants an instruction as one session, then confirms it leaks
    into an unrelated victim session
  • Makefile automation (setup / attack / stop / all) and a README
    write-up with attack diagram

How to test

cd exploitation/memory_poisoning
make setup
make attack

Expected: the victim session's reply contains the attacker's planted
payload — [!] VULNERABLE: poisoned instruction leaked...

Notes

  • Tested end-to-end containerized (Podman)
  • Passes black, isort, and mypy
  • The threat_model/ directory is inherited from llm_local and does not
    yet cover the memory-specific attack surface (noted in the sandbox README)

Implements issue GenAI-Security-Project#22: a persistent-memory LLM sandbox and a working
Conversation Memory Poisoning exploit.

Sandbox (sandboxes/llm_memory_local):
- SQLite-backed conversation memory (app/memory.py) with an
  intentionally unscoped fact store to demonstrate the vulnerability
- FastAPI mock OpenAI endpoint wired to memory, plus /v1/memory/facts
  and /v1/memory/reset debug endpoints
- session_id support across the API, Gradio UI, and test client

Exploit (exploitation/memory_poisoning):
- attack.py plants a fact as one session and confirms it leaks into an
  unrelated victim session
- Makefile automation (setup/attack/stop/all) and README write-up

Tested end-to-end containerized (Podman); passes black, isort, mypy.
Add explicit dark text color to styled diagram nodes so labels are
readable on GitHub's dark theme, and shorten exploit diagram labels to
avoid text cutoff. Also apply isort import ordering to gradio_app.py.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant