"I added a login, so it's protected now" is a dangerous assumption. Login (authentication) and permissions (authorization) are different things, and mixing them up leads to an incident where everyone who logs in can see all the data, including other people's. No attack steps here — just how it happens and how to defend.
Authentication and authorization are different
They're easily conflated, but their roles are completely different.
Authentication only (the common mistake)
- thinking "can log in = safe"
- treating post-login data reads as the same for everyone
- result: everyone who logs in reaches all the data
Authentication + authorization (how it should be)
- authentication confirms "who"
- authorization limits to "only the data they may touch"
- data reads are always scoped to the owner
Authentication is "the ID check at the entrance"; authorization is "controlling which rooms you may enter." A login only guarantees the former. "Who may touch which data" is something you have to write separately.
Authentication vs authorization at a glance
| Authentication (AuthN) | Authorization (AuthZ) | |
|---|---|---|
| What it checks | Who you are | Whether this person may do this action on this data |
| When | At login (and when checking the session) | On every request that reads or writes data |
| Typical means | Passwords, MFA, passkeys | Owner scoping, role-based permissions, policies |
| HTTP status on failure | 401 Unauthorized | 403 Forbidden (or 404 to hide existence) |
| Related standard | OpenID Connect | OAuth 2.0 |
| OWASP Top 10:2025 | A07 Authentication Failures | A01 Broken Access Control (#1) |
| Typical incident | Account takeover via a reused password | Changing an ID shows someone else's data (IDOR) |
The HTTP names are confusing: 401 is called "Unauthorized" but actually means an authentication failure. When a user is logged in but lacks permission, return 403.
OAuth and OpenID Connect are another commonly confused pair. OAuth 2.0 is an authorization framework that decides what scope of access an app gets; it doesn't verify identity. For login features like "Sign in with Google," use OpenID Connect, which adds an identity layer on top of OAuth 2.0.
How "sees all data" happens in real apps
In the field, the same flaw turns up repeatedly across independent, self-built systems. A personal task/note app, or a small product/order-management system (with external API integrations) — the cause was the same overlap of two flaws.
① Registration is open (and on two routes)
Auth scaffolds (things like Laravel's Breeze/Jetstream) often ship with the registration page public by default. And when the registration route is duplicated across the UI library and the auth package, closing one still leaves /register. A stranger who knows the URL can sign up.
② Authentication exists but authorization doesn't (missing owner scope)
The data table has no owner column (user_id), or the list/read/update/delete queries aren't narrowed to the current user. Then "logged in = access to all data." If the app auto-logs-in right after sign-up, a stranger sees someone else's data list right after registering.
Result: the authn ≠ authz incident
There is a login (authentication), but no per-record permission check (authorization). Because the stranger behaves as "a properly logged-in user," there's barely even a trace of unauthorized access.
The damage is wider the more business data is involved (customer records, orders, integration API keys can all be affected). And a different system built the same way probably has the same flaw.
How to defend
Always scope data to the owner
Limit every read and write to "the logged-in user's own rows." Enforce the owner condition on all of read/update/delete via an ORM global scope or an authorization policy (policy/gate). If the table has no owner column, redesign that first.
Close registration you don't need — and suspect duplicated routes
Disable sign-up on personal/internal apps. Actually measure over HTTP that /register and the like return 404, and check both the UI-library and auth-package registration routes.
Defense-in-depth on admin surfaces
For internal/admin use, don't rely on authentication alone — layer IP restrictions, Basic auth, and the like. If one measure is bypassed, the next one stops it.
Keep audit and access logs before an incident
Without "who, when, from which IP, did what," you can't reconstruct "what was seen" after the fact. At minimum, keep login success/failure audit logs and retain/rotate web access logs.
Detect new sign-ups and anomalies
The core lesson here is "it went unnoticed for a long time." Add ways to notice fast — notifications on new user registration, periodic user/data stock-takes. With no detection, the flaw stays unnoticed.
How to check your own app
Check only apps you run, using test accounts you created. Trying this on someone else's service may count as unauthorized access, so don't.
Use two test accounts and try to open each other's data
Create one record as user A and note its URL or ID (e.g. /notes/123). Log in as user B, open the same URL, and confirm you get 403 or 404. Check list, detail, edit, delete and file download separately.
Check while logged out too
Log out, open the same URLs and APIs, and confirm you're sent to the login page or get 401. The page may be protected while the API behind it isn't.
Find where permission decisions are made
Hiding a button is not authorization. Confirm in the code that permission checks live on the server (controllers, policies, database queries). If you use JWTs, inspect one with the JWT decoder and confirm the server verifies the signature before trusting any permission claims.
Confirm registration is actually closed
Open any registration page you don't need (such as /register) and confirm it returns 404. Check both the UI library's route and the auth package's route.
Real examples: an authentication failure and an authorization failure
One typical case of each from this site:
- Authentication failure: in 7pay (2019), there was no two-step verification and password resets could be sent to an email address other than the registered one, which led to account takeovers. The mechanism for confirming "is this really the user" was weak.
- Authorization failure: CVE-2025-29927, covered in the Next.js vulnerability overview, allowed authorization checks done in middleware to be bypassed. Not relying on middleware alone, and checking again where data is fetched, limits the impact.
Stronger authentication doesn't close authorization gaps, and vice versa. Review each one separately.
This site's view: a library only guarantees 'who'
An auth library takes care of "who" — no further. "What that person may do" doesn't exist unless you, the designer, write it.
And a structural flaw found in one system is probably in other systems built the same way. Don't fix one and stop; audit the same-shape builds across the board. When you can't tell whether something was read, the correct posture is to treat it as read and revoke/rotate any exposed secrets.
Read next
- Example: CVE-2026-123218: IBM Aspera Faspex authorization bypass (administrator takeover)
- Glossary: what IDOR (broken access control) is (the classic: pass someone else's ID and reach their data)
- A case: the Lawson ID data breach (a mechanism meant to show users their own data was accessed without authorization, and how operators can check theirs)
- Apply it: security by framework (where to write authorization in each framework)
- Related: keep secrets out of public directories (checking token/credentials/.env exposure)
- Basics: protecting secrets, from scratch / basics: the minimum security checklist
Sources
- OWASP Top 10 (2021) A01: Broken Access Control: owasp.org
- OWASP Top 10:2025 A01 Broken Access Control: owasp.org / A07 Authentication Failures: owasp.org
- OWASP Authorization Cheat Sheet: cheatsheetseries.owasp.org
- RFC 9110, "HTTP Semantics", 15.5.2 (401) and 15.5.4 (403): rfc-editor.org
- RFC 6749, "The OAuth 2.0 Authorization Framework": rfc-editor.org
- OpenID Foundation, "OpenID Connect Core 1.0": openid.net
- In the wild: do Next.js and React have a lot of vulnerabilities? (middleware authorization bypasses keep shipping)