Secure code review

Reading a diff for auth bugs, injection sinks, and secret leaks; using SAST as a first pass, not a verdict. Live code-review rounds are common in India appsec loops.

About 27 min read3-question knowledge check

The mental model

Secure code review is reading a diff the way an attacker reads it — not asking "does this work?" but "what happens if the input is hostile, the user is malicious, and every assumption is false?" A functional reviewer traces the happy path. A security reviewer traces the abuse path: the request that arrives without the token, the ID that belongs to someone else, the field the client was never supposed to set.

The analogy that sticks: a functional reviewer is a building inspector checking that the doors open and the lights work. A security reviewer is a locksmith walking the same building asking "which of these locks can I pick, which window is unlatched, and where does the fire exit let me in from outside?" Same building, entirely different attention. The locksmith is not smarter — they are looking for a different property: what is reachable by someone who should not reach it.

Why this is a distinct, hireable skill and a common live interview round (especially in Indian appsec loops): most bugs that cause breaches are invisible to functional review because they are *absences* — a missing authorization check, an unvalidated redirect, a secret that should not be in the diff. There is nothing broken to notice; the code does exactly what it says, and what it says is dangerous. The reviewer's job is to see the check that *is not there*. That is why the core mental discipline is "trace untrusted input to a sink, and trace every object access to its authorization check" — you are hunting for gaps, not for wrong code.

The other half of the model: SAST is a first pass, not a verdict. A static analysis tool is a fast, tireless junior who flags every suspicious shape and cannot tell reachable from unreachable or exploitable from benign. You use its output as a candidate list to triage, never as the answer. The senior signal is reconciling tool output with a manual read and defending which findings are false positives.

The full lesson continues with 15 more sections
  • Deep dive
  • Internal architecture
  • Real-world use cases
  • Best practices
  • Common mistakes
  • Performance
  • Security
  • Production troubleshooting
  • Advantages & disadvantages
  • Alternatives
  • Interview expectations
  • Interview questions
  • Facts to remember
  • Cheat sheet
  • Quick revision