Hiding an admin page is not the same as protecting it
An admin page lets someone change things: delete users, issue refunds, edit content. The usual way to protect it is to hide the link and redirect anyone who is not an admin. That feels like protection, but it only changes what the browser shows. It does not stop anyone from talking to your server directly.
Where the problem sits
Most apps have two layers:
- The page, which runs in the visitor's browser.
- The server or database, which holds the data and does the real work.
A check in the page, such as "if the user is not an admin, redirect to the home page", can be skipped. The visitor controls their browser. They can open the address directly, turn off scripts, edit the code, or ignore the page and send the same requests it would send.
Only a check on the server can be trusted. On every request, the server has to ask: who is this, and are they allowed to do this?
Signs your admin area is only hidden
- The admin link is missing from the menu, but
/adminloads for anyone who types it. - The page shows an error or a login prompt, but the data behind it loads in the background first.
- Admin actions such as delete or update call an API that does not check who is calling.
- The page decides who is an admin from a value stored in the browser, which the visitor can edit.
- Access rules in your database are off, so any signed-in user, or any visitor, can read and write every table.
Step 1: Try common admin addresses
In a private browser window, visit these on your live site:
/admin
/dashboard
/admin/users
/manage
/api/admin
If you see admin content without signing in, it is open. If you see a login page, go on to the next step: a login page on its own is not proof that the data behind it is protected.
Step 2: Call the API without signing in
Open the browser's developer tools on your admin page, go to the Network tab and find the requests it makes when it loads data. Copy one as a curl command, remove the login headers and cookies, and run it.
curl -i https://yourdomain.com/api/admin/users
You want a 401 (not signed in) or a 403 (not allowed). A 200 with data means the server is not checking.
Then run a second test. Sign in as a normal user, not an admin, and repeat the request with that user's token. A normal user should get a 403.
Step 3: Check on the server, every time
For each admin route on your server:
- Read who is calling from a trusted source, such as a verified session or token, never from a plain value the browser sends.
- Look up the person's role on the server side, in your own database.
- Refuse the request with a
403unless the role allows it.
Put the check in one shared function that every admin route uses, so a new route cannot forget it.
If you use a database service with access rules, such as row level security, turn the rules on for every table and write rules that depend on the signed-in user. A rule that lets everyone through is the same as no rule.
Step 4: Keep the admin address boring
An unusual address is a fine extra, but never the only protection: scanners guess common paths and search engines follow links. Add noindex to admin pages so they stay out of search results, and keep the real checks on the server.
What to do today
- Visit the common admin addresses in a private window.
- Copy an admin API request and run it without signing in. Expect a
401or403. - Repeat it as a normal user. Expect a
403. - Add a role check to every admin route on the server, in one shared function.
- Turn on database access rules for every table and test them with a normal account.
Check your own site
Attack Shield looks for these mistakes on your website and shows how to fix each one.
Scan your site