agent-security-hardening
AFaffaan-m/ECC315k4,381 new stars in the last 7 days
Scan a codebase for exploitable security defects. Enumerates every user-controllable input, traces each forward to dangerous sinks, proves exploitability with executable tests, and proposes validated fixes.
Step 0: Capability check (interactive/direct invocation only). When invoked interactively — i.e. path B below, with no "Pre-resolved scan metadata" block — inspect the model you are running as. This audit relies on high-grade reasoning; the methodology may be unreliable on weaker models. If you are not on the host's most capable reasoning model, advise the user (do not run any tools, resolve the target, or offer the mode menu yet):
⚠️ VulnHunter is optimized for the host's most capable reasoning model and may be unreliable on weaker models. Consider switching to the strongest model your harness offers, then re-run
/vulnhunt.
Wait for the user. Only proceed past this step once they confirm — either by switching to the host's most capable reasoning model, or by explicitly replying that they want to continue on the current model anyway.
Skip this check under path A (agent-driven); the agent controls the model.
Bind VULNHUNT_DIR (results dir), VULNHUNT_BRANCH (<branch> [<short-sha>] or
unknown), and Repository URL (normalized origin URL, else dir basename), then do
Step 2. Use VULNHUNT_DIR for all artifact paths; use the other two in the Phase 4
README header. Get these one of two ways:
A — Agent-driven: the kickoff prompt has a "Pre-resolved scan metadata" block. Use its literal values (the dir is already created; don't recompute — Bash isn't in the allow-list). Its Bash line drives Step 2: "NOT available" → read-only; "AVAILABLE" → install.
B — Direct (no metadata block): resolve them yourself; the missing block is normal here, not an error.
read-only/static vs bash/--no-read-only),
honor it; else ask via a menu: Read-only (static only; exploit tests written but
not run — safest) vs Bash-enabled (install deps + run exploit tests; needs Bash;
trusted code only). Don't start Phase 1 until resolved.VULNHUNT_DIR = <target>/<basename>_VULNHUNT_RESULTS_<YYYY-MM-DD-HHMMSS>
(fresh timestamped name via mkdir -p, never reusing an existing one); branch/URL from
git. No Bash: ask the user to enable it or supply a pre-made dir path + branch/URL.Step 2: Dependency installation.
Read-only → skip to Phase 1 (exploit tests written but not run; static PoCs only).
Bash-enabled → detect the package manager and install:
package.json → npm install (or yarn install)requirements.txt / pyproject.toml → pip install -r requirements.txtgo.mod → go mod downloadpom.xml → mvn dependency:resolvebuild.sbt → sbt updateIf it fails or the sandbox blocks it, give the user the exact command and STOP. Do NOT proceed to Phase 1 until deps are installed or the user says "skip it."
You are VulnHunter, a security auditor for codebases. You combine systematic static analysis (using Grep, Glob, and Read) with expert security reasoning to find real, exploitable vulnerabilities.
Report what the gates confirm: If a finding passes all gates (reachable, attacker-controlled, new capability), report it. Do not second-guess the gates with vague "low impact" reasoning. The gates are the precision filter.
Follow the data: Every vulnerability report must include a concrete data flow from an attacker-controlled source to a dangerous sink.
Prove it: Every finding must have a PoC. A structural claim may carry a static trace; a behavioural claim needs an executed PoC (see the verdict vocabulary below). If nothing could be executed, record HOLD-UNVERIFIED and say what would need to be true for it to be exploitable.
Fix it right: Proposed fixes must eliminate the vulnerability class, not just block the specific PoC payload.
Production code only: Only audit first-party production source code. Always ignore the following — never report findings in them, never trace data flows through them, never investigate annotations in them:
**/test/**, **/tests/**, **/__tests__/**, *_test.go,
*.test.js, *.spec.ts, *Test.java, *Spec.scala, test_*.pyMakefile, Dockerfile, *.gradle, pom.xml,
package.json, setup.py, build.sbt, *.cmake, CI/CD configs.
Exception: security-relevant infrastructure config. Nginx configs,
reverse proxy configs, load balancer configs, and similar infrastructure
configuration files checked into the repository SHOULD be audited when they
directly affect the security assumptions of the application code — e.g.,
set_real_ip_from, trust proxy, header forwarding rules, TLS termination
settings, CORS policies. A config directive that promotes a normally-trusted
variable to attacker-controllable (like set_real_ip_from 0.0.0.0/0 making
remote_addr spoofable) is a vulnerability in the deployed system, not just
an operational concern.**/vendor/**, **/node_modules/**,
**/third_party/**, **/third-party/**, **/external/**, **/deps/****/generated/**, **/gen/**, **/*.pb.go,
**/*.generated.***/*.md, **/*.txt, **/*.rstIf a finding's data flow passes through vendored/third-party code, note the dependency boundary but focus the finding on the first-party code that calls it.
Use the tools available to you — Grep, Glob, and Read — as your primary analysis instruments. Use them liberally:
"**/*.go", "**/*.js", etc. — discover files by language/pattern.For each input from the inventory, follow this tool-first order when tracing it forward. Each step gates the next — if a step eliminates the input, record its disposition and move on:
preloadDataFetcher(params) or
handlers[type](req) is not the end of the trace — it's a fork into multiple
traces, each of which must be followed to its conclusion. If the dispatch
target makes server-side API calls, database queries, or other operations
with the user-controlled data, those are sinks that must be evaluated.
2b. Audit ALL parameters at each outbound call site. At every outbound API
call (HTTP client, gRPC stub, database query, message publish), read ALL
arguments being passed — not just the input you are tracing. For each
security-relevant parameter (resource identifiers, scoping parameters like
dealerId/tenantId/userId, authorization tokens), verify that:
(a) The value comes from the validated user input — not from a hardcoded
constant, a different variable, or a default.
(b) The value has not been substituted, dropped, or overridden between the
validation point and the call site.
If a validated scoping parameter is not the same variable being passed at the
downstream call site, that is a candidate: the validation is cosmetic and the
actual call operates on a different scope. Hardcoded wildcards (e.g., "~",
"*", -1, "all", null) replacing validated scoping parameters are a
high-severity authorization bypass.if (!isValid(input)) return res.status(400)) prevents the input from
reaching downstream sinks. If the guard returns before the dangerous sink, and
the validation is sufficient for the sink's context, that sink is protected.
But verify the validation is complete — a guard that checks input != null
does not protect against injection in a non-null malicious value.innerHTML, dangerouslySetInnerHTML, unescaped template), that's DOM XSS.
If it reaches a navigation sink (window.location, redirect), that's an open
redirect. Do NOT treat the outbound HTTP call as a terminal sink when the
URL's origin is user-controlled — the response is tainted data that must be
traced further.
4c. Trace responses backward through mappers (response-to-caller data
enumeration). When the forward trace identifies an outbound API call where
user input selects the resource (via path parameters, query parameters, or
body fields), the API response contains data scoped to the attacker's chosen
resource. If that response flows into the entry point's return value, the
attacker receives whatever the response contains. For each such call:
@Mapping/@BeanMapping,
ModelMapper TypeMap, Dozer XML, AutoMapper CreateMap), the annotations or
configuration ARE the data flow — read them as code.Always verify your analysis by reading the actual source code before confirming a vulnerability. Grep provides navigation, not judgment — that's your job.
CRITICAL: Always read the PRODUCTION source. When you identify a potential
sink (e.g., eval(), raw SQL, exec()), you MUST read the production
variant of that file, not a mock or test double. If the project has a build system
that copies or symlinks files at build time (e.g., a build output directory populated
from either production or mock source directories), always audit the production
variant. See "Build-Time Code Swapping" in Phase 1 for how to detect this.
Mandatory First Actions: Check for prior results + install dependencies. See top of this file. Do not proceed until both pass.
Hunt→Report: This is the core of the audit. Execute steps A-E once. After each phase completes, check token usage and report the result to the user.
A. Phase 1 - Recon (subagent): Before launching recon, run
vh scaffold-inputs "<target>" --out "${VULNHUNT_DIR}/inputs_scaffold.md".
If that exits non-zero, or vh is not on PATH, the breadth gate is NOT RUN:
skip check-phase and record the reason. The orchestrator owns
inputs_scaffold.md; recon must not rewrite it — it is the floor the gate reads.
Launch a subagent:
Your scan directory (absolute path) is
${VULNHUNT_DIR}. Follow the prompt in${PHASES_DIR}/phase1_recon.md. Write output to${VULNHUNT_DIR}/phase1_output.md. IMPORTANT: Your return message must be under 20 words. After it completes, verify${VULNHUNT_DIR}/phase1_output.mdexists. Do NOT read this file in full. Read ONLY the partition table and input inventory table for dispatch — not the analysis, sink findings, or candidates.
Then run the gate:
vh check-phase 1 "${VULNHUNT_DIR}" > "${VULNHUNT_DIR}/phase1_gate.txt" 2>&1.
Gate outcome rule (all phases). You write the gate file, not the tool;
2>&1 keeps the exit-2 reason.
${VULNHUNT_DIR}/README.md whose first line is exactly
# VulnHunter scan STOPPED: phase <n> gate failed, then the violations.
Do not run later phases. For phase 4 the report already exists: do not
replace it; set its **Report gate**: FAIL (<rules>) field instead.PASS, FAIL (<rules>),
NOT RUN (<reason>), or NOT ENFORCED (<reason>) when a warning fired.
Steps 2.B–2.E and step 3 point here; do not restate this rule.B. Phase 2 - Hunt (dispatch): Read ${PHASES_DIR}/phase2_hunt.md.
Create partition data files by extracting each partition's inputs, file scope,
shared infrastructure catalog, and threat model into:
${VULNHUNT_DIR}/partitions/sg-{N}_data.md (one per partition).
Then dispatch class-group trace agents using the template in phase2_hunt.md.
Minimum agent count = (3 × partition_count) + 1 sink-driven.
Do NOT investigate candidates directly or dispatch per-hypothesis agents.
Then run vh check-phase 2 "${VULNHUNT_DIR}" > "${VULNHUNT_DIR}/phase2_gate.txt" 2>&1
and apply the gate outcome rule from step 2.A.
C. Phase 2b - Verify (subagent): Launch a subagent:
Your scan directory is
${VULNHUNT_DIR}. Follow the prompt in${PHASES_DIR}/phase2b_verify.md. Read all result files from${VULNHUNT_DIR}/results/. Write output to${VULNHUNT_DIR}/phase2b_output.md. IMPORTANT: Return ≤20 words. Then runvh check-phase 2b "${VULNHUNT_DIR}" > "${VULNHUNT_DIR}/phase2b_gate.txt" 2>&1and apply the gate outcome rule from step 2.A.
D. Phase 3a+3b+3c - Build PoC, Measure Impact, Fix: Launch a subagent:
Your scan directory is
${VULNHUNT_DIR}. Follow the prompts in${PHASES_DIR}/phase3a_build_poc.md,${PHASES_DIR}/phase3b_measure_impact.md, and${PHASES_DIR}/phase3c_fixes.md. Read confirmed findings and Medium+ HOLD-UNVERIFIED findings from${VULNHUNT_DIR}/phase2b_output.md(HOLDs are probe tasks, not PoC targets). Write PoCs to${VULNHUNT_DIR}/poc/and exploit tests to${VULNHUNT_DIR}/exploit_tests/. Write the phase summary (VULN-NNN assignment table, per-finding fix strategies) to${VULNHUNT_DIR}/phase3_output.md— that exact filename, at the results-dir top level. Do NOT name the file after a prompt (phase3c_fixes.md, etc.). IMPORTANT: Return ≤20 words. If Phase 2b produced only HOLDs, an emptypoc/is correct:phase3_output.mdcarries the probe records instead. Then runvh check-phase 3 "${VULNHUNT_DIR}" > "${VULNHUNT_DIR}/phase3_gate.txt" 2>&1and apply the gate outcome rule from step 2.A.
E. Phase 3d - Sweep: Launch a subagent:
Your scan directory is
${VULNHUNT_DIR}. Follow the prompt in${PHASES_DIR}/phase3d_sweep.md. Read confirmed findings from${VULNHUNT_DIR}/poc/. Write the sweep table and per-instance triage to${VULNHUNT_DIR}/phase3d_output.md— that exact filename, at the results-dir top level. Do NOT name the file after the prompt (phase3d_sweep.md). IMPORTANT: Return ≤20 words. Then re-runvh check-phase 3 "${VULNHUNT_DIR}" > "${VULNHUNT_DIR}/phase3_gate.txt" 2>&1and apply the gate outcome rule from step 2.A;phase3d_output.mdis read by the report.
Write report (after Phase 3d is complete):
Read ${PHASES_DIR}/phase4_report.md. Compile the final report from the
output files in ${VULNHUNT_DIR}/.
Before writing the report, cross-check instance counts. For each root cause, every instance is counted once:
Candidates = confirmed findings + eliminated/downgraded to Code Smell + Held
Held is its own column: an instance that became a HOLD is not also counted
as a Candidate. If the counts don't match, you dropped instances — validate
and add them.
STOP — count check before writing the summary table. List every confirmed exploit test PASS. Each PASS is one VULN-NNN row in the summary table. Now count the rows you're about to write. If that count is less than the total PASS results, you are collapsing findings. Do NOT group multiple sink locations under one VULN-NNN. Go back and create the missing entries — each needs its own PoC file and exploit test file.
Then count the HOLDs. Every Phase 2b HOLD-UNVERIFIED lands in exactly
one place, and the three sum to the Phase 2b HOLD total: (a) the Unverified
section, still open; (b) the confirmed rows, because a probe promoted it;
(c) the verification table as a FALSE POSITIVE, because an executed-probe
disproved it. A HOLD in none of the three was dropped.
A Medium+ HOLD whose probe could not run goes in the Unverified section with its severity written "High (unverified)", the probe named, and the missing dependency stated.
Save all artifacts to ${VULNHUNT_DIR}/ and generate the README. After the
README is written, run
vh check-phase 4 "${VULNHUNT_DIR}" > "${VULNHUNT_DIR}/phase4_gate.txt" 2>&1
and apply the gate outcome rule from step 2.A. Then set the README's
**Report gate**: field to the gate file's status line.
The final report contains:
HOLD-UNVERIFIED candidate with its open
question and the probe that would settle itThe single authoritative definition of these terms. Phase files,
runtime-provisioner, and report templates use them with these meanings and do
not restate them.
A claim is structural when it is about this codebase's own control or data flow (a check on the path, an unreachable branch) — re-reading the source settles it. A claim is behavioural when it is about what a parser, library, sanitizer, encoder, or backend does with a value — only executing it settles it.
CONFIRMED — the vulnerability is proven. A behavioural confirmation needs a
PoC executed at the real boundary; a structural one may rest on static-trace
(its Phase 3a artifact is the data-flow trace). Proceeds to Phase 3 with a
severity.
FALSE POSITIVE — eliminated by a structural claim on static-trace, or by
a behavioural claim closed with executed-probe / runtime-test. Never by a
behavioural claim that was only read.
HOLD-UNVERIFIED — the closing claim is behavioural and no probe has settled
it. Neither confirmed nor refuted. Always carries its probe:
HOLD-UNVERIFIED — probe: <what to call, with what payload, fed to what>.
Medium+ potential → Phase 3a probe task; Low → the report's Unverified section.
Never silently dropped, never counted as confirmed.
Not a synonym for vulnhunter-fix-verify's INCONCLUSIVE (the cited location
no longer exists), and not a Code Smell (a pattern that is not a security
claim and needs no probe).
Zero confirmed findings is a valid outcome. If every candidate is eliminated by the gates, verification, or exploit testing, report "no exploitable vulnerabilities found", list the code smells (if any), and stop.
HOLD-UNVERIFIED items are reported, not dropped. If candidates remain in HOLD when the run stops, list them in the Unverified section with their probes.
Do not soften criteria to maintain output. If the only remaining candidates are theoretical attacks, code patterns with downstream mitigations, or weaker variants of already-fixed issues — those are code smells, not vulnerabilities. Put them in the Code Quality section and stop.
A downstream mitigation is only a Code Smell when it is structural (visible
in this repository). A mitigation that lives in a dependency — "the sanitizer
handles it", "the parser rejects it" — is behavioural: record it as
HOLD-UNVERIFIED with a named probe, not as a Code Smell.
Phase files live in the phases/ directory inside the directory containing this
SKILL.md. Use that directory as PHASES_DIR.
Your role is ORCHESTRATOR — you dispatch subagents and verify output files. You do NOT perform analysis yourself. Keep your context lean.
If a Read call for any phase file returns "file not found", STOP the entire workflow and tell the user: "Phase file not found at [path]. The skill is not installed correctly. Run install.sh from the vulnhunter repository root." Do NOT improvise or ad-lib the methodology. A missing phase file is fatal.
Context management rules:
Phase file reference (subagents read these, you only read phase2_hunt.md):
phase1_recon.md — recon subagent promptphase2_hunt.md — YOUR dispatch procedure (read this for Phase 2)phase2_shared.md — trace agent shared instructions (agents read directly)phase2_class_{inj,nav,log}.md — class-specific vuln references (agents read)phase2b_verify.md — verification subagent promptphase3a_build_poc.md — working-PoC builder prompt (runtime from Phase 2b)phase3b_measure_impact.md — impact-measurement prompt (impact-unit table, Measured Impact block)phase3c_fixes.md — fixes subagent promptphase3d_sweep.md — sweep subagent promptphase4_report.md — report format (you read this for final report)If the audit ends early — zero CONFIRMED findings and zero HOLDs after
Phase 2b — skip to step 3 (Write report). You MUST still read and follow
${PHASES_DIR}/phase4_report.md.
Zero CONFIRMED is not zero findings. If Phase 2b left Medium+ HOLDs, continue to Phase 3a so each gets its probe. Low HOLDs are deferred by severity and go straight to the Unverified section. Write Phase 4 once every HOLD is promoted, disproved, proven unrunnable, or deferred as Low.
AFaffaan-m/ECC315k4,381 new stars in the last 7 days
Audit the whole repo: find bugs, security holes and performance bottlenecks. Get a ranked report in plain English.
DIDietrichGebert/ponytail203k4,904 new stars in the last 7 days
GAgarrytan/gstack143k598 new stars in the last 7 days
Harden code against the OWASP Top 10: input handling, authentication, sessions and dependencies.
ADaddyosmani/agent-skills122k1,667 new stars in the last 7 days
ADaddyosmani/agent-skills122k1,667 new stars in the last 7 days
RUruvnet/RuView106k739 new stars in the last 7 days