Skip to main content
LowClient-sideOWASP A01:2021CWE-602

How to fix: UI Visibility Gated by Client-Side Role Check Only

An element's visibility is toggled based on a client-side role/permission check (e.g. user.role === 'admin') with no indication the underlying action is also enforced server-side.

Why it matters

Any user can open devtools, flip the condition, or call the underlying API directly, bypassing a UI gate that isn't backed by a server-side authorization check.

Hiding an 'Admin' button when user.role !== 'admin' is fine for UX, but AI-scaffolded apps sometimes treat this as the entire access control mechanism and skip re-checking the role on the server endpoint the button calls.

How to fix it

  1. 1Treat every client-side role check as a UX convenience only, never as the authorization boundary.
  2. 2Re-validate the user's role/permission on the server for every state-changing request the gated UI can trigger.
  3. 3Add an authorization test that calls the underlying endpoint directly as a non-privileged user and asserts it is rejected.

Code examples

Server-side check is the real gate

TypeScript
// UI hides the button for non-admins (nice-to-have)
// but the endpoint MUST re-check on every request:
export async function DELETE(req: Request) {
  const session = await getSession(req);
  if (session?.role !== 'admin') return new Response('Forbidden', { status: 403 });
  // ...
}

References

Detected automatically by VulnRadar. The check id is cs-client-only-role-gate, stable across every scan so you can filter or diff on it.

See every client-side check

Questions

How severe is UI Visibility Gated by Client-Side Role Check Only?
VulnRadar rates this low severity in the client-side category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id cs-client-only-role-gate, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does UI Visibility Gated by Client-Side Role Check Only map to?
It maps to CWE-602. In the OWASP Top 10 it falls under A01:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for ui visibility gated by client-side role check only

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

UI Visibility Gated by Client-Side Role Check Only | VulnRadar