Security Guides

Authentication vs authorization: a login alone doesn't protect other users' data

Authentication (who) vs authorization (what you may do): a login without owner-scoped data means 'logged in = sees all data.' Why it happens and how to defend.

Published 2026-06-30 Updated 2026-10-06 9 min read
On this page

"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.

authn
Check "who" at login
authz
Control "who may see it" per record (scope by owner)
no authz
Everyone logged in sees all data
Authentication only checks identity at login. Without a separate per-record permission check (authorization), everyone who logs in can see all the data.

Authentication vs authorization at a glance

Authentication (AuthN)Authorization (AuthZ)
What it checksWho you areWhether this person may do this action on this data
WhenAt login (and when checking the session)On every request that reads or writes data
Typical meansPasswords, MFA, passkeysOwner scoping, role-based permissions, policies
HTTP status on failure401 Unauthorized403 Forbidden (or 404 to hide existence)
Related standardOpenID ConnectOAuth 2.0
OWASP Top 10:2025A07 Authentication FailuresA01 Broken Access Control (#1)
Typical incidentAccount takeover via a reused passwordChanging 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.

1

① 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.

2

② 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.

3

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

1

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.

2

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.

3

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.

4

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.

5

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.

1

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.

2

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.

3

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.

4

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.

Sources

FAQ

QHow are authentication and authorization different?
A

Authentication verifies who you are (login). Authorization decides what you may do (permissions). As an analogy, authentication is the ID check at the building entrance; authorization controls which rooms you may enter. Adding a login only implements authentication — authorization (who may touch which data) is something you must write separately. Conflate the two and you end up with 'everyone who logs in can see all the data.'

QThere's a login — so why can everyone see all the data?
A

Because the data query isn't narrowed to 'just the logged-in user's own rows.' Forget the owner (user_id) condition on any of list/read/update/delete, and once someone is logged in, all rows come back — including other people's. It's a design flaw independent of whether authentication exists, and it's the classic Broken Access Control that OWASP ranks number one.

QFor a personal tool or internal app, isn't leaving registration open fine?
A

It's dangerous. Many auth scaffolds ship with registration (e.g. /register) public by default. If a stranger knows the URL they can sign up, and with no authorization they can see the data straight away. Registration routes are sometimes duplicated (both the UI library and the auth package), so disabling one still leaves the other open. Disable registration you don't need, and layer defenses like IP restrictions on admin surfaces.

QIs OAuth authentication or authorization?
A

OAuth 2.0 is authorization. Its specification (RFC 6749) is literally titled 'The OAuth 2.0 Authorization Framework': it grants an app access to a defined scope of someone's data. For login (authentication) you use OpenID Connect (OIDC), which adds an identity layer on top of OAuth 2.0. Features like 'Sign in with Google' are normally built on OIDC.

QWhat's the difference between HTTP 401 and 403?
A

401 (Unauthorized) means the request wasn't applied because it lacks valid authentication credentials, so it's an authentication failure. 403 (Forbidden) means the server understood the request but refuses to fulfill it: the user may be logged in but lacks permission, which is an authorization failure (RFC 9110). If you don't want to reveal that someone else's resource exists, you can return 404 instead.

QWhat do AuthN and AuthZ stand for?
A

AuthN is authentication and AuthZ is authorization. Both words start with 'auth', so these short forms keep them apart. You'll see them often in design documents and library docs.