TL;DR
AI editors add a login check to your API routes but skip the ownership check, so any logged-in user can read another user's data by changing the ID in the URL (CWE-639, IDOR).
It happens because tutorials treat "authenticated" as if it means "authorized," and the AI learned from those tutorials.
The fix is one line: scope every lookup to the current user instead of trusting a raw ID from the request.
I asked Cursor to build an endpoint that returns an invoice by ID. It gave me clean code. Auth middleware on the route, a database lookup, a JSON response. It ran on the first try.






