Skip to main content
Authentication is assumed to be present. This lesson focuses on the next critical step: authorization — verifying which identities can access which resources and operations across an Express application. The supporting repository and the automated audit artifacts referenced throughout this guide are available on GitHub: https://github.com/JeremyMorgan/Claude-Code-Reviewing-Prompts
Summary
  • Purpose: Provide a practical checklist and remediation guidance for authorizing routes, preventing BOLA/IDOR, enforcing RBAC, verifying JWT usage, and closing privilege escalation vectors.
  • Audience: Backend engineers, security reviewers, and dev teams auditing Express apps for authorization issues.
  • Output: A reproducible checklist, example code snippets for fixes, proof-of-concept notes, and prioritized remediation steps.
Authorization checklist (core items) Additional items to check
A dark-themed code editor (Visual Studio Code) with a file explorer on the left. The main pane displays a security-audit checklist covering role-based access control, JWT validation, privilege escalation checks, and API token scopes.
Key points to emphasize
  • Multi-tenant isolation must be enforced server-side. Client-side tenant selectors are not a security boundary.
  • Bulk operations must check ownership at the per-item level; do not assume the caller is authorized for every item in a batch.
  • Field-level authorization (or server-side projection) is required to avoid leaking sensitive fields.
  • Use a consistent error policy to avoid resource enumeration: choose 403 for authenticated-but-unauthorized; use 404 only when intentionally hiding existence.
  • Middleware ordering must always be: authentication (authN) → authorization (authZ) → handler. Misordered middleware is a common bypass.
For each endpoint you should answer
  • Who can access it? (roles, scopes, tenant)
  • What data can they see or modify (including hidden fields)?
  • Are ownership/tenancy checks enforced (query-level filter + post-fetch verification)?
  • Are authN/authZ middleware enforced consistently and in the correct order?
Deliverables for each finding For any issue discovered, produce:
  • Title, Severity (Critical/High/Medium/Low), CWE (if applicable)
  • Evidence (file, function, line ranges)
  • Short explanation: Why it matters
  • Exploitability notes and safe PoC steps (no real secrets)
  • Remediation: precise code-level fix or config change (include snippets)
  • Defense-in-depth guidance
  • Summary risk score (0–10) and top prioritized fixes
  • Checklist diff: which items are Pass / Fail / N/A
Callout — critical reminder
Authorization failures are often catastrophic. If you find missing authorization middleware, weak JWT validation, or endpoints that accept role changes from clients, treat these as critical and fix them before any production deployment.
Example findings and minimal remediation snippets
  1. Weak / incomplete JWT issuance
Problem: Tokens are signed without explicit algorithm, issuer, audience, or short expiration. Default secrets in env allow token forgery. Remediation (example token issuance):
  1. Enforce ownership on object-level routes
Problem: Routes accepting /:id may be vulnerable to BOLA/IDOR if they do not verify resource ownership. Remediation (authorization middleware):
  1. Authentication middleware must run before route handlers
Example pattern:
Proof of concept (why it is exploitable) If no auth middleware is attached, any future POST/PUT/DELETE endpoints will be accessible to anonymous users. To demonstrate locally:
If the server does not require the token for privileged routes, any client can perform state-changing operations without authorization. Assessment sample (from automated audit)
  • Authorization Security Assessment Complete
  • Risk Score: 9.5/10 (Critical)
Critical findings (examples)
  • No authentication middleware — endpoints are unprotected.
  • Weak JWT implementation — missing algorithm, issuer, audience validation.
  • Default secrets present — allows token forgery.
  • No authorization framework — vulnerable to BOLA/IDOR.
Immediate actions (short-term)
  • Replace default JWT secret with a 256-bit cryptographically secure value.
  • Implement authentication middleware before adding any protected endpoints.
  • Configure JWT verification to require algorithms, issuer, and audience, and ensure expiration (exp) is enforced.
  • Disallow client-side role or tenant updates; accept those only via server-side admin flows.
Defense-in-depth recommendations
  • Application: comprehensive authN/authZ middleware, RBAC mapping, and field-level filtering.
  • Infrastructure: rate limiting, WAF, secure defaults for secrets and environment variables.
  • Database: enforce row-level security when available (e.g., PostgreSQL RLS) and use least-privilege DB users.
  • Monitoring: log auth events and alert on suspicious access patterns.
  • Testing: automated tests for BOLA/IDOR, RBAC, and token validation in CI.
Assessment artifacts and reporting Produce a structured report per issue containing:
  • Title, Severity, CWE, Evidence (file/function/line ranges), Why it matters.
  • Safe reproduction steps and remediation code snippets.
  • A prioritized list of fixes and a checklist diff (Pass/Fail/N/A).
Wrap-up Automated code-generation tools can accelerate development, but they often produce code lacking hardening assumptions (default secrets, missing authZ, etc.). Use automated audits to find these gaps, apply minimal, specific fixes above, and re-run tests and audits. The prompts and audit artifacts referenced in this lesson/article are available at: https://github.com/JeremyMorgan/Claude-Code-Reviewing-Prompts
Use short-lived access tokens (e.g., 15 minutes) and implement a refresh token mechanism with strict rotation and revocation. Always validate algorithms, iss, and aud in jwt.verify, and ensure token expiration (exp) checks are enforced.

Watch Video