Exploitation/embedding inversion - #54
Open
Prateek-Pulastya wants to merge 2 commits into
Open
Conversation
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).
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.
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.