Fix it in your stack

Tested fixes for the weaknesses API1:2023 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

APIs expose object IDs in paths and request bodies, so swapping one ID for another is the simplest and most common way to read or change other users’ data.

How to prevent it

  • On every endpoint, check that the authenticated caller may perform the action on that specific object, using the identity from the session or token.
  • Scope data access by user and tenant in the query itself.
  • Use unpredictable IDs only as defense in depth, and test every object endpoint with two users.

Guides on this site

Practice

References

  1. API1:2023 Broken Object Level Authorization (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.