Nexus Void Research
Security Code Review, Secure Code Review, Pull Request Review, OWASP, ASVS, Broken Access Control, SAST, How-to
How to Do a Security Code Review: Process and Checklist
How to do a security code review: trace untrusted input, check authorization on every route, use a checklist for injection, secrets and logic flaws.
To do a security code review, start from what the change exposes: list its entry points, follow untrusted input from where it enters to where it is used, and check authentication, authorization, input handling, secrets, dependencies and error handling against a checklist. Let automated tools catch known patterns first, spend human time on business logic and access control, and record every finding with a severity and a concrete fix.
A security code review is a manual or tool-assisted read of source code to find vulnerabilities before they ship. It differs from a normal code review in what you look for: not whether the code works, but how it could be abused. The OWASP Code Review Guide and the OWASP Application Security Verification Standard (ASVS) are the standard references; this guide turns them into a process you can run on every pull request.
When should you do a security code review?
At two levels, because they catch different things:
Review type | When | What it catches |
|---|---|---|
Pull request review | Every change, before merge | New bugs in the lines that changed |
Focused deep review | New features touching auth, payments, file handling or data access; before a major release or audit | Design flaws and bugs that span many files |
Pull request review keeps the backlog from growing. Deep reviews find the logic flaws a diff hides. Most teams need both.
Step 1: Understand the change before reading the code
Read the pull request description, the ticket and any design notes. Answer three questions before opening a single file:
What new entry points does this add? New API routes, webhooks, file uploads, queue consumers, CLI flags.
What data does it touch? User records, payment data, credentials, files, anything regulated.
Who is allowed to use it? Anonymous users, logged-in users, admins, other services.
This is a lightweight threat model. It tells you where to spend your attention.
Step 2: Let tools take the first pass
Run static analysis (SAST), dependency scanning (SCA) and secret scanning before the human review, ideally automatically on the pull request. Tools are good at known patterns: string-built SQL, dangerous functions, hardcoded keys, known-vulnerable package versions. They are weak at intent: they cannot tell whether a user should be allowed to see a record.
Clear or triage the tool findings first, so the human review is not spent rediscovering them.
Step 3: Trace untrusted input from source to sink
The core technique of a security review is following data. Start at every source of untrusted input and follow it to every sink where it is used:
Sources (untrusted) | Sinks (dangerous if input is untrusted) |
|---|---|
Request bodies, query strings, headers, cookies | SQL and NoSQL queries |
File uploads and file names | Shell commands and |
Webhook payloads from third parties | HTML output and templates |
Messages from queues and other services | File system paths |
Data read back from the database that users wrote | Outbound HTTP requests (SSRF) |
LLM output | Deserialization, |
For each path, check that input is validated, parameterised or encoded for the place it ends up. A value that is safe in a SQL parameter can still be dangerous in an HTML template.
Step 4: Check authentication and authorization on every route
Broken access control has topped the OWASP Top 10 for years, and it is the class tools miss most often because it depends on intent. For every new or changed endpoint, check:
Authentication: does the route require a logged-in user, and is that enforced by middleware rather than remembered per handler?
Object-level authorization: when a request names a record by ID, does the code check that this user owns or may access that record? Missing checks here are IDOR (insecure direct object reference) bugs.
Function-level authorization: can a normal user call an admin action by guessing the route?
Tenant isolation: in multi-tenant apps, is every query scoped to the caller's organisation?
Mass assignment: can a user set fields like
role,isAdminorpriceby adding them to the request body?
Step 5: Work through the security checklist
Use a fixed checklist so reviews are consistent across reviewers:
Area | Check |
|---|---|
Injection | Queries parameterised; no user input in shell commands, |
Output encoding | User content escaped for HTML, attributes, JavaScript and URLs |
Secrets | No keys, tokens or passwords in code, config or tests; see how to store API keys securely |
Cryptography | Standard libraries only; no MD5 or SHA-1 for security; secure random for tokens |
Sessions and tokens | Expiry, rotation on login, secure and HttpOnly cookies, JWT signature and algorithm verified |
Error handling | No stack traces or internal details returned to users; failures fail closed |
Logging | Security events logged; no passwords, tokens or personal data in logs |
File handling | Upload type and size validated; paths cannot escape the intended directory |
Outbound requests | User-supplied URLs restricted to allowed hosts to prevent SSRF |
Dependencies | New packages are needed, maintained and not lookalike names; see how to detect malicious npm packages |
Rate limiting | Login, signup, password reset and expensive endpoints are limited |
AI features | Prompts do not mix untrusted input with instructions; tools called by an LLM have least privilege |
Step 6: Look for business logic flaws
Logic flaws are bugs in the rules of your product rather than in the code's syntax: applying a discount twice, skipping a payment step by calling the final endpoint directly, approving your own request, or a race condition that lets two requests spend the same balance. No pattern matcher finds these. Ask "what would a dishonest user try here?" for every state change.
Step 7: Write findings people can act on
A finding is only useful if the author can fix it without a meeting. Each one should include:
Location: file and line.
Severity: use a consistent scale, and consider exploitability, not just impact.
What is wrong and how it could be abused, in one or two sentences.
A concrete fix, ideally as a code suggestion.
Then verify the fix in the follow-up commit. A review that ends at "please fix" leaves half-fixes in production.
Step 8: Make it part of the workflow
Require reviews on protected branches, and require the security checks to pass before merge.
Use CODEOWNERS so changes to sensitive paths, such as auth, billing and crypto code, always get a reviewer who knows them.
Keep pull requests small. Reviewers find far more in a short, focused diff than in a large one.
Track what merged with open findings, so accepted risk is visible rather than forgotten. It is how an AppSec backlog starts.
How does ARGUS review pull requests for security?
ARGUS runs the automated part of this process on every pull request and keeps the record of what merged.
It reviews every pull request when it is opened, updated or reopened, scanning the changed lines with rule-based static analysis and secret detection.
An optional AI security review adds a pass that looks for logic errors, authorization gaps, injection and secrets, the categories in steps 4 to 6 that rules alone miss.
It comments inline on the added lines with the severity, an explanation and a suggested fix, plus a summary comment with a verdict.
It requests changes when a Critical or High finding lands on changed lines, and can post a required status check so the pull request cannot merge until it is resolved. ARGUS never posts an approval; that stays with your reviewers.
AI can only lower noise, never hide serious findings. AI triage can drop a finding only if it is judged a false positive with high confidence and is Medium severity or lower. Critical and High findings are never suppressed by AI.
It keeps an audit record of each pull request, including those merged with unresolved findings.
Limits: pull request review runs on GitHub, covers up to 100 changed files per pull request and skips files over 512 KiB. See ARGUS AI code review, or scan a repository free.
Frequently asked questions
What is a security code review?
A security code review is a read of source code, by people and tools, to find vulnerabilities before the code ships. It focuses on how code could be abused: untrusted input reaching dangerous functions, missing authorization checks, exposed secrets, weak cryptography and business logic flaws, rather than on style or whether features work.
How do you perform a security code review?
Understand what the change exposes, run SAST, dependency and secret scanning first, then trace untrusted input from where it enters to where it is used. Check authentication and authorization on every route, work through a fixed checklist, look for business logic flaws, and write each finding with a location, severity and fix.
What should a security code review checklist include?
Injection and output encoding, authentication and authorization (including object-level checks), secrets, cryptography, session and token handling, error handling and logging, file handling, outbound requests for SSRF, new dependencies, rate limiting, and AI or LLM features. The OWASP ASVS is a good source for a fuller list.
What is the difference between a code review and a security code review?
A normal code review checks correctness, readability and design. A security code review checks how the code could be misused: who can call it, what untrusted data reaches it, and what an attacker gains if it fails. Many teams fold security checks into every pull request review and add deeper reviews for sensitive features.
Can automated tools replace manual security code review?
No. Static analysis, dependency scanning and secret scanning reliably catch known patterns and should run on every pull request. They are weak at intent, such as whether a user should see a record, and at business logic. Use tools for the first pass and human review for access control and logic.
How long should a security code review take?
It depends on the size and risk of the change. Small, focused pull requests can be reviewed in minutes once tools have run. Changes to authentication, payments or data access deserve a focused session. Keeping pull requests small is the most effective way to keep reviews fast and thorough.
What are the most common vulnerabilities found in code review?
Broken access control, including missing object-level checks (IDOR), injection such as SQL and command injection, cross-site scripting, hardcoded secrets, server-side request forgery, insecure deserialization, and weak error handling that leaks internal details. Business logic flaws are also common in payment and approval flows.
Who should do security code reviews?
Every developer reviewing pull requests should apply a basic security checklist. Changes to sensitive areas, such as authentication, billing, cryptography and data access, should also get a reviewer with security experience, enforced with CODEOWNERS. Automated review on every pull request covers the patterns humans tend to miss under time pressure.
DATA SOURCES
OWASP Code Review Guide: https://owasp.org/www-project-code-review-guide/ ; OWASP ASVS: https://owasp.org/www-project-application-security-verification-standard/ ; OWASP Top 10: https://owasp.org/Top10/