hypnguyen1209/offensive-claude / skills/vulnerability-analysis
vulnerability-analysis
UnverifiedUse 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 risks
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 11.4 KB |
| references/deserialization-prototype-pollution.md | markdown | 8.3 KB |
| references/injection-source-patterns.md | markdown | 8.6 KB |
| references/memory-safety-c-cpp.md | markdown | 7.7 KB |
| references/secrets-crypto-authz-concurrency.md | markdown | 8.6 KB |
| references/supply-chain-dependency-audit.md | markdown | 7.3 KB |
| references/taint-engines-static-analysis.md | markdown | 11.0 KB |
| references/variant-hunting.md | markdown | 3.4 KB |
| scripts/dep_audit.py | script | 10.9 KB |
| scripts/deser_gadget_scan.py | script | 7.7 KB |
| scripts/evidence_kit.py | script | 13.0 KB |
| scripts/finding_dedup.py | script | 4.2 KB |
| scripts/joern_taint.sc | other | 3.6 KB |
| scripts/merge_runtime_evidence.py | script | 6.1 KB |
| scripts/path_conditions.py | script | 10.6 KB |
| scripts/provenance.py | script | 2.8 KB |
| scripts/sast_runner.py | script | 7.8 KB |
| scripts/secret_crypto_audit.py | script | 8.1 KB |
| scripts/taint_trace.py | script | 14.9 KB |
| scripts/validate_findings.py | script | 22.8 KB |
| scripts/variant_hunt.py | script | 11.8 KB |
| scripts/vocab_gate.py | script | 7.5 KB |
references/secrets-crypto-authz-concurrency.md
View on GitHub# Secrets, Crypto, Authorization & Concurrency Audit
Cluster: the "non-injection" findings that fill most real reports — hardcoded
secrets (CWE-798), weak/misused cryptography (CWE-327/328/326/329/330/347),
broken authorization / IDOR (CWE-862/639/285), and TOCTOU/race conditions
(CWE-367/362). Backing tool: `scripts/secret_crypto_audit.py` (plus gitleaks/
trufflehog for live-credential verification).
## 1. Hardcoded Secrets (CWE-798 / CWE-321)
### Mechanism
A credential committed to source persists in git history even after deletion, so
any reader of the repo (or its mirrors/forks) holds the key. Detection combines
**provider regex** (precise) with **Shannon entropy** (catches unknown formats),
then ideally **live verification** (is the key still valid?).
### Audit
```bash
# Fast offline regex + entropy pass, CWE-tagged for the report:
python3 scripts/secret_crypto_audit.py secrets ./src --entropy 4.0 --json secrets.json
# Verify which are LIVE (TruffleHog) and the blast radius:
trufflehog filesystem ./src --only-verified --json
trufflehog git file://. --since-commit HEAD~1000 --only-verified
# Fast CI gate, broad coverage, SARIF for GH Advanced Security:
gitleaks detect --source . --report-format sarif --report-path leaks.sarif
```
Tool division of labor (overlap between tools is low — run ≥2): **gitleaks** =
fast, offline, regex+entropy, CI/commit gate (SARIF, composite rules since
v8.28). **TruffleHog** = verification-first (>800 types, live login to confirm
validity), incident response & history sweeps; clones local repos to a temp dir
first to defuse malicious git configs (CVE-2025-41390). **Kingfisher** (MongoDB,
Rust, June 2025) = 942 rules / 484 with live validation across 42 providers,
`kingfisher revoke` to kill leaked tokens, Linux-kernel scan in ~205s.
### Remediate (note in finding)
Rotate first (assume used), then check provider audit logs (CloudTrail/GitHub
audit), replace with env var or secrets manager (Vault/Doppler/Infisical), and
**do not** rewrite shared git history. Hardcoded *crypto keys/IVs* are CWE-321.
## 2. Weak / Misused Cryptography
### Audit patterns
```python
hashlib.md5(pw).hexdigest() # CWE-328 broken hash (also for passwords)
Cipher(AES, mode=ECB) # CWE-327 ECB leaks plaintext patterns
AES.new(key, AES.MODE_CBC, iv=b"\x00"*16) # CWE-329 static/zero IV
token = str(random.random()) # CWE-330 non-CSPRNG for security token
jwt.decode(t, verify=False) # CWE-347 signature not verified
requests.get(url, verify=False) # CWE-295 cert validation disabled
# password hashing must be bcrypt/scrypt/argon2 with per-user salt — NOT md5/sha
```
```bash
python3 scripts/secret_crypto_audit.py crypto ./src --json crypto.json
```
High-value classes the scanner flags: MD5/SHA1 for security (CWE-328), DES/RC4/
Blowfish (CWE-327), ECB mode (CWE-327), static/zero IV (CWE-329), `Math.random`/
`rand()`/`mt_rand` for tokens (CWE-330), hardcoded key/salt (CWE-321), disabled
cert validation (CWE-295), `alg:none`/`verify=False` JWT (CWE-347), and
encryption-without-authentication (CBC/NoPadding, CWE-353 → padding oracle /
bit-flip risk; pair with `crypto-analysis` skill for exploitation).
## 3. Broken Authorization / IDOR (CWE-639 / CWE-862 / CWE-285)
### Mechanism
The single most common high-severity web finding: a handler fetches an object by
an attacker-supplied id but never checks that the *current user owns* it (IDOR /
BOLA), or relies on a client-side/role check only. Authentication ≠
authorization.
### Audit heuristic
```python
# VULN — object fetched by id, no ownership check:
@app.get("/invoice/<id>")
def get_invoice(id):
return Invoice.query.get(id).json() # any user reads any invoice
# SAFE:
inv = Invoice.query.get(id)
if inv.owner_id != current_user.id: abort(403)
```
```bash
# Heuristic: handlers that read by id with no ownership/role guard in body:
python3 scripts/secret_crypto_audit.py authz ./src --json authz.json
```
Audit checklist: every sensitive endpoint enforces auth *and* ownership/role;
no security decision made client-side only; mass-assignment guarded (binding the
whole request body to a model lets `role=admin` through → CWE-915); sequential/
guessable ids (or use UUID + still check ownership). Confirm reachability and the
real auth context before reporting — the heuristic over-flags.
## 4. TOCTOU & Race Conditions (CWE-367 / CWE-362)
### Mechanism
The program *checks* a resource's state, then *acts* on it; an attacker mutates
state in the window between (the check-then-act gap). Classic on the filesystem
via symlink swaps against setuid/privileged processes; also financial
double-spend and auth-token races. Reliably winnable — modern CPUs give the
attacker billions of loop iterations per second.
### Audit patterns (Python filesystem TOCTOU)
```python
if os.path.exists(path): # check ...
open(path, "w") # ... use — attacker swaps `path` for a symlink
if os.path.isfile(p): os.remove(p)
if os.access(p, os.W_OK): open(p, "w")
# SAFE — make check+use atomic, or anchor to a descriptor:
fd = os.open(p, os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o600) # atomic create
# or: open() directly and handle the exception, never stat-then-open.
```
Semgrep rule shapes that map to CWE-367 (HIGH): `os.path.exists($P) … open($P)`,
`os.path.isfile($P) … open($P)`, `os.access($P,…) … open($P)`. For app-level
races (double-spend, coupon reuse), the fix is atomic DB ops / SELECT … FOR
UPDATE / idempotency keys, not a recheck. Exploitation/PoC of single-packet web
races lives in `web-pentest`; here you flag the non-atomic check-then-act.
## Modern 2024-2026 Variants
- **Secrets sprawl scale**: ~12.7M new secrets in public commits in a single
recent year; **cryptographic keys are the most-exposed secret type** in source
— prioritize the private-key/`SecretKeySpec` hits.
- **LLM-augmented secret detection** (FuzzingLabs 2025/26): GPT-5-mini hit ~84%
recall vs. gitleaks ~37% by catching *split* secrets (key concatenated across
vars), obfuscated/decoded tokens, and commented-out creds — regex misses
these, so keep a manual pass for concatenated/encoded secrets.
- **Kingfisher** (2025) added one-step `revoke` and cross-provider Access Map
(identity + permission scope behind each live key) — useful to score blast
radius in the finding.
- **TruffleHog CVE-2025-41390** (malicious local git config) → it now clones to a
temp dir before scanning; reflects that even your *audit tooling* is attack
surface on hostile repos.
- TOCTOU stays evergreen because *sequential thinking is natural and concurrent
execution is not* — the check-then-act mental model maps cleanly to code while
silently dropping the security guarantee.
## Detection
```yaml
# Sigma: use of a credential that should never appear in code/logs (e.g. AWS key)
title: Hardcoded AWS Key Pattern in Repo/Log
logsource: { category: file_event }
detection:
sel:
TargetFilename|re: 'AKIA[0-9A-Z]{16}'
condition: sel
level: high
```
- Secrets: GitHub secret-scanning / push protection alerts; provider-side use of
a leaked key from a new ASN/geo (CloudTrail/audit logs).
- Weak crypto: TLS scanners flagging RC4/DES; JWT with `alg:none` accepted.
- IDOR: spikes in 200-responses across sequential object ids from one session.
- TOCTOU: auditd `PATH`/`SYMLINK` events on a privileged process between a stat
and an open of the same inode; symlink creation in world-writable dirs
(`/tmp`) racing a setuid binary.
## OPSEC
- Source/secret scanning is offline and silent. **Verifying** a secret with
TruffleHog makes a *live API call to the provider* — that authentication event
is logged on the provider side; only verify when in scope, and prefer
read-only `get-caller-identity`-style probes.
- Demonstrating IDOR/TOCTOU touches real records/files — read one adjacent
object or create one symlink, capture evidence, and document exactly what was
accessed/created for cleanup. Never bulk-enumerate.
- Treat any secret you find as live and sensitive: store in the engagement vault,
never paste into chat/tickets, and flag for rotation in the report.
## References
- Snyk *State of Secrets* (keys are the most-exposed secret): https://snyk.io/articles/state-of-secrets/
- TruffleHog vs Gitleaks comparison + Kingfisher: https://www.jit.io/resources/appsec-tools/trufflehog-vs-gitleaks-a-detailed-comparison-of-secret-scanning-tools
- CWE-367 TOCTOU (MITRE): https://cwe.mitre.org/data/definitions/367.html
- OWASP Race Conditions: https://owasp.org/www-community/pages/vulnerabilities/race_conditions
- CWE-798 / CWE-327 / CWE-330 / CWE-347 / CWE-639 / CWE-362 (MITRE CWE database).
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |