Add modular agent skill with progressive disclosure for token-efficient security reviews#7
Open
SrFlipFlop wants to merge 2 commits intoArcanum-Sec:mainfrom
Open
Add modular agent skill with progressive disclosure for token-efficient security reviews#7SrFlipFlop wants to merge 2 commits intoArcanum-Sec:mainfrom
SrFlipFlop wants to merge 2 commits intoArcanum-Sec:mainfrom
Conversation
Restructure the two monolithic anti-pattern files (~165K tokens combined) into a modular, agent-friendly skill format that achieves 20-100x token cost reduction through progressive disclosure. - Add SKILL.md as the skill entry point and router - Add references/ with 16 modular files (10 breadth + 6 depth) covering all 10 security surfaces and 25+ vulnerability classes - Update README.md with Option 5 documenting the new skill format Original monolithic files are preserved unchanged for backward compatibility. Content in references/ is extracted verbatim from the source files, reorganized by security surface.
Add 5 deliberately vulnerable mockups (Python, JS, TSX, Go, Dockerfile) and their security review results demonstrating the modular skill's routing accuracy, progressive disclosure, and token efficiency. Document findings in README: 53 vulnerabilities found across 5 reviews, 100% pattern match rate, zero false surfaces loaded, along with known gaps for future improvement.
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.
Why?
From the moment I read about the project in an Executive Offense email earlier this year, I thought it was a very interesting idea, even though the context windows were more limited back then. After last week's Attacking AI training, I was working on a similar project at work to see how we could help developers introduce fewer issues into the codebase, and the sec-context project popped into my mind. From the start, I had planned to use only certain parts of the project, but after playing around with it a bit, I thought it might be useful to slightly modify the structure so that agents could automatically use whatever patterns they needed depending on the project.
What?
The monolithic files (
ANTI_PATTERNS_BREADTH.mdat ~65K tokens andANTI_PATTERNS_DEPTH.mdat ~100K tokens) are excellent references, but loading ~165K tokens for every task is expensive when an agent only needs, say, injection patterns for a SQL-heavy file. This PR adds a modular agent skill that restructures the same content into a progressive-disclosure format while keeping the originals untouched.Architecture
10 security surfaces are covered with breadth files (concise patterns):
Secrets, Injection, XSS, Authentication, Cryptography, Input Validation, Config & Deployment, Dependencies, API Security, File Handling.
6 of those also have depth files (the top-priority surfaces from the original DEPTH document):
Secrets, Injection, XSS, Authentication, Cryptography, Input Validation.
All content was extracted verbatim from the source files — reorganized, not rewritten. Each reference file includes a CC BY 4.0 attribution header pointing back to the originals.
Routing
SKILL.mdacts as the router. It contains:SQL,query,execute) to specific reference files, so agents know which surfaces to load.An agent reading
SKILL.mdcan identify the relevant surfaces for any given code file and load only the matching references. Token cost drops from ~165K to ~2-8K per task depending on how many surfaces are relevant.What's changed
SKILL.md(agent skill entry point with router)references/directory with 16 modular files (10 breadth + 6 depth)examples/mockups/with 5 deliberately vulnerable test filesexamples/results/with security reviews produced by the skillREADME.mdwith Option 5 documentation and testing resultsANTI_PATTERNS_BREADTH.mdandANTI_PATTERNS_DEPTH.md(fully backward compatible)Tests
To validate the skill, I created 5 deliberately vulnerable mockup files spanning different languages and security surfaces, then ran each through the modular skill using OpenCode (Claude Sonnet) as the reviewing agent.
The 5 Mockups
01-user-search-api.py02-auth-service.jsMath.random()tokens, timing-vulnerable comparison03-profile-page.tsxdangerouslySetInnerHTML, client-side admin gate, IDOR, open redirect04-file-upload-server.go05-infra-deploy.dockerfileUSER root,curl|bash, typosquattable packages, hardcoded tokensHow they were tested
Each mockup was reviewed with a prompt like: "Using the sec-context skill, perform a security review of examples/mockups/01-user-search-api.py". The agent loaded
SKILL.md, identified relevant surfaces, loaded matching reference files, and produced a structured review.Results
53 total findings across 5 reviews. Zero irrelevant surfaces loaded.
What worked
Known gaps / improvement ideas
USER root,--privileged, unpinned base images, mutable tags.postinstall/lifecycle script pattern — Dependencies breadth covers typosquatting but not npm lifecycle script RCE.