1---2name: vulnerability-analysis3description: Use when auditing source code for vulnerabilities — drive CodeQL/Semgrep/Joern to taint untrusted data source-to-sink across injection, memory safety, deserialization/prototype-pollution, secrets/crypto/authz/race, and supply-chain risks4metadata:5 source: https://skillmd.com/skills/hypnguyen1209/vulnerability-analysis6 type: offensive7 phase: analysis8 tools: codeql, semgrep, joern, opengrep, trufflehog, gitleaks, kingfisher, osv-scanner, syft, grype, trivy, npm-audit, pip-audit, ysoserial, phpggc9 mitre: [T1190, T1059, T1552.001, T1195.001, T1213]10kill_chain:11 phase: [recon, exploit]12 step: [1, 4]13 attck_tactics: [TA0043, TA0002, TA0001]14 attck_techniques: [T1190, T1059, T1552.001, T1195.001, T1195.002]15depends_on: [recon-osint]16feeds_into: [exploit-development, web-pentest]17inputs: [attack_surface_map, source_code]18outputs: [vulnerability_list, taint_analysis_report, finding_record, sbom]19references:20 - references/taint-engines-static-analysis.md21 - references/injection-source-patterns.md22 - references/memory-safety-c-cpp.md23 - references/deserialization-prototype-pollution.md24 - references/secrets-crypto-authz-concurrency.md25 - references/supply-chain-dependency-audit.md26 - references/variant-hunting.md27scripts:28 - scripts/taint_trace.py29 - scripts/sast_runner.py30 - scripts/joern_taint.sc31 - scripts/deser_gadget_scan.py32 - scripts/secret_crypto_audit.py33 - scripts/dep_audit.py34 - scripts/validate_findings.py35 - scripts/evidence_kit.py36 - scripts/variant_hunt.py37 - scripts/path_conditions.py38 - scripts/merge_runtime_evidence.py39---4041# Vulnerability Analysis4243Every vulnerability you miss is one an attacker finds first. Systematic source44auditing traces untrusted data from **source** to **sink**, evaluates every45sanitizer for bypass, and questions each trust-boundary assumption. This skill is46the router; depth lives in `references/`, and every technique cluster is backed47by a runnable tool in `scripts/`.4849## When to Activate5051- Auditing any codebase (white/grey box) for security vulnerabilities52- Writing/driving CodeQL queries, Semgrep taint rules, or Joern CPGQL flows53- Tracing injection, deserialization, prototype-pollution, or memory-safety paths54- Reviewing auth/authorization (IDOR/BOLA), cryptography, or concurrency (TOCTOU)55- Triaging dependency CVEs and hunting malicious/compromised packages (SCA)56- Variant hunting — generalizing one finding into a codebase-wide pattern5758## Technique Map5960| Technique | ATT&CK | CWE | Reference | Script |61|-----------|--------|-----|-----------|--------|62| Taint analysis (source/sink/sanitizer modeling) | T1190 | CWE-20 | references/taint-engines-static-analysis.md | scripts/taint_trace.py |63| CodeQL/Semgrep/Joern engine orchestration + merge | T1190 | CWE-20 | references/taint-engines-static-analysis.md | scripts/sast_runner.py, scripts/joern_taint.sc |64| SQL injection (raw/ORM/identifier/2nd-order/NoSQL) | T1190 | CWE-89 | references/injection-source-patterns.md | scripts/taint_trace.py |65| OS command / argument injection | T1059 | CWE-78 / CWE-88 | references/injection-source-patterns.md | scripts/taint_trace.py |66| Server-side template injection | T1190 | CWE-1336 | references/injection-source-patterns.md | scripts/taint_trace.py |67| Path traversal | T1083 | CWE-22 | references/injection-source-patterns.md | scripts/taint_trace.py |68| SSRF (tainted server-side URL) | T1190 | CWE-918 | references/injection-source-patterns.md | scripts/taint_trace.py |69| Integer overflow -> heap/stack overflow | T1203 | CWE-190 / CWE-787 | references/memory-safety-c-cpp.md | scripts/joern_taint.sc |70| Use-after-free / double-free | T1203 | CWE-416 / CWE-415 | references/memory-safety-c-cpp.md | scripts/joern_taint.sc |71| Unbounded copy / NULL deref | T1203 | CWE-120 / CWE-476 | references/memory-safety-c-cpp.md | scripts/joern_taint.sc |72| Insecure deserialization + gadget preconditions | T1059 | CWE-502 | references/deserialization-prototype-pollution.md | scripts/deser_gadget_scan.py |73| Prototype pollution -> gadget -> RCE | T1059.007 | CWE-1321 | references/deserialization-prototype-pollution.md | scripts/deser_gadget_scan.py |74| Hardcoded secrets / high-entropy literals | T1552.001 | CWE-798 / CWE-321 | references/secrets-crypto-authz-concurrency.md | scripts/secret_crypto_audit.py |75| Weak / misused cryptography | T1600 | CWE-327 / CWE-328 / CWE-330 / CWE-347 | references/secrets-crypto-authz-concurrency.md | scripts/secret_crypto_audit.py |76| Broken authorization / IDOR / BOLA | T1190 | CWE-639 / CWE-862 | references/secrets-crypto-authz-concurrency.md | scripts/secret_crypto_audit.py |77| TOCTOU / race condition | T1190 | CWE-367 / CWE-362 | references/secrets-crypto-authz-concurrency.md | scripts/secret_crypto_audit.py |78| Known-CVE dependency (SCA) | T1195.001 | CWE-1395 / CWE-1104 | references/supply-chain-dependency-audit.md | scripts/dep_audit.py |79| Malicious package / install worm / typosquat | T1195.002 | CWE-506 / CWE-829 / CWE-1357 | references/supply-chain-dependency-audit.md | scripts/dep_audit.py |80| Variant hunting — one finding -> all siblings, root-cause clustered | T1190 | CWE-20 | references/variant-hunting.md | scripts/variant_hunt.py |81| Path feasibility — branch guards -> tri-state SAT/UNSAT (Z3 optional) | T1190 | CWE-20 | references/taint-engines-static-analysis.md | scripts/path_conditions.py |82| Evidence grounding + FP gate (structured proof, EVD citations) | T1190 | CWE-20 | references/finding-validation-runtime.md | scripts/validate_findings.py, scripts/evidence_kit.py |83| Runtime reachability confirmation (Frida sink-executed) | T1190 | CWE-20 | references/dynamic-instrumentation.md | scripts/merge_runtime_evidence.py |8485## Quick Start8687```bash88# 0. Intake from recon-osint: languages, frameworks, trust boundaries, entry points.8990# 1. Fast triage — rank files by unsanitized source->sink flows (heuristic, multi-lang)91python3 scripts/taint_trace.py trace ./src --lang py,js,php,java --json triage.json92python3 scripts/taint_trace.py config --lang py > seed.semgrep.yml # seed a real rule9394# 2. Deep interprocedural — drive the real engines, then merge into one ranked list95python3 scripts/sast_runner.py semgrep --src ./src --config p/owasp-top-ten --pro --out sg.sarif96python3 scripts/sast_runner.py codeql --src ./src --lang python \97 --suite codeql/python-queries:codeql-suites/python-security-extended.qls --out cq.sarif98python3 scripts/sast_runner.py joern --src ./src --script scripts/joern_taint.sc --out joern.json99python3 scripts/sast_runner.py merge sg.sarif cq.sarif joern.json --out merged.json --top 50100101# 3. Class-specific deep passes102python3 scripts/deser_gadget_scan.py all ./src --json deser.json # deser sinks + gadget libs103python3 scripts/secret_crypto_audit.py all ./src --json sca.json # secrets+crypto+authz+TOCTOU104python3 scripts/dep_audit.py all ./repo --json dep.json # CVE SCA + worm/typosquat105trufflehog filesystem ./src --only-verified # confirm LIVE secrets106107# 4. Exploitability gate (per finding): reachable? controllable? real impact? sanitizer real?108# -> write confirmed issues to templates/exploit/findings/ with109# severity, CWE, CVSS, taint path, PoC, evidence, ATT&CK ID, remediation.110python3 scripts/evidence_kit.py verify --store evidence.json # re-hash every artifact111python3 scripts/validate_findings.py --findings findings.json \112 --evidence ./evidence --evidence-store evidence.json --strict # tier + EVD-citation gate113114# 5. After a CONFIRMED finding: hunt every sibling, then prune false-positive paths115python3 scripts/variant_hunt.py ./src --seed-finding findings.json --lang py,js --json variants.json116python3 scripts/taint_trace.py trace ./src --lang py --json trace.json # trace carries branch guards117python3 scripts/path_conditions.py --trace trace.json --json feasibility.json # Z3 prune (tri-state)118python3 scripts/merge_runtime_evidence.py --events events.jsonl --findings findings.json --out merged.json119```120121## OPSEC & Detection (summary)122123| Technique | Telemetry / IOC | Detection (Sigma/EDR) | OPSEC note |124|-----------|-----------------|------------------------|------------|125| SAST engine runs | `codeql database create`, `semgrep --sarif`, `joern-parse` process trees; large `codeql-db/`/`cpg.bin` | CI process-creation Sigma (informational) | offline & silent; CodeQL `--command` runs target build -> sandbox hostile repos; purge DBs/SARIF on teardown |126| Injection (SQLi/cmdi/SSTI/SSRF) | SQL keywords/`SLEEP`, web svc spawning `sh/curl`, template engine errors, OOB DNS | webserver regex + EDR child-shell Sigma | source review is noiseless; validate with time-based/DNS-OOB, never `--dump` |127| Memory safety (C/C++) | SIGSEGV/SIGABRT, glibc `corrupted`/`double free`, ASan reports | auditd ANOM_ABEND Sigma; EDR RWX/W^X alerts | CPG review silent; fuzz a local copy in a container, purge cores (may hold secrets) |128| Deserialization / proto-pollution | Java `rO0AB`/.NET `AAEAAAD/////` in bodies; JVM->LDAP/RMI; `POST /` w/ `Next-Action` (CVE-2025-55182) | egress Sigma to 389/636/1099/1389; body-marker rules | prove gadget chain exists; `id`/DNS callback not reverse shell; proto-pollution is global -> revert |129| Secrets / crypto / authz / TOCTOU | `AKIA*`/`ghp_*` patterns; `alg:none`; sequential-id 200s; symlink-race auditd | secret-scanning push protection; symlink/PATH auditd | secret *verification* makes a logged provider API call -> only in scope; read one record for IDOR/TOCTOU evidence |130| Supply chain (SCA / worm) | install hook spawning shell/net; `bundle.js`/`setup_bun.js`; new public `Shai-Hulud` repo | install-script process-creation Sigma; agentless SBOM lookup | never `npm install` a suspect tree; `--ignore-scripts` in a disposable container; treat a compromised dep as full host compromise |131132## Deep Dives133134- references/taint-engines-static-analysis.md — taint theory + propagation rules;135 Semgrep (taint mode, Pro interfile, Opengrep), CodeQL modular dataflow API,136 Joern CPG/`reachableBy`; engine orchestration + multi-tool merge; CPG+LLM (2025).137- references/injection-source-patterns.md — source-code shapes of SQLi (incl.138 identifier/ORDER BY/2nd-order/NoSQL), OS command & argument injection, SSTI,139 path traversal, SSRF; per-language safe/vuln pairs; Joern/Semgrep confirmation.140- references/memory-safety-c-cpp.md — integer overflow->overflow, UAF/double-free,141 unbounded copy, NULL deref; the 2025 libxml2 CVE cluster; ASan/UBSan + fuzzing142 confirmation; `unsafe` Rust surface.143- references/deserialization-prototype-pollution.md — CWE-502 sinks + gadget144 preconditions (ysoserial/phpggc/ysoserial.net), JS prototype pollution->RCE;145 React2Shell CVE-2025-55182, Tomcat CVE-2025-24813, lodash CVE-2025-13465, Silent146 Spring.147- references/secrets-crypto-authz-concurrency.md — hardcoded secrets (gitleaks/148 trufflehog/Kingfisher), weak crypto, IDOR/BOLA, TOCTOU/race; LLM-augmented149 secret detection (2025).150- references/supply-chain-dependency-audit.md — OSV/SCA, malicious-package & install151 worm heuristics, typosquats; Shai-Hulud 1.0/2.0/Mini (CVE-2026-45321), the SLSA152 provenance-bypass lesson.153- references/variant-hunting.md — HUNT protocol: one confirmed finding -> tree-wide sibling154 sweep, same-function taint qualification, root-cause clustering (copy-paste/shared-util/155 framework-misuse) to decide one-fix-or-many; backed by `variant_hunt.py`. Pairs with156 `evidence_kit.py` (re-verifiable EVD evidence), `path_conditions.py` (Z3 path-prune, tri-state),157 and `merge_runtime_evidence.py` (Frida runtime sink confirmation).