Vibe Code Guardian
← All posts

Client-Side Admin Checks in AI-Generated Code: Why Your Hidden Admin Page Isn't Protected

If the only thing keeping people out of your admin area is a browser check, there is nothing keeping them out. How to test your AI-built app's admin routes in ten minutes.

Aaron Allen·

A founder showed me their app recently. Users could log in, view their dashboard, all fine. Then they asked me how the admin page worked, the one where you can see every customer's orders. The answer was that you had to know the URL. Type /admin into the address bar and, if you were logged in, the page loaded. The data came from the same endpoints as everyone else's account. There was no server-side check at all.

That is not an unusual setup in apps built with AI coding tools. It is one of the most common gaps I see, and it is invisible until someone finds the URL.

Why the admin page isn't actually protected

When you ask Cursor or Lovable for an admin area, the tool builds you the interface and adds a route guard. The guard runs in the browser: it checks who you are, looks at your role, and hides the admin link if you are not an admin. Everything about that check happens on the user's own machine.

The browser is the attacker's machine. Anyone can open the developer tools, change a role field in local state, or just read the API calls the admin page makes and call them directly. If the server does not independently confirm "this request is from an admin", the guard is decoration.

The same problem appears in several shapes:

  • An admin page that is "hidden" because it is not linked anywhere.

  • A React component that redirects non-admins away, while the data fetch happens before or regardless of the redirect.

  • Custom API endpoints, added when you asked for a feature, that trust a user ID sent in the request body.

  • A Supabase client running with a service role key on the server, with no row-level security policy behind the custom endpoint that uses it.

Point three is the one that catches people who never built an admin area at all. Any endpoint you asked the AI to add that accepts a user ID as input is a candidate. Change the ID in the request and you may get someone else's data.

How to check your app in ten minutes

You do not need to be a security expert for this. You need a browser and a text editor.

1. List your admin and privileged pages. Write down every page a normal user should never see: admin dashboards, user management, anything that shows other people's data.

2. Open the admin page as a normal user. Log in with a regular account and type the admin URL in directly. If the page loads and then bounces you back, watch what happened. If you saw data flash before the redirect, or the redirect never came, the check is client-side only.

3. Look at what the page fetches. Open the network tab in the browser, load the admin page as an admin, and note the API calls. Then make the same calls as a normal user. If a regular account can call the admin endpoint and get a 200 with data back, you have a problem.

4. Search your codebase for endpoints that take a user ID. Grep for route handlers that read an id, userId or customerId from the request. For each one, ask: what stops me passing a different ID? In a Supabase app the answer should be row-level security. If the handler bypasses RLS with a service role key, the handler itself has to do the ownership check, and the AI frequently did not write one unless you asked for it.

5. Check the roles actually exist on the server. If your app has an "isAdmin" field, find out where it lives. If it is in a table that the user can write to through the app, or the client decides what the role is, the role is not real.

The fix, in plain terms

Every privileged request needs a check on the server, where the user cannot touch it. That means roles stored in the database, written only through paths users cannot reach, row-level security policies on every table, and custom server endpoints that verify the caller's role and data ownership themselves.

AI coding tools will do all of this if you ask explicitly. The pattern that fails is asking for the feature and not asking for the authorisation behind it. The tool built what you described: a page that admins can use. It did not build the server that refuses everyone else, because nobody said that part out loud.

Where else this same gap shows up

Client-side-only checks are one instance of a general problem: the app behaves correctly in the browser and never enforces anything on the server. The same roots cause users reading each other's records through normal app pages, actions open to everyone because the button was hidden but the endpoint wasn't, and webhook or internal endpoints that accept any request because they were built for the app to call, not the public.

If you have read this far and are now wondering about your own app, that instinct is worth acting on. Vibe Code Guardian runs a free surface check that flags exactly this kind of gap: the places where your app trusts the browser instead of the server. You run it yourself on your own code, and it points you at what to fix first. If you want a deeper pass, the launch-readiness audit goes through authorisation, data access and deployment one item at a time. Details on both are on the packages page.

The admin URL test takes two minutes. Most people who run it find at least one page that should not have loaded. Better you find it than a curious user.

Want a developer to look at your app?

Built your app with AI tools? Run the free surface check yourself in a few minutes. Nothing to buy, and we never look at your app unless you run it.