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.
What's actually going on
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
- 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 for | Why a tool might miss it |
|---|---|
| String building via unusual helper functions | A static analysis tool tuned for common patterns might not recognize a custom string-building helper |
| A dynamic identifier allowlist defined far from its use site | Requires tracing code across files, which some tools handle poorly |
| Second-order read-and-reuse across modules | Requires understanding data flow across the whole codebase, not just one file |
Quick check
1. A reviewer focused specifically on injection patterns should check for...
Specific, distinct checks catch what a general impression or imperfect tool coverage might miss.