Home / Learn Secure SQL / Manual Code Review, Focused on Injection Patterns

Manual Code Review, Focused on Injection Patterns

What a reviewer should specifically look for, beyond what a tool catches.

In shortWhat a reviewer should specifically look for, beyond what a tool catches.

What's actually going on

What a focused reviewer checks, specificallyAny string concatenation/formatting feeding a queryAny dynamic identifier not checked against a fixed allowlistAny previously stored value read back and reused in a later query
What a focused reviewer checks, specifically

The basic idea

Automated tools catch many, but not all, unsafe patterns — a human reviewer specifically looking for injection-related issues should check for string concatenation or formatting feeding into any query, any dynamic identifier not checked against a fixed allowlist, and any place a previously stored value is read back and used in a later query (the second-order pattern covered earlier in this group).

Why this comes up

A reviewer who knows specifically what to look for (rather than a vague "does this look risky?") catches issues a generic review, or even a static analysis tool with imperfect coverage, might miss — this specificity is what makes the consolidated code review checklist from the Case studies group actually effective in practice.

The mechanics

When reviewing a pull request that touches database code, explicitly check each of the three patterns above (concatenation into a query, an unchecked dynamic identifier, a second-order read-and-reuse) as a distinct step, rather than relying on a general impression that the code "looks fine."

Where it is used

  • Web application code review
  • Backend development
  • Database administration
What a reviewer should flag versus approve
- const sql = "SELECT * FROM t WHERE id=" + id;              // flag: concatenation
+ const sql = "SELECT * FROM t WHERE id = ?"; db.execute(sql, [id]); // OK: bound
Specific thing to look forWhy a tool might miss it
String building via unusual helper functionsA static analysis tool tuned for common patterns might not recognize a custom string-building helper
A dynamic identifier allowlist defined far from its use siteRequires tracing code across files, which some tools handle poorly
Second-order read-and-reuse across modulesRequires understanding data flow across the whole codebase, not just one file

Quick check

1. A reviewer focused specifically on injection patterns should check for...