Who can see what: getting permissions right
Day 13 of our web security series: the difference between logging in and being allowed, and the simple rules that stop users from seeing each other's data.
So far this week has been about one question: is this really you? We’ve stored passwords safely, slowed down guessing, protected the session, fixed password resets and added passkeys. All of that is authentication: proving who someone is.
Today is about the question that comes straight after: now that we know who you are, what are you allowed to do? That’s authorization, and it’s where a surprising number of real data leaks happen. A site can have perfect logins and still show one customer’s invoices to another.
Two different questions
A simple way to keep them apart:
- Authentication is the guard at the front door checking your ID.
- Authorization is every locked room inside the building. Getting through the front door doesn’t mean you can walk into the server room.
Most sites get the front door right, because login pages are obvious and well understood. The rooms inside are easier to forget, because there are hundreds of them: every page, every button, every API request that reads or changes something.
Why it matters for security
When authorization goes wrong, the attacker doesn’t need to break anything. They log in with their own, perfectly legitimate account and then simply ask for something that isn’t theirs. To the server it looks like normal traffic.
This is why broken access control sits at the very top of the OWASP Top 10, the industry’s list of the most serious web application risks. We’ll look at it from OWASP’s angle on Day 16. Today is about the habits that prevent it in the first place.
The classic mistake: trusting the ID in the request
Imagine an online shop where your order page lives at:
https://shop.example/orders/10452
What happens if a logged-in customer changes that number to 10453? On a well-built site, they get an error, because order 10453 belongs to someone else. On a badly built site, they see a stranger’s name, address and purchase history.
The mistake is that the server checked “is this person logged in?” but never checked “does this order belong to this person?” Remember Day 2: everything in a request can be changed by the person sending it, including IDs in the address, form fields and API calls.
The fix is a rule simple enough to write on a sticky note: for every request, check that this user is allowed to touch this specific thing. Not just that they’re logged in, and not just that they have the right role, but that this record is theirs or has been shared with them.
Hiding the button isn’t a lock
Another common trap is relying on the interface. The admin menu is only shown to admins, so ordinary users can’t reach the admin pages, right?
Wrong. Hiding a button changes what people see, not what the server allows. Anyone can type an address directly or send a request with a script. If /admin/users/delete doesn’t check permissions on the server, hiding the link protects nothing.
Every permission check must happen on the server, on every request. The interface can hide things to keep it tidy, but it is never the lock.
Rules that keep permissions sane
Deny by default
New pages and API endpoints should start out closed and be opened deliberately, not the other way round. If a developer forgets to add a check, the result should be “access denied”, not “access for everyone”. Many frameworks let you require login and permission checks globally, with explicit exceptions for public pages.
One place for the rules
When permission checks are scattered across hundreds of pages, some will be missed or written slightly differently. Put the rules in one shared place, a policy module or middleware your framework provides, and call it everywhere. It’s easier to review, test and fix.
Least privilege
Give every person and every system only the access it actually needs:
- A support agent who answers questions may need to see orders but not refund them.
- A reporting tool needs read access to the database, not the ability to delete tables.
- A temporary contractor’s account should expire when the contract does.
When something does go wrong, a narrow account can only do narrow damage.
Keep roles simple
Start with a few clear roles (for example, member, editor and admin) and write down what each one can do. Dozens of overlapping roles and one-off exceptions become impossible to reason about, and that’s where gaps hide.
Protect the powerful actions
Changing someone’s role, exporting all customer data, deleting accounts and editing payment details deserve extra care: ask the user to confirm their identity again, require a strong second factor (Day 12), and log who did what and when.
Watch out for the quiet leaks
Permissions aren’t only about pages. Data also leaks through side doors:
- API responses that return too much. A profile endpoint that sends the user’s full record, including fields the page doesn’t show, still leaks them to anyone who looks.
- Shareable links. “Anyone with the link” is convenient, but links get forwarded. Use long, unguessable links, let owners revoke them, and consider expiry dates.
- Files in storage. Uploaded documents in a public storage bucket are readable by anyone who finds the address, whatever the app’s permissions say.
- Search and exports. A search box or CSV export that forgets to filter by owner can return everyone’s data at once.
Test it like a curious user
You don’t need special tools to catch the most common problems:
- Create two ordinary test accounts, A and B.
- As A, create something private: an order, a document, a message. Note its address.
- Log in as B and open that same address. You should get “not found” or “access denied”.
- As an ordinary user, try typing the address of an admin page directly.
If either test shows data it shouldn’t, you’ve found a real bug, and you found it before an attacker did. Make these checks part of your regular testing, ideally as automated tests that run on every change.
What you can do today
If you use websites:
- Review which apps and people have access to your accounts, such as connected apps in Google, Microsoft or social media settings, and remove what you no longer use.
- Check shared folders and documents. Turn “anyone with the link” sharing off for anything personal.
- If you ever see someone else’s information on a site, report it to the company. It’s a sign of a permissions bug that may affect your data too.
If you run a website:
- Check ownership on the server for every request that reads or changes a record, not just login status.
- Make new routes deny by default, and keep permission rules in one shared place.
- Give staff, tools and services the least access they need, and remove access when people leave.
- Run the two-account test above on your most important pages, and turn it into automated tests.
- Read the OWASP Authorization Cheat Sheet for more detail.
Coming up next
Tomorrow is Day 14, the end of week two. We’ll turn everything from logins and accounts into an account security checklist, and add it to the website security checklist from Day 7.