Fix it in your stack

Tested fixes for the weaknesses A01:2025 maps, in Express, Flask, Spring Boot, ASP.NET Core, Next.js, FastAPI, Django, net/http, Rails and Laravel: the vulnerable code, the fix, a wrong fix and the regression tests.

Why it matters

Access-control failures expose other users’ data and privileged functions directly. The category has been first in the Top 10 since 2021, and in 2025 it also absorbed server-side request forgery.

How to prevent it

  • Deny by default, except for intentionally public resources, and enforce access control in trusted server-side code.
  • Implement access control once and reuse it everywhere, checking ownership of each record rather than only whether a user is signed in.
  • Disable directory listings, keep metadata and backup files out of web roots, and rate-limit API access to slow automated probing.
  • Log access-control failures and alert on repeats; invalidate sessions at logout and keep tokens short-lived.
  • For SSRF, allowlist outbound destinations and segment the network so the server cannot reach internal services it does not need.

Guides on this site

Main subject · Guide

Enforce authorization for every object action

Authorize the authenticated subject, requested operation, and specific resource together; a valid login or unpredictable identifier is insufficient.

Main subject · Guide

Authorize functions and fields as well as objects

Prevent mass assignment, sensitive-field exposure and administrative actions that a valid object lookup alone cannot protect.

Main subject · Guide

Authorization models: RBAC, ABAC, ReBAC and policy as code you can test

Translate roles, attributes and relationships into explicit subject-action-resource decisions, prevent broken object level authorization (BOLA), and verify ownership and tenant boundaries with tests.

Main subject · Guide

Protect cookie-authenticated actions against CSRF

Make the server distinguish an intended action from a request another site caused the browser to send.

Main subject · Guide

Constrain server-side fetches to their intended destinations

Prevent untrusted URLs from turning a preview, import, or webhook feature into access to internal services.

Main subject · Guide

Extract archives without escaping the destination

Prevent traversal, link tricks, overwrites and decompression exhaustion while preserving legitimate file extraction.

Main subject · Guide

Redirect users only to destinations you control

Check every redirect target taken from a request, so attackers cannot borrow your domain for phishing, carry OAuth tokens off-site or steer a server-side fetcher through your redirects.

Also covers this · Guide

Review tenant boundaries before implementation

Trace tenant identity through requests, data stores, caches, jobs, and administration, then turn plausible isolation failures into tests.

Also covers this · Guide

Review trust boundaries in mobile and native clients

Protect local data and platform interactions while keeping server-side authorization independent of the client’s behavior.

Also covers this · Guide

Authenticate workloads and authorize their service actions

Use service identities, mutual TLS and function permissions without mistaking an encrypted connection for complete authorization.

Also covers this · Guide

Keep retrieval inside the user’s data boundary

Carry document permissions through ingestion, retrieval, caching and citations so a model never receives another tenant’s records.

Also covers this · Guide

SCIM deprovisioning: make account disablement remove every usable authority

Connect SCIM resource updates to current sessions, tokens, group-derived permissions and background jobs, with explicit tenant mapping, CAEP revocation events and a measurable revocation contract.

Also covers this · Guide

Prevent shared-cache poisoning and private-response deception

Define lookup and storage policy, trace cache/origin interpretation differences and verify both public reuse and private isolation.

Also covers this · Guide

Maintain an API inventory and prevent gateway bypass

Connect documented routes, deployed listeners and backend trust so retired or direct paths do not bypass the intended controls.

Also covers this · Guide

Configure CORS and CSP around the browser capabilities you need

Control who can read API responses and which resources a page may execute without confusing either control with authorization.

Also covers this · Guide

Preserve framework security controls across the request lifecycle

Trace middleware, persistence and rendering so custom code does not bypass the protections supplied by the framework.

Also covers this · Guide

Review a code change through its trust boundaries

Turn a pull request into a small set of security claims that can be checked against the surrounding system and tests.

Also covers this · Guide

Defend OAuth and OIDC against redirect and token attacks

Apply RFC 9700 and RFC 10017: exact redirect matching, PKCE with downgrade protection, state and iss binding, refresh-token rotation, sender-constrained tokens, and a backend-for-frontend so browser tokens cannot be stolen.

Also covers this · Guide

Prevent file inclusion: LFI, RFI, dynamic imports and template names

Stop request data from choosing which file, module or template your application loads: local and remote file inclusion in PHP, dynamic require() and import() in Node.js, importlib and template names in Python, Thymeleaf view names in Spring, render in Rails, and the allowlist fix that works in all of them.

Also covers this · Guide

Create temporary files safely: mkstemp, O_EXCL and private directories

Stop symlink, hardlink and pre-created-file attacks on the temporary files your code writes in shared directories such as /tmp: create each file atomically with O_EXCL and owner-only permissions through mkstemp or its equivalent in shell, Python, Java, Node.js, Go, .NET and Rust, keep related files in a private directory, and treat the Linux protected_* sysctls and systemd PrivateTmp as a backstop.

Also covers this · Reference

Secure design patterns: a catalogue for insecure-design (A06)

A catalogue of reusable secure-design patterns, grouped by concern, each with when to use it, a short example and the failure it prevents: choke-point authorization, capability tokens, parse-don't-validate, safe-by-default APIs, tenant scoping, fail-closed, idempotency, and more.

Practice

References

  1. A01:2025 Broken Access Control (OWASP)

List data from the publisher. A guide is listed as the main subject when the weakness or risk is what the guide is about, and as covering it when a dedicated section or worked example addresses it.