Courses

Source Code Analysis
OSWE · Chapter 4

Source Code Analysis

Source code analysis (white-box review) finds vulnerabilities by reading the application's own code rather than only probing it from outside. It is slower per-line than automated scanning but finds business-logic and authorization flaws that black-box testing frequently misses entirely.

Key concepts

  • Start from "sources" (anywhere untrusted input enters: request params, headers, file uploads) and trace forward to "sinks" (SQL queries, shell exec, template rendering, deserialization calls).
  • Prioritize authentication and authorization code first — these bugs tend to have the highest impact and are the hardest to find via black-box testing alone.
  • Diffing against a previous known-good version (or the public open-source upstream) quickly surfaces custom, potentially unreviewed modifications.
  • Static analysis tools (Semgrep, CodeQL) scale this process across large codebases, but still require a human to confirm each hit is exploitable.

Try it yourself

Pick an open-source web app on GitHub and grep for a dangerous sink (e.g. `eval(`, `exec(`, raw SQL string concatenation). For one hit, trace backward to see whether the value ever originates from untrusted user input.

@ Daniel Burlacu