Source Code & CVE Hunting
Bug Bounty · Stage 4 — Level Up · Level: L4 → L5 · Reading time: ~12 min
Black-box hunting guesses at behaviour from the outside. Reading code lets you see the behaviour directly — which finds deeper, less-duplicated bugs. This is how many top hunters find criticals: when the target runs open-source software, or when source leaks, the bug is often sitting there in plain text.
When You Have Source
You have source more often than you'd think:
- The target runs open-source software (a CMS, framework, library, self-hostable app).
- Source maps reconstruct front-end code (see JavaScript Analysis).
- Code leaked on GitHub, in
.gitdirectories, or in exposed archives. - The company publishes repositories, SDKs or sample code.
Reading leaked code to understand an in-scope target is one thing; redistributing it or using it beyond the program's scope is another. Follow the program's policy, and report exposed source as a finding in its own right where appropriate.
How to Read Code for Bugs
You don't read top to bottom. You follow untrusted input to dangerous sinks.
Sources (user input) Sinks (dangerous operations)
───────────────────── ──────────────────────────────
request params/body/headers → SQL queries (string-built)
cookies, tokens shell/exec calls
uploaded files file path operations
webhook/third-party data template rendering
deserialization
HTML output (XSS)
URL fetching (SSRF)
auth/authz checks (missing?)
Practical workflow
- Map entry points: routes/controllers, API handlers, GraphQL resolvers, webhook receivers, message consumers.
- Grep for sinks and work backwards to see if user input reaches them unsafely:
# Examples — adapt per language/framework
grep -rnE "exec\(|execSync|child_process|os\.system|subprocess|Runtime\.getRuntime" .
grep -rnE "query\(|execute\(|raw\(|rawQuery|createQuery" . # SQL
grep -rnE "innerHTML|dangerouslySetInnerHTML|v-html|render_template_string" .
grep -rnE "pickle\.loads|yaml\.load\(|unserialize|ObjectInputStream|BinaryFormatter" .
grep -rnE "requests\.get\(|fetch\(|HttpClient|urlopen|axios" . # SSRF candidates
grep -rniE "verify=False|rejectUnauthorized|InsecureSkipVerify" . # TLS
grep -rniE "secret|api[_-]?key|password|token" . # hardcoded secrets
- Check authorization at every handler: is there an ownership/role check, or does it trust the request? Missing checks are the most common serious finding.
- Follow the data flow from each source to each sink; note where validation is absent or wrong.
- Read the diffs/commits: recent changes,
TODO/FIXME/HACKcomments, and "fix security" commits point at weak spots.
Start with a self-hostable app you can also run. Read a feature's code, form a hypothesis ("this endpoint never checks ownership"), then confirm it live against your own instance. Linking code to behaviour is the fastest way to learn white-box hunting.
SAST — Helpful, Not Magic
Static analysis tools flag candidate issues to review:
| Tool | For |
|---|---|
| Semgrep | Multi-language pattern rules; great custom-rule support |
| CodeQL | Deep data-flow queries (source→sink) |
| Bandit / Brakeman / gosec | Python / Ruby on Rails / Go |
| npm audit / pip-audit / Dependency-Check | Vulnerable dependencies |
Treat results as leads. Every real finding still needs you to confirm the data flow and the impact.
1-Day Hunting & Patch-Diffing
When a vulnerability is disclosed in widely used software, there's a window before everyone patches. 1-day hunting means:
- A CVE/advisory drops for a product you've seen in recon.
- Find in-scope instances running the affected version.
- Confirm the vulnerability safely (detection, not destructive exploitation) and report.
Patch-diffing goes deeper: compare the vulnerable and patched versions to understand the exact bug and build a reliable detection — sometimes discovering the patch was incomplete (a 0-day variant).
Advisory / new release
│ diff patched vs previous
▼
Understand the exact changed check/sink
│
▼
Detect affected in-scope instances ──► confirm safely ──► report fast
Monitor vendor advisories, the CISA KEV catalog, GitHub Security Advisories and this site's CVE Radar. Pair that with your recon inventory (which products/versions appear on which programs) so that when a CVE lands, you already know exactly where to look. Speed is the whole game in 1-day hunting.
From Research to CVE
If you find a new vulnerability in a product (not just a program's instance), you can pursue a CVE through coordinated disclosure:
- Report privately to the vendor/maintainer first; give them time to fix (typical industry windows are around 90 days, flexible by severity and vendor).
- Request a CVE via the vendor's CNA or a CNA of last resort.
- Publish a write-up after the fix/embargo, with details that help defenders.
Never threaten disclosure for payment, never dump details before a fix, and be patient and professional with maintainers — many are volunteers. Responsible research builds the reputation that opens doors (private programs, live events, jobs).
Key Takeaways
- Reading code finds deeper, less-duplicated bugs — follow sources to sinks and check authorization at every handler.
- Use SAST (Semgrep, CodeQL) for leads, then confirm the data flow and impact yourself.
- 1-day hunting and patch-diffing reward speed and a good recon inventory.
- Turn novel findings into CVEs through coordinated disclosure — never through pressure.