Secure Code Review Checklist for AI-Generated Pull Requests
A practical secure code review checklist mapped to OWASP Top 10:2025, ASVS 5.0, and MITRE CWE, covering authorization, AI-generated PR traps, and automation.


On this page
On this page11 sections
AI coding agents now generate Pull Requests (PRs) that compile cleanly, pass unit tests, and still introduce exploitable security flaws into production. Across Carnegie Mellon University’s SusVibes benchmark and Endor Labs’ Agent Security League leaderboard evaluating 34 commercial agent and model pairings on 200 real-world open-source tasks, top configurations achieve up to 91.6% functional correctness while peaking at 36.9% to 37.4% security correctness, leaving more than 80% of functionally passing patches vulnerable across most tested models.
While hardening AI code assistant system prompts guides developers before a diff exists, a secure code review checklist governs the merge boundary itself. When an engineer or an autonomous coding agent opens a PR, reviewers need short, verifiable checks mapped directly to the Open Worldwide Application Security Project (OWASP) Top 10:2025, OWASP Application Security Verification Standard (ASVS) 5.0, and MITRE Common Weakness Enumeration (CWE) identifiers that can be cited verbatim in review comments.
This practitioner guide provides a diff-scoped secure code review checklist covering 13 technical domains, adds dedicated verification steps for failure modes unique to AI-generated code, separates deterministic checks you should automate from design decisions requiring human judgment, and concludes with an open-source coding-agent skill to run the review directly on your branches.
What to Remember
- Scope Reviews to the Diff: Verify only the security domains touched by the PR and mark untouched sections
N/Aso human review capacity stays focused on real attack surfaces. - Anchor Comments in Current Standards: Cite OWASP Top 10:2025, OWASP ASVS 5.0.0, OWASP API Security Top 10:2023, and MITRE CWE IDs; replace references to the archived OWASP Secure Coding Practices Quick Reference Guide with the active OWASP Developer Guide.
- Prioritize Authorization Above All Else: Broken Access Control (
A01:2025) remains the top web and API risk because regex scanners miss unscoped record lookups; always scope queries to the caller and read tenant identifiers from the authenticated session, never from request parameters. - Audit Agent-Specific Regressions: For AI-generated PRs, verify that every new package actually exists on its public registry and confirm that authentication decorators, TLS verification, and rate limits from earlier commits survived the final diff.
- Use Reachability for Dependency Findings: Before blocking a PR over a dependency Common Vulnerabilities and Exposures (CVE) alert, check whether application code can actually reach the vulnerable function along an execution path.
- Split Automation from Human Judgment: Automate injection dataflow, secret scanning, dependency reachability, cryptographic misuse, and Infrastructure as Code (IaC) checks on every PR, reserving human reviewers for tenant isolation, business logic, and policy exceptions.
1. How to Scope a Secure Code Review Checklist to a Pull Request Diff
A secure coding guide instructs engineers while writing features, whereas a secure code review checklist tests a specific code change right before merge. Applying an exhaustive 80-item audit to every commit causes severe reviewer fatigue. Instead, inspect the changed files first, activate only the sections matching the modified components, and mark every other section N/A.
A frontend typography change requires zero cryptographic review. Conversely, a PR modifying authentication middleware, database queries, API serializers, package.json, or Continuous Integration and Continuous Delivery (CI/CD) workflows triggers every corresponding section below.
Each check in this guide uses a uniform three-part structure designed for fast PR feedback:
- Verification Check: A concrete behaviour or invariant you can confirm directly in the diff.
- Why: One sentence explaining the exploit path opened when the invariant fails.
- Ref: Exact standard mappings (OWASP Top 10:2025, ASVS 5.0, OWASP API Top 10:2023, and CWE) to paste into blocking review comments so remediation expectations are unambiguous.
Standards Baseline: OWASP Top 10:2025, ASVS 5.0, and MITRE CWE
If your team previously relied on the OWASP Secure Coding Practices Quick Reference Guide, note that OWASP has officially archived that standalone repository and migrated its checklists into the OWASP Developer Guide. Pairing the Developer Guide with our breakdown of the OWASP Top 10:2025 and ASVS 5.0 gives reviewers an up-to-date taxonomy that reflects modern supply chain and exception-handling failures.
| Standard / Resource | Current Edition | Role in Pull Request Security Reviews |
|---|---|---|
| OWASP Top 10 | 2025 Release | High-level risk taxonomy; folds Server-Side Request Forgery (SSRF) into A01:2025, adds A03:2025 Software Supply Chain Failures and A10:2025 failures. |
| OWASP ASVS | v5.0.0 (May 2025) | Verifiable pass/fail engineering requirements across 17 chapters (V1 Encoding through V17 WebRTC), including dedicated V9 Tokens and V10 OIDC. |
| OWASP API Security Top 10 | 2023 Release | API-specific failure modes covering Broken Object Level Authorization (API1:2023) and Broken Object Property Level Authorization (API3:2023). |
| MITRE CWE | CWE v4.x | Granular root-cause weakness identifiers (such as CWE-89 SQL Injection or CWE-639 Authorization Bypass Through User-Controlled Key). |
| OWASP Developer Guide & Cheat | Living Web Docs | Active replacement for the archived Secure Coding Practices Quick Reference Guide, paired with implementation patterns in the OWASP Cheat Sheet Series. |
2. Identity, Authentication, Session, and Access Control Checks
Identity and access boundaries account for more than a third of all requirements in OWASP ASVS 5.0 and represent the single highest-impact area for human security review.
Authentication Verification (OWASP A07:2025, ASVS V6)
Apply the authentication checks below whenever a diff introduces routes, modifies login flows, handles credentials, or touches account recovery. Reference the OWASP Authentication, Password Storage, Multifactor Authentication, and Forgot Password Cheat Sheets.
- Default-Authenticated Routing: New routes require authentication by default, and any public endpoint uses an explicit, documented opt-out decorator. Why: A forgotten route annotation silently exposes internal handlers to unauthenticated callers. Ref:
A07:2025 Authentication Failures,ASVS V6,CWE-306 - Standardized Authentication Libraries: Identity verification delegates to an established framework or identity provider rather than custom authentication logic. Why: Hand-rolled authentication routines routinely reintroduce timing leaks, parsing flaws, and edge-case bypasses solved years ago in vetted libraries. Ref:
ASVS V6 - Memory-Hard Password Hashing: Passwords use
Argon2id,bcrypt, orscryptconfigured with current work factors. Why: Fast general-purpose digests such asSHA-256collapse rapidly under offline GPU cracking. Ref:A04:2025 Cryptographic Failures,ASVS V11,CWE-916 - Brute-Force Rate Limiting: Login, password reset, and Multi-Factor Authentication (MFA) verification endpoints enforce strict per-account and per-IP rate limits. Why: Unthrottled authentication endpoints enable automated credential stuffing and six-digit code exhaustion. Ref:
A07:2025,ASVS V6,CWE-307 - Enforced Multi-Step MFA State: MFA verification steps cannot be bypassed by invoking downstream authenticated endpoints directly. Why: Failing to track partial authentication state server-side lets attackers skip the second factor entirely. Ref:
A07:2025,ASVS V6,CWE-287 - Short-Lived Single-Use Reset Tokens: Password recovery tokens come from a cryptographic generator, expire within minutes, and invalidate immediately upon single use. Why: Long-lived or reusable recovery tokens grant persistent account takeover paths. Ref:
ASVS V6,CWE-640
Authorization and Multi-Tenant Isolation (OWASP A01:2025, ASVS V8)
Authorization receives the deepest scrutiny because Broken Access Control (A01:2025) produces the highest volume of severe production breaches. Checking that a caller holds the user role proves nothing about whether that caller owns invoice 4812 or belongs to tenant acme-corp. As demonstrated in the Moltbook breach where missing Row Level Security exposed 1.5 million API keys, shipping functional data queries without object-level and tenant-level scoping turns standard API credentials into full-database read/write access. Reference the OWASP Authorization and Insecure Direct Object Reference Prevention Cheat Sheets.
Function-Level Access Checks
- Server-Side Action Enforcement: Every new route, controller method, and GraphQL resolver executes an explicit server-side permission check. Why: Hiding administrative buttons in frontend code never stops direct HTTP requests. Ref:
A01:2025 Broken Access Control,ASVS V8,CWE-862 - Deny-by-Default Policy: Access control evaluators reject requests whenever no explicit allow rule matches. Why: Allow-by-default logic converts every unmapped route or newly added action into an unauthorized exposure. Ref:
A01:2025,ASVS V8 - Service-Layer Role Checks: Privileged operations verify caller permissions inside the core service function rather than relying solely on route middleware for one HTTP path. Why: Secondary entry points such as GraphQL mutations, CLI jobs, or internal RPCs frequently invoke the same service method without the original route middleware. Ref:
A01:2025,CWE-285
Object-Level and Tenant-Level Checks
- Caller-Scoped Object Lookups: Queries fetching records by primary key constrain results to the authenticated owner (for example,
WHERE id = $1 AND owner_id = $2). Why: Fetching by primary key alone creates an Insecure Direct Object Reference (IDOR). Ref:A01:2025,ASVS V8,CWE-639 - Session-Derived Tenant Context: Multi-tenant queries extract
tenant_idstrictly from the verified server-side session or token claims, never from request bodies, query strings, or URL headers. Why: Trusting a client-supplied tenant identifier lets one customer read or mutate another organization’s records. Ref:A01:2025,ASVS V8,CWE-639 - Scoped Bulk, Search, and Export Queries: Collection endpoints, search indexes, and CSV/PDF export handlers apply identical tenant and ownership filters. Why: Unscoped bulk endpoints exfiltrate entire tables in a single call rather than one row at a time. Ref:
A01:2025,ASVS V8 - Write-Path Ownership Checks:
UPDATE,PATCH, andDELETEmutations verify record ownership just as strictly asGEThandlers. Why: Write-side IDOR flaws allow attackers to corrupt or destroy another tenant’s data. Ref:A01:2025,CWE-863 - Asynchronous Consumer Re-Verification: Background workers, queue consumers, and webhook processors re-verify tenant and object ownership before acting on queued IDs. Why: Asynchronous jobs execute outside the HTTP middleware context and may process stale or tampered job payloads. Ref:
A01:2025,CWE-863 - CSRF Defences on Cookie-Authenticated Mutations: State-changing endpoints accepting browser cookies enforce Cross-Site Request Forgery (CSRF) tokens or strict
SameSitepolicies. Why: Browsers automatically attach session cookies to cross-origin forged requests unless explicitly restricted. Ref:A01:2025,ASVS V3,CWE-352
Compare how an unscoped AI-generated endpoint differs from a session-scoped implementation during review:
# RED FLAG IN PR DIFF: Trusts client-supplied tenant_id and performs unscoped ID lookup
@router.get("/invoices/{invoice_id}")
async def get_invoice_vulnerable(invoice_id: int, tenant_id: str, db: Session = Depends(get_db)):
# Vulnerable to IDOR + Cross-Tenant Bypass (CWE-639 / A01:2025)
return db.query(Invoice).filter(
Invoice.id == invoice_id,
Invoice.tenant_id == tenant_id
).first()
# SECURE PATTERN: Binds both user_id and tenant_id from the verified session context
@router.get("/invoices/{invoice_id}")
async def get_invoice_secure(
invoice_id: int,
principal: AuthPrincipal = Depends(require_authenticated_principal),
db: Session = Depends(get_db),
):
invoice = db.query(Invoice).filter(
Invoice.id == invoice_id,
Invoice.tenant_id == principal.tenant_id,
Invoice.owner_id == principal.user_id,
).one_or_none()
if invoice is None:
raise HTTPException(status_code=404, detail="Invoice not found")
return InvoiceReadSchema.model_validate(invoice)Session and Self-Contained Token Handling (ASVS V7, ASVS V9)
In OWASP ASVS 5.0, stateful sessions live in V7 while JSON Web Tokens (JWTs) and other self-contained tokens have their own dedicated chapter in V9 (with cookie attributes reinforced in V3). Reference the OWASP Session Management and JSON Web Token Cheat Sheets.
- Session Identifier Rotation: Server-side session identifiers regenerate upon login and upon any privilege elevation. Why: Retaining a pre-authentication session ID enables session fixation attacks. Ref:
A07:2025,ASVS V7,CWE-384 - Hardened Cookie Attributes: Session cookies set
HttpOnly,Secure, and an explicitSameSite=LaxorSameSite=Strictattribute. Why: Missing flags expose session cookies to Cross-Site Scripting (XSS) theft and cross-origin request attachment. Ref:ASVS V3,ASVS V7,CWE-1004 - Strict JWT Cryptographic and Claim Validation: JWT verifiers enforce cryptographic signature checks against a pinned algorithm allowlist, reject
alg: none, and validateexp,aud, andissclaims. Why: Skipping algorithm allowlists or audience checks allows attackers to forge claims or replay tokens minted for another service. Ref:ASVS V9,CWE-347 - Zero Tokens in URLs or Logs: Bearer tokens, session IDs, and OAuth codes never travel in URL query parameters or application log payloads. Why: Query strings persist in browser history, proxy access logs, and
Refererheaders. Ref:ASVS V7,CWE-598 - Server-Side Session Revocation: Logout, password reset, and account suspension immediately invalidate active server-side sessions. Why: Stolen session credentials remain usable until natural expiry if logout only clears browser storage. Ref:
ASVS V7,CWE-613 - Refresh Token Rotation and Reuse Detection: Refresh tokens rotate on every exchange, and presenting a previously consumed refresh token revokes the entire token family. Why: Rotation and reuse detection bound the blast radius of a compromised long-lived refresh token. Ref:
ASVS V9,ASVS V10
3. Input Handling, APIs, Files, and Business Logic Checks
Whenever untrusted input crosses an application boundary into an interpreter, API parser, filesystem call, or financial workflow, verify that structural separation and domain invariants hold.
Input Validation and Injection Prevention (OWASP A05:2025, ASVS V1 & V2)
Apply the injection checks below whenever user-controlled or external data reaches SQL databases, OS shells, HTML templates, outbound HTTP clients, or object deserializers. Note that OWASP Top 10:2025 moved SSRF under A01:2025 Broken Access Control while keeping injection and XSS under A05:2025. Reference the OWASP Query Parameterization, XSS Prevention, OS Command Injection Defense, SSRF Prevention, Deserialization, and Input Validation Cheat Sheets.
- Parameterized Queries Only: Database access uses prepared statements or safe Object-Relational Mapping (ORM) parameter binding with zero string interpolation. Why: Concatenating untrusted strings into SQL or NoSQL queries allows attackers to rewrite query syntax. Ref:
A05:2025 Injection,ASVS V1,CWE-89 - Context-Aware Output Encoding: Dynamic values rendered to browsers use encoding matched to the exact sink context (HTML body, HTML attribute, JavaScript literal, CSS, or URL). Why: Applying HTML entity encoding inside an inline JavaScript block leaves XSS exploitable. Ref:
A05:2025,ASVS V1,CWE-79 - Shell-Free Subprocess Execution: Subprocess calls pass argument arrays with shell invocation disabled (
shell=FalseorexecFile) or use native language APIs instead of OS commands. Why: Passing concatenated strings to/bin/sh -cturns a single semicolon or subshell token into Remote Code Execution (RCE). Ref:A05:2025,ASVS V1,CWE-78 - Allowlisted Outbound URL Fetchers: Server-side HTTP requests driven by user input restrict schemes (
httpsonly), validate destination hostnames against an allowlist, and block private/link-local IP ranges after DNS resolution. Why: Unrestricted URL fetchers reach internal microservices and cloud instance metadata endpoints (169.254.169.254). Ref:A01:2025 Broken Access Control,ASVS V1,CWE-918 - Safe Deserialization Formats: Untrusted payloads never pass into native object deserializers such as Python
pickle, JavaObjectInputStream, PHPunserialize(), oryaml.load()withoutSafeLoader. Why: Gadget chains in native deserializers execute arbitrary code before application validation runs. Ref:A08:2025 Software or Data Integrity Failures,ASVS V1,CWE-502 - Positive Server-Side Input Validation: Server handlers enforce strict allowlists for data type, byte length, numeric range, and format. Why: Client-side form validation is bypassed with a single
curlcommand. Ref:ASVS V2,CWE-20
A classic injection red flag you can spot in two seconds inside any Python diff:
# RED FLAG: f-string interpolation directly inside SQL execution (CWE-89)
cursor.execute(f"SELECT * FROM orders WHERE id = {order_id}")
# SECURE: Driver-level parameter binding separates SQL structure from data
cursor.execute("SELECT * FROM orders WHERE id = %s AND tenant_id = %s", (order_id, tenant_id))API Surface and Schema Security (OWASP API Top 10:2023, ASVS V4)
Apply the API security checks below when reviewing REST, GraphQL, gRPC, or webhook endpoints. Reference the OWASP REST Security, Mass Assignment, and GraphQL Cheat Sheets.
- Authenticated Internal and Versioned Endpoints: Legacy routes (
/v1/) and internal service endpoints enforce authentication alongside primary public routes. Why: Copied controller versions and “internal” prefixes frequently lose authentication middleware during refactors. Ref:API2:2023 Broken Authentication,API9:2023 Improper Inventory Management - Per-Identifier Object Authorization: Every resource ID present in path parameters, query filters, and nested JSON arrays undergoes Broken Object Level Authorization (BOLA) verification. Why: Checking ownership on the parent URL ID while ignoring secondary IDs inside the JSON payload leaks foreign records. Ref:
API1:2023 BOLA,ASVS V8,CWE-639 - Explicit Input DTOs Against Mass Assignment: Request payloads bind to explicit Data Transfer Objects (DTOs) or field allowlists rather than directly mutating ORM entities. Why: Direct model binding lets callers inject privileged fields such as
role,is_admin, orplan_tier(Broken Object Property Level Authorization, or BOPLA). Ref:API3:2023 BOPLA,ASVS V15,CWE-915 - Strict Request Schema Enforcement: API gateways or framework validators enforce JSON/protobuf schemas and reject unexpected fields or type mismatches. Why: Unvalidated nested objects trigger type confusion and unhandled downstream exceptions. Ref:
ASVS V4,CWE-20 - Pagination Caps and Cost Throttling: Collection endpoints enforce a hard maximum page size (
limit <= 100) and rate limits. Why: Unboundedlimit=1000000queries enable denial of service and rapid dataset scraping. Ref:API4:2023 Unrestricted Resource Consumption,CWE-770 - GraphQL Depth, Complexity, and Introspection Controls: GraphQL servers enforce query depth and cost limits and disable schema introspection in production unless intentionally public. Why: Deeply nested cyclical GraphQL queries exhaust CPU and memory in a single HTTP POST. Ref:
API4:2023,ASVS V4 - Cryptographic Webhook Signature Verification: Inbound webhook receivers verify HMAC signatures over the raw request bytes and check timestamp freshness before parsing business logic. Why: Webhook URLs are publicly reachable endpoints that anyone on the internet can POST forged events to. Ref:
ASVS V4,CWE-345
File Upload, Path, and Parser Safety (OWASP A01:2025 & A02:2025, ASVS V5)
Apply the file-handling checks below whenever code reads filenames, extracts archives, accepts uploads, or parses XML documents. Reference the OWASP File Upload and XML External Entity Prevention Cheat Sheets.
- Canonicalized Path Confinement: Filesystem paths derived from external input resolve via
realpath/Path.resolve()and verify that the canonical path starts with the intended base directory. Why: Unchecked../traversal sequences expose/etc/passwd, environment files, or application source code. Ref:A01:2025,ASVS V5,CWE-22 - Zip Slip Archive Extraction Guards: TAR and ZIP extraction routines resolve each archive entry path and abort if any entry escapes the target extraction folder or introduces symlinks outside the root. Why: Malicious archive entries containing
../../overwrite arbitrary files on disk (“Zip Slip”). Ref:ASVS V5,CWE-22 - Content-Type and Byte-Size Upload Validation: File uploads enforce strict byte-size caps and verify magic bytes / MIME content rather than trusting client-supplied filename extensions or
Content-Typeheaders. Why: A polyglot or double-extension file such asinvoice.pdf.phpexecutes as code if served by an unhardened web server. Ref:ASVS V5,CWE-434 - Out-of-Webroot Storage with Generated Filenames: Uploaded blobs land in object storage or a non-executable directory outside the webroot using server-generated UUID keys. Why: Storing user-named uploads inside static web directories enables direct script execution and file overwrites. Ref:
ASVS V5,CWE-434 - Hardened XML Parsers Against XXE: XML parsers explicitly disable Document Type Definitions (DTDs) and external entity resolution. Why: Default XML configurations in several ecosystems remain vulnerable to XML External Entity (XXE) local file disclosure and SSRF. Ref:
A02:2025 Security Misconfiguration,ASVS V1,CWE-611
Business Logic and Concurrency Controls (OWASP A06:2025, ASVS V2 & V15)
Static pattern scanners cannot infer what your product is supposed to allow. Business logic review requires comparing the code against domain invariants.
- Server-Enforced Workflow State Machines: Multi-step processes (such as
cart -> payment_pending -> paid -> fulfilled) validate legal state transitions server-side on every mutation. Why: Attackers invoke finalization endpoints directly out of sequence to skip payment or approval steps. Ref:A06:2025 Insecure Design,ASVS V2,CWE-841 - Domain Boundary Checks on Quantities and Amounts: Monetary values, item counts, and transfer amounts reject negative numbers, zero (where invalid), NaN, and integer overflows. Why: Submitting a quantity of
-5in an unguarded checkout calculation turns a debit into an account credit. Ref:A06:2025,ASVS V2,CWE-20 - Atomic Concurrency on Balances and Quotas: Wallet debits, coupon redemptions, and inventory decrements use database transactions with row-level locking (
SELECT ... FOR UPDATE) or atomic conditional updates. Why: Parallel race-condition requests (“double-spend” Time-of-Check to Time-of-Use, or TOCTOU) drain balances multiple times before state commits. Ref:A06:2025,ASVS V15,CWE-362 - Idempotency and Replay Protection: Payment captures, fund transfers, and provisioning endpoints require client idempotency keys or single-use nonces. Why: Network retries or intentional request replays duplicate financial side effects without idempotency enforcement. Ref:
A06:2025,ASVS V2 - Cross-Endpoint Business Limit Enforcement: Free-trial caps, promotional codes, and seat invitation limits enforce quotas in a shared domain layer across REST, GraphQL, and batch endpoints alike. Why: Quotas enforced only on the primary web controller get bypassed through mobile or batch API routes. Ref:
API6:2023 Unrestricted Access to Sensitive Business Flows
4. Cryptography, Secrets, Data Privacy, and Error Logging Checks
Cryptographic failures, leaked credentials, verbose exception traces, and unapproved data sharing turn localized bugs into organization-wide compromises and regulatory incidents.
Cryptography and TLS Verification (OWASP A04:2025, ASVS V11 & V12)
Reference the OWASP Cryptographic Storage and Transport Layer Security Cheat Sheets.
- Zero Custom Cryptographic Primitives: The diff introduces no bespoke encryption schemes, custom stream ciphers, or homegrown token-signing protocols. Why: Custom cryptographic constructions fail silently against differential, timing, and padding attacks that functional unit tests never detect. Ref:
A04:2025 Cryptographic Failures,ASVS V11,CWE-327 - Modern Vetted Algorithms and Authenticated Modes: Symmetric encryption uses authenticated modes (
AES-256-GCMorChaCha20-Poly1305), with zero use ofECBmode,DES,MD5, orSHA-1for security guarantees. Why:ECBleaks plaintext structure and broken hashes allow chosen-prefix collisions. Ref:A04:2025,ASVS V11,CWE-327 - Unique Per-Operation IVs and Nonces: Initialization vectors (IVs) and nonces are generated uniquely per encryption call and never hardcoded or reused under the same key. Why: A single reused nonce in
AES-GCMcatastrophically destroys both confidentiality and authentication integrity. Ref:A04:2025,ASVS V11,CWE-329 - Cryptographically Secure Randomness: Security tokens, session IDs, nonces, and verification codes draw from a Cryptographically Secure Pseudo-Random Number Generator (CSPRNG) such as Python
secretsor Node.jscrypto.randomBytes(). Why:Math.random()andrandom.random()expose internal PRNG state that attackers reconstruct from a handful of outputs. Ref:A04:2025,ASVS V11,CWE-338 - Mandatory TLS Certificate Verification: Outbound Transport Layer Security (TLS) clients keep certificate chain and hostname verification enabled, with zero
verify=False,NODE_TLS_REJECT_UNAUTHORIZED=0, orInsecureSkipVerify: trueflags. Why: “Temporary” TLS bypasses pasted during debugging ship to production and enable trivial Man-in-the-Middle (MitM) interception. Ref:ASVS V12,CWE-295 - Externalized Key Management: Encryption and signing keys load at runtime from a cloud Key Management Service (KMS) or dedicated secrets manager, never from repository files. Why: Keys committed to source control replicate permanently to every developer laptop, fork, and CI cache. Ref:
ASVS V11,CWE-321
Secrets Hygiene Across Code and Git History (OWASP A07:2025, ASVS V13)
Inspect test suites, fixtures, Dockerfiles, and sample configurations just as carefully as application code. Reference the OWASP Secrets Management Cheat Sheet.
- Zero Hardcoded Credentials Anywhere in Diff: Source files, unit test fixtures, Dockerfiles, GitHub Actions YAML, and
.env.exampletemplates contain no real API keys, database URIs, or private keys. Why: Credentials labelled “staging” or “test” frequently share permissions with production cloud accounts. Ref:A07:2025,ASVS V13,CWE-798 - Immediate Rotation of Historically Committed Secrets: Any secret committed in an earlier commit on the PR branch is revoked and rotated immediately, not merely deleted in a follow-up commit. Why: Deleting a secret in a later commit leaves the plaintext credential accessible in Git commit history and PR reflogs. Ref:
ASVS V13,CWE-798 - Ignored Local Environment Files:
.env,.env.local, service-account JSON keys, and Terraform.tfvarsfiles containing secrets are explicitly excluded in.gitignoreand.dockerignore. Why: Unignored local credential files get swept into repositories bygit add .or baked into container layers byCOPY . .. Ref:ASVS V13 - Runtime Secret Injection: Newly required credentials inject via workload identity or runtime secret mounts rather than build-time container
ARGorENVdirectives. Why: Build-time container arguments persist indocker historymetadata for anyone with registry pull access. Ref:ASVS V13,CWE-526
Error Handling and Security Logging (OWASP A09:2025 & A10:2025, ASVS V16)
OWASP Top 10:2025 elevated A10:2025 Mishandling of Exceptional Conditions as a standalone top-ten category and renamed A09:2025 to emphasize alerting alongside logging. Reference the OWASP Logging and Error Handling Cheat Sheets.
- Sanitized User-Facing Error Responses: External error payloads return generic messages with correlation IDs, stripping stack traces, SQL syntax, filesystem paths, and internal hostnames. Why: Detailed exception dumps map framework versions, table schemas, and internal topology for attackers. Ref:
A10:2025 Mishandling of Exceptional Conditions,ASVS V16,CWE-209 - Fail-Closed Exception Paths:
try/catchblocks wrapping authentication, authorization, rate limiting, or policy engines deny access whenever an exception occurs. Why: Catch blocks that log an error and fall through (or returntrue) turn downstream timeouts into complete authentication bypasses. Ref:A10:2025,ASVS V16,CWE-636 - Structured Audit Logging on Security Events: Authentication failures, access denials, privilege changes, and administrative mutations emit structured logs capturing actor identity, tenant, target resource, and timestamp. Why: Incident responders cannot scope or prove unauthorized access without an immutable audit trail. Ref:
A09:2025 Security Logging and Alerting Failures,ASVS V16,CWE-778 - Zero Secrets or Raw PII in Logs: Log statements never serialize
Authorizationheaders, cookies, passwords, payment card numbers, or unredacted request bodies. Why: Centralized log aggregators are readable by far more engineers and third-party processors than production databases. Ref:A09:2025,ASVS V16,CWE-532 - Log Injection Neutralization: Untrusted strings written to logs use structured JSON fields or strip carriage returns, newlines, and ANSI control characters. Why: Raw
\r\nsequences in text logs let attackers forge fake audit entries and corrupt SIEM parsers. Ref:A09:2025,ASVS V16,CWE-117
Data Protection and LLM Privacy Boundaries (OWASP A04:2025, ASVS V14)
Apply the data-protection checks below whenever a PR introduces database columns, modifies API serializers, or wires application data into analytics SDKs or Large Language Model (LLM) APIs.
- Explicit Data Classification: New personal, financial, health, or tenant-confidential fields are documented and tagged according to your data classification policy. Why: Unclassified columns bypass automated masking, encryption, and regional residency guardrails. Ref:
ASVS V14 - Data Minimization and Defined Retention: Newly stored attributes collect only what the feature strictly requires and attach to a concrete TTL or deletion lifecycle. Why: Sensitive records you never retain cannot be exfiltrated in a future breach. Ref:
ASVS V14,CWE-359 - Minimal Response Serialization: API endpoints serialize explicit response schemas containing only client-required fields rather than returning raw database models. Why: Returning full user objects often leaks password hashes, internal notes, or MFA secrets in browser network tabs (
API3:2023). Ref:API3:2023 BOPLA,ASVS V14,CWE-213 - Encryption at Rest for Regulated Stores: New storage buckets, caches, and database volumes holding sensitive data enforce encryption at rest. Why: Unencrypted snapshots, read replicas, and backups outlive application-level access controls. Ref:
A04:2025,ASVS V14,CWE-311 - Approved Third-Party and LLM Data Egress: Personal data, customer source code, and confidential records are never transmitted to external analytics trackers or third-party LLM prompts without documented privacy approval and zero-data-retention agreements. Why: Every external API call establishes a new sub-processor boundary and potential training-data leak. Ref:
ASVS V14
5. Supply Chain, Dependencies, Configuration, and CI/CD Checks
In OWASP Top 10:2025, A02:2025 Security Misconfiguration and A03:2025 Software Supply Chain Failures occupy the #2 and #3 positions right behind Broken Access Control, underscoring how often modern compromises enter through package.json, Terraform, or .github/workflows/.
Software Dependencies and Reachability Analysis (OWASP A03:2025, ASVS V15)
Apply the dependency checks below whenever a PR adds, upgrades, or removes packages in manifests (package.json, pyproject.toml, go.mod, pom.xml, Cargo.toml). Reference the OWASP Vulnerable Dependency Management Cheat Sheet.
- Justified and Actively Maintained Packages: Every newly introduced dependency solves a non-trivial problem and shows active upstream maintenance and security response practices. Why: Pulling in abandoned micro-packages for five-line helpers leaves unpatched transitive trees in your build. Ref:
A03:2025 Software Supply Chain Failures,ASVS V15,CWE-1104 - Verified Exact Package Naming: Package names and scopes match the canonical upstream project character-for-character with zero near-miss spellings. Why: Typosquatting packages execute malicious payloads during dependency installation. Ref:
A03:2025,CWE-1357 - Committed Lockfiles and Pinned Versions: Lockfiles (
package-lock.json,pnpm-lock.yaml,uv.lock,poetry.lock) update in lockstep with manifests using deterministic cryptographic hashes. Why: Floating version ranges (*or unpinned caret ranges without lockfile enforcement) pull freshly compromised upstream releases straight into CI builds. Ref:A03:2025,ASVS V15 - Audited Package Lifecycle Scripts: Any
preinstall,install, orpostinstallhooks inside newly added packages have been inspected or disabled by policy. Why: Malicious lifecycle scripts exfiltrate cloud credentials from developer machines and CI runners the instantnpm installorpip installruns. Ref:A03:2025,CWE-829 - Policy-Compliant Open-Source Licences: New direct and transitive dependencies carry licences compatible with organizational legal policy (for example, avoiding unexpected
AGPL-3.0copyleft obligations in proprietary services). Why: Licence violations discovered post-release force costly emergency rewrites. Ref:ASVS V15 - Function-Level Reachability Triage for CVEs: When Software Composition Analysis (SCA) flags a vulnerability in an added or bumped dependency, verify whether application code calls a path reaching the vulnerable function before blocking or waiving the PR. Why: A parsing bug inside an unused helper module carries fundamentally different risk than a deserialization CVE wired directly into a public HTTP handler. Ref:
A03:2025,CWE-1395
Static CVE lists overwhelm reviewers with unexploitable noise. Combining call-graph reachability analysis with automated SCA remediation (such as the patterns covered in automating AppSec remediation with context-aware AI agents) lets reviewers distinguish reachable P0 blockers from non-reachable backlog items using concrete call-path evidence.
Application Configuration, Containers, and CI/CD Workflows (OWASP A02:2025 & A03:2025, ASVS V3 & V13)
Apply the configuration and pipeline checks below when reviewing Helm charts, Terraform/OpenTofu HCL, Dockerfiles, web server configs, and CI workflow YAML. Reference the OWASP Infrastructure as Code Security and Docker Security Cheat Sheets, alongside our OWASP Top 10 CI/CD Security Risks blueprint.
- Disabled Production Debug Modes: Framework debug flags (
DEBUG=True, Werkzeug debugger, Spring Boot Actuator sensitive endpoints, pprof) are strictly off in production profiles. Why: Exposed debug consoles frequently provide interactive Remote Code Execution out of the box. Ref:A02:2025 Security Misconfiguration,ASVS V13,CWE-489 - Safe CORS Origin Policies: Cross-Origin Resource Sharing (CORS) configurations never pair wildcard (
*) or blindly reflectedOriginheaders withAccess-Control-Allow-Credentials: true. Why: Reflecting arbitrary origins alongside credentials lets any malicious webpage read authenticated API responses from the victim’s browser. Ref:A02:2025,ASVS V3,CWE-942 - Hardened Browser Security Headers: Web responses enforce Content Security Policy (
CSP), HTTP Strict Transport Security (HSTS),X-Content-Type-Options: nosniff, andframe-ancestorsrestrictions. Why: Missing response headers leave browsers exposed to XSS gadget execution, MIME sniffing, clickjacking, and TLS stripping. Ref:A02:2025,ASVS V3 - Private Storage and Restricted Network Ingress in IaC: Terraform, CloudFormation, and Kubernetes manifests create zero public object-storage buckets and zero
0.0.0.0/0ingress rules on SSH (22), RDP (3389), or database ports. Why: Automated internet scanners discover and ransack public cloud buckets and exposed admin ports within minutes of deployment. Ref:A02:2025,CWE-732 - Least-Privilege Cloud IAM Policies: Identity and Access Management (IAM) roles scope permissions to specific actions and resource ARNs/URIs, avoiding
"Action": "*"or"Resource": "*". Why: Wildcard IAM roles convert a single compromised pod into full cloud-account takeover. Ref:A01:2025,CWE-250 - Non-Root Container Execution: Dockerfiles and Kubernetes
securityContextspecs run processes as an explicit non-root UID, dropALLLinux capabilities, and use minimal base images where feasible. Why: Running container processes asUID 0dramatically lowers the barrier to host kernel escape and lateral movement. Ref:A02:2025,CWE-250 - Minimal CI Token Permissions and Safe Expression Handling: GitHub Actions and GitLab CI workflows declare explicit
permissions: contents: readdefaults, pin third-party actions to full 40-character commit SHAs, and never interpolate untrusted PR metadata (${{ github.event.pull_request.title }}or head branch names) directly intorun:shell scripts. Why: Shell injection inside privilegedpull_request_targetworkflows exfiltrates repository secrets and write tokens. Ref:A03:2025,CWE-78
6. Extra Checks Specific to AI-Generated Pull Requests
Autonomous coding agents (Claude Code, Cursor, Codex, Gemini CLI) optimize relentlessly for passing functional tests and satisfying compiler errors. Because LLM weights reflect millions of public repositories containing insecure shortcuts, agents reproduce classic vulnerabilities alongside distinct agent-only failure modes that human engineers rarely introduce.
Every domain check in Sections 2 through 5 applies to AI-authored code, plus the five mandatory checks below.
Five Mandatory Checks for Agent-Authored Diffs
- Registry Existence and Provenance Verification (Anti-Slopsquatting): Confirm every newly added package actually exists on npm, PyPI, Maven Central, or Go Proxy with an established release history, real repository link, and legitimate maintainer. Why: LLMs hallucinate plausible-sounding non-existent package names, and threat actors proactively register those exact names to plant malware in a supply chain attack known as AI slopsquatting. Ref:
A03:2025 Software Supply Chain Failures,CWE-1357 - Zero Dropped Security Controls Across Agent Iterations: Compare the final PR diff against both the original ticket security requirements and the first commit of the branch to verify that authentication decorators, CSRF middleware, input validators, TLS
verify=Truesettings, and rate limiters survived intact. Why: When an AI coding agent hits a failing test or HTTP403error during self-repair loops, the agent frequently deletes or loosens the blocking security control so the test suite turns green. Ref:A06:2025 Insecure Design,ASVS V15 - Zero Placeholder Credentials or Fallback Keys: Search the diff for synthetic or fallback secrets such as
sk-test-...,changeme,secret_key = os.getenv("JWT_SECRET", "default-secret"), or dummy HMAC keys. Why: Hardcoded fallback defaults silently activate in production whenever an environment variable is misspelled or omitted. Ref:A07:2025,CWE-798 - Zero Stubbed Authorization or
TODOSecurity Bypasses: Verify no# TODO: implement authcomments, mock middleware, or stubbed policy functions returningTrueremain anywhere in the diff. Why: Stubbed permission checks satisfy static type checkers and happy-path tests while shipping wide-open endpoints. Ref:A01:2025,CWE-862 - Adversarial and Failure-Path Unit Tests: Confirm PR tests explicitly assert
401 Unauthorized,403 Forbidden(cross-tenant access),422 Unprocessable Entity(malformed input), and rate-limit rejections, not just200 OKhappy paths. Why: AI-generated test suites routinely exhibit tautological testing, asserting only that the generated code executes whatever logic the agent just wrote. Ref:ASVS V15
Catching Silent Control Regressions Across Agent Iterations
Silent control regression is the single most frequently missed flaw in agent-written PRs. Reviewers typically inspect only the net diff against main, which hides controls that existed in Commit 1 (or in the issue specification) and vanished in Commit 4 while the agent debugged a test failure.
# COMMIT 1 (Initial agent draft matched ticket spec, but broke an unauthenticated unit test):
@app.post("/api/v1/webhooks/stripe")
@limiter.limit("60/minute")
async def stripe_webhook(request: Request):
payload = await request.body()
sig_header = request.headers.get("Stripe-Signature", "")
event = stripe.Webhook.construct_event(payload, sig_header, settings.STRIPE_WEBHOOK_SECRET)
await process_verified_event(event)
return {"status": "ok"}
# COMMIT 4 (Final PR diff after agent "fixed" failing unit tests lacking valid signatures):
@app.post("/api/v1/webhooks/stripe")
async def stripe_webhook(request: Request):
# RED FLAG: Agent dropped @limiter and replaced signature verification with raw JSON parse!
event = await request.json()
await process_verified_event(event)
return {"status": "ok"}Whenever a PR carries AI co-author trailers or comes from an autonomous coding workflow, open the linked issue alongside the commit-by-commit history, list the expected security boundaries, and confirm each boundary survived to the final SHA.
7. Automating the Gate vs Focusing Human Reviewers
At modern engineering velocity, human reviewer attention is your scarcest security resource. Expecting engineers to manually hunt for regex-detectable MD5 calls or missing cookie flags wastes cognitive budget that should be spent evaluating multi-tenant isolation and business workflow abuse.
Pattern-only Static Application Security Testing (SAST) floods developers with syntax false positives while completely missing IDOR and broken authentication because no regular expression can express “this user does not own record 4812.” Modern dataflow-aware SAST and evidence-grounded agent harnesses (such as Google’s open-source Mantis vulnerability harness and reachability-backed PR review agents) trace untrusted request parameters across multiple files into database sinks, moving mechanical object-lookup tracing into Stage 1. However, no automated scanner knows whether a customer-support role should have cross-tenant read access under your product’s contract terms. Policy, intent, and architecture remain human responsibilities.
Automation vs Human Judgment Matrix
Use the division below to configure your CI/CD merge gates and train human code reviewers on where to spend their review minutes:
| Automate on Every Pull Request (Stage 1 Gate) | Reserve for Human Reviewer Judgment (Stage 2 Review) |
|---|---|
| Injection Dataflow: SQLi, command injection, XSS, SSRF, and unsafe deserialization sinks. | Authorization Semantics: Whether permission rules match real business roles. |
| Traced Unscoped Queries: Request IDs flowing into ORM lookups without owner/tenant joins. | Multi-Tenant Architecture: Isolation design for shared tables, caches, and queues. |
Secrets & History: Hardcoded credentials, fallback tokens, and .env commits in history. | Data Governance: Classifying new sensitive fields and setting retention windows. |
| Supply Chain & Reachability: Non-existent packages, typosquats, scripts, reachable CVEs. | Dependency Necessity: Deciding whether adding a third-party library is worth risk. |
Cryptographic API Misuse: Weak ciphers (ECB/MD5), static nonces, verify=False. | Business Logic & Concurrency: State-skipping, negative amounts, and race flows. |
IaC, Container & CI Misconfig: Public buckets, Action: *, root containers, CI scripts. | External & LLM Data Egress: Approving whether PII or code may cross to a vendor. |
Token & Cookie Flags: Missing HttpOnly/Secure, alg: none, unverified JWT signatures | Control-Regression Audit: Confirming AI agents kept controls required by tickets. |
| File Path & Parser Sinks: Unconfined path joins, Zip Slip patterns, XXE-enabled XML. | Policy Exceptions: Approving and documenting deliberate public routes or waivers. |
8. Run the Checklist with the Open-Source security-review Skill
To operationalize all 82 checks across the 14 domains above without manual copy-pasting, I published the open-source security-review-skill on GitHub. The skill turns OpenCode, Claude Code, Codex, Cursor, or Gemini CLI into a read-only, diff-scoped PR reviewer featuring commit-by-commit control-regression auditing, adversarial finding validation, a paste-ready PR-TEMPLATE.md, and structured review.json and REVIEW.md outputs.
Quick Installation
Install the skill via the Skills CLI (requires Node.js 22.20+) for a single repository or globally for your preferred coding agent:
# Install into the current project
npx skills add https://github.com/wioui/security-review-skill --skill security-review
# Or install globally for OpenCode or Claude Code (also supports codex, cursor, gemini-cli)
npx skills add https://github.com/wioui/security-review-skill --skill security-review -a opencode -g
npx skills add https://github.com/wioui/security-review-skill --skill security-review -a claude-code -gQuick Usage
Launch your coding agent in the target repository and request a diff review (or invoke @security-review in OpenCode / /security-review in Claude Code):
security review this PR
review origin/main...HEAD for security before I merge
this branch was written by Claude Code: check it for dropped security controlsFor automated CI merge gates, run the bundled zero-dependency validator (node <skill-dir>/validate-review.cjs security-review/review.json --gate) to block merges on confirmed critical or high findings introduced by the diff.
Conclusion: Enforce Evidence at the Merge Boundary
AI coding assistants have permanently multiplied pull request volume, compressing the time between a ticket description and a mergeable branch from days to minutes. Because code generation models optimize for green functional tests rather than adversarial resilience, treating passing CI unit tests as proof of safety guarantees a growing security debt of broken object-level authorization, slopsquatted dependencies, and silently dropped middleware.
Pairing automated dataflow, secret, IaC, and reachability gates with a diff-scoped human review checklist anchored in OWASP Top 10:2025, OWASP ASVS 5.0, and MITRE CWE restores engineering control at the merge boundary. Automate every pattern and call-graph check a machine can prove, and focus human security reviewers on authorization intent, multi-tenant isolation, business workflows, and agent control regressions.
To further enhance your cloud security and implement Zero Trust, contact me on LinkedIn Profile or [email protected].
FAQ
Frequently Asked Questions (FAQ)
What is the difference between a secure code review checklist and a secure coding checklist?
A secure coding checklist guides software developers while writing new features before any pull request exists. A secure code review checklist is a diff-scoped verification list applied by reviewers and automated gates to a specific pull request right before merge, checking only the attack surfaces modified by the change.
Did OWASP archive the Secure Coding Practices Quick Reference Guide?
Yes. OWASP archived the standalone Secure Coding Practices Quick Reference Guide repository and migrated its checklist content into the active OWASP Developer Guide. Security teams should cite the OWASP Developer Guide alongside OWASP Top 10:2025 and OWASP ASVS 5.0.0 as their current baseline.
Why do AI-generated pull requests require extra security review checks?
Empirical evaluations such as the SusVibes benchmark and Endor Labs Agent Security League show that top AI coding agents achieve roughly 87% to 91% functional correctness while passing security tests less than 38% of the time. Agents introduce unique failure modes including hallucinated package names (slopsquatting), placeholder fallback secrets, tautological happy-path tests, and silently deleting authentication or TLS controls across self-repair iterations.
Why does authorization receive the most items in a pull request security review?
Broken Access Control (OWASP A01:2025) remains the most prevalent critical application vulnerability because pattern-matching scanners cannot infer business ownership rules. Reviewers must manually verify that every record lookup, mutation, bulk export, and background job scopes queries to the caller and derives tenant identifiers from the authenticated server session rather than request inputs.
How does OWASP ASVS 5.0 improve pull request security reviews?
Released in May 2025, OWASP Application Security Verification Standard (ASVS) 5.0.0 reorganizes 345 testable security requirements across 17 chapters, adding dedicated chapters for Web Frontend Security (V3), Self-contained Tokens such as JWTs (V9), OAuth and OIDC (V10), and Secure Coding and Architecture (V15). Reviewers can cite exact ASVS chapter references in PR comments to set clear pass-or-fail criteria.
Which code review security checks should be automated versus reviewed by a human?
Teams should automate deterministic and dataflow checks on every pull request, including SQL and command injection tracing, hardcoded secret detection, package registry existence, dependency CVE reachability, cryptographic API misuse, and IaC or CI workflow linting. Human reviewers should focus on multi-tenant isolation design, role policy semantics, business logic state transitions, concurrency race conditions, sensitive data egress to LLMs, and verifying that AI agents did not drop required controls.
How does reachability analysis help during dependency review in a pull request?
Reachability analysis traces call paths from application source code into third-party libraries to determine whether a vulnerable function associated with a CVE can actually execute at runtime. Using reachability evidence prevents engineering teams from blocking urgent pull requests over uncalled transitive helper code while ensuring immediate remediation when vulnerable code sits on an active request path.
Resources
- Companion Agent Skill (GitHub): wioui/security-review-skill: Open-Source PR Security Review Skill
- OWASP Risk Taxonomy: OWASP Top 10:2025 Official Release
- Verification Standard: OWASP Application Security Verification Standard (ASVS) 5.0
- Developer Checklists: OWASP Developer Guide (Successor to Secure Coding Practices Quick Reference)
- Implementation Patterns: OWASP Cheat Sheet Series (ASVS 5.0 Index)
- API Security Baseline: OWASP API Security Top 10:2023
- AI Agent Benchmark: Endor Labs Agent Security League & SusVibes Benchmark Analysis
- Related Analysis: The Prompt That Turns Your AI Coder into a Security Expert
- Related Analysis: Slopsquatting: The AI Hallucination That Infects Your Codebase
- Related Analysis: Google Mantis: Open-Source AI Harness to Find and Fix Bugs



