references/owasp-secure-code-review.md
GitHubOWASP Secure Code Review
Use this reference to choose review scope, organize evidence, and keep manual review centered on code paths that automated tools often miss.
Review Modes
- Use a baseline review for new applications, major releases, legacy onboarding, compliance work, or post-incident review.
- Use a diff-based review for pull requests, commits, feature delivery, and routine security regression checks.
- Escalate from diff-based to baseline review when a change introduces a new trust boundary, new integration, new privilege path, or evidence of systemic control gaps.
Baseline Sequence
- Map architecture, components, assets, trust boundaries, and deployment assumptions.
- Enumerate entry points and verify server-side validation.
- Verify authentication and authorization at each path.
- Trace untrusted and sensitive data through processing to sinks.
- Model critical business workflows and invariants.
- Review cryptographic implementations and key handling.
- Check fail-closed error handling and security logging.
- Inspect configuration, secrets, runtime privileges, and deployment drift.
Diff-Based Sequence
- Identify the security controls touched by the change.
- Identify new or widened attack paths.
- Verify changed trust-boundary crossings.
- Review new integrations, parsers, stores, and privileged actions.
- Check for regressions in existing auth, validation, and logging behavior.
- Apply the relevant sink-specific references in this directory.
Evidence Pattern
Trace each suspected issue as:
source -> parsing -> validation -> authorization -> transformation -> sink -> impact
Record:
- attacker capability and required state
- exact route, job, function, or parser
- existing controls and bypass conditions
- affected asset or invariant
- test case that proves the issue or proves the control
Pattern Examples
Missing alternate-path review
# Primary route enforces ownership.
@app.get("/invoices/{invoice_id}")
def get_invoice(invoice_id, user):
return invoices.get_for_user(invoice_id, user.id)
# Export path skips the same check.
@app.get("/exports/invoices/{invoice_id}")
def export_invoice(invoice_id, user):
return invoices.get(invoice_id)
Review both routes because a single missed authorization check defeats the protected resource.
Incomplete data-flow tracing
const filename = req.query.name;
const normalized = sanitize(filename);
audit.log(normalized);
return fs.readFileSync(path.join(REPORT_DIR, normalized));
Do not stop at sanitize(). Verify whether the sanitizer is correct for a filesystem path sink, whether canonicalization happens before comparison, and whether the resolved path stays under REPORT_DIR.
Business-logic bypass
if (order.status === "paid") {
ship(order);
}
// Separate admin helper can call ship() without checking payment state.
Trace every path that can reach the state transition, not only the normal workflow.
Review Prompts
- Which assets would matter most if confidentiality, integrity, or availability failed?
- Which trust boundaries were added or changed?
- Which security controls are centralized, and which alternate paths bypass them?
- Which suspicious patterns are only scanner hints, and which are complete exploit paths?
- Which unresolved assumptions should be recorded as coverage gaps rather than findings?
Source
Local summary based on the OWASP Secure Code Review Cheat Sheet:
https://cheatsheetseries.owasp.org/cheatsheets/Secure_Code_Review_Cheat_Sheet.html