Add an LLMSecTest exploitation example against llm_local - #59
Open
wehnsdaefflae wants to merge 1 commit into
Open
Add an LLMSecTest exploitation example against llm_local#59wehnsdaefflae wants to merge 1 commit into
wehnsdaefflae wants to merge 1 commit into
Conversation
LLMSecTest is an MIT-licensed OWASP LLM Top 10 scanner that ships as a pytest plugin and writes SARIF, so findings land in a CI code-scanning tab without conversion. It follows CONTRIBUTING Option B and mirrors the structure of exploitation/garak. Against llm_local the run exercises 8 of 10 categories. --repo adds the white-box LLM03 supply-chain scan over the sandbox's own manifests, which a black-box scanner cannot reach. Two findings about the sandbox itself are documented in the README, both from running it: the mock serves only POST /v1/chat/completions and GET /health, so a --preflight health check through GET /v1/models reports a healthy sandbox as unreachable; and the mock enforces Bearer sk-mock-key, so the key is required even though the backend is local.
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
exploitation/llmsectest/, following CONTRIBUTING Option B (integrate an existing security tool) and mirroring the structure ofexploitation/garak.What it adds
LLMSecTest is an MIT-licensed scanner for the OWASP Top 10 for LLM Applications. It ships as a pytest plugin, so a scan is a test run, a failing security test becomes a CVSS v4.0 scored OWASP finding, and the output is SARIF that a CI code-scanning tab reads without conversion.
Two things make it complementary to the scanners already in
exploitation/:--repoadds a white-box LLM03 supply-chain scan over the sandbox's own dependency manifests. Againstllm_localthe run therefore covers 8 of 10 categories, including one no black-box scanner can reach. The tool prints the map at the end of every scan and names what it did not exercise and why, so a partial run never reads as a full one.Two notes about the sandbox, both found by running it
These are in the README because they would trip up the next person:
llm_localdoes not serveGET /v1/models. It servesPOST /v1/chat/completionsandGET /healthonly, so a--preflighthealth check through the models endpoint reports a perfectly healthy sandbox as unreachable. This example deliberately does not use it.Authorization: Bearer sk-mock-key, so the key is required even though the backend is local.Files
attack.pyOPENAI_BASE_URL/OPENAI_API_KEYand calls the CLI, so the run is reproducible by handconfig/config.tomlMakefilesetup/attack/stop/all, the same target set asexploitation/garakpyproject.tomlllmsectest[openai]Testing
The exact CLI invocation in
attack.pywas run end to end against a local Ollama through the sameOPENAI_BASE_URLpath the sandbox uses: 9 findings across LLM01, LLM05, LLM07 and LLM10, SARIF written, 7 of 10 categories exercised black-box.--repoadds LLM03 on top of that.I have not been able to run it against the containerised sandbox itself yet, since I do not have
gpt-oss:20bpulled locally. The two sandbox notes above come from readingsandboxes/llm_local/app/mocks/openai.pyandapp/main.py. Happy to adjust the model default or anything else you would prefer.Natural next step
Point the same tool at
sandboxes/RAG_localwith--target app:<url> --app-canary <confidential string in a retrieved document>and--app-rag-poison <marker a planted document emits>to cover LLM08 as well. I am glad to send that as a follow-up if it is wanted.