Skip to content

Exploitation/embedding inversion - #54

Open
Prateek-Pulastya wants to merge 2 commits into
GenAI-Security-Project:mainfrom
Prateek-Pulastya:exploitation/embedding-inversion
Open

Exploitation/embedding inversion#54
Prateek-Pulastya wants to merge 2 commits into
GenAI-Security-Project:mainfrom
Prateek-Pulastya:exploitation/embedding-inversion

Conversation

@Prateek-Pulastya

Copy link
Copy Markdown

Adds an embedding inversion attack against the RAG_local sandbox in exploitation/embedding_inversion/.

Threat model: the sandbox's query API never returns raw vectors, so the only realistic leak path is a vector-only dump, e.g., a backup, an insider export, or a leaked index snapshot. The attack's victim/attacker split is based on that scenario rather than on a metadata leak.

Validated live end-to-end against a running RAG_local instance: real calls to /v1/embeddings, /v1/chat/completions, and /pinecone/vectors/upsert, real embeddings, real cosine-similarity scoring, real history-feedback loop, no mocking. This confirms the plumbing works.

One gap worth calling out directly: inversion against the sandbox's default model, gpt-oss:20b, was not demonstrated. The machine used for validation had no GPU and 8GB of RAM, well under the sandbox's stated requirements of 16GB of dedicated GPU memory and 32GB of system RAM for that model. The live run substituted llama3.2:1b (1B parameters) as the guiding chat model, with nomic-embed-text left unchanged as the embedding model. Across 15 iterations per target, best cosine similarity plateaued around 0.35-0.40 against a 0.93 threshold, and neither target string converged; recovered text was unrelated to the ground truth. A 1B-parameter guesser is a weak stand-in for the intended 20B target, so this doesn't invalidate the mechanism, but success against gpt-oss:20b itself hasn't been shown and should be checked on hardware that meets the sandbox's requirements.

The guess-and-check technique here is adapted from ranfysvalle02/hacking-vectors. It's weaker than trained inversion models like vec2text, and is meant to illustrate the vulnerability class rather than demonstrate a state-of-the-art attack.

black, isort, mypy --strict, and pytest all pass (7/7 tests). Also added uv.lock, which was missing despite the Makefile's sync/lock targets; example/ and system_reconnaissance/ both already commit one.

Addresses #29.

Implements issue GenAI-Security-Project#29 (Reverse Engineering Embeddings): reconstructs
plaintext from a leaked, metadata-stripped embedding vector using only
black-box access to the embedding model API and an LLM-guided
guess-and-check loop, adapted from ranfysvalle02/hacking-vectors.

Reuses sandboxes/RAG_local unmodified. Maps to OWASP LLM Top 10
LLM08: Vector and Embedding Weaknesses.
gpt-oss:20b inversion was never demonstrated live due to hardware
constraints; the validated run substituted llama3.2:1b and did not
converge. Records that gap explicitly instead of leaving it implicit,
and adds the missing lock file for reproducibility (present in
example/ and system_reconnaissance/ but missing here despite the
Makefile's sync/lock targets).
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