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
- 1Treat every client-side role check as a UX convenience only, never as the authorization boundary.
- 2Re-validate the user's role/permission on the server for every state-changing request the gated UI can trigger.
- 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
// 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.
More client-side checks
- HighCSP Allows 'unsafe-inline' Scripts
- MediumCSP Allows 'unsafe-eval'
- HighpostMessage Without Origin Validation
- HighSensitive Data Stored in localStorage
- HighDOM XSS via location.hash Assignment
- Highdocument.write() in Page Scripts
- Higheval() in Client-Side JavaScript
- MediumExternal Script Without Subresource Integrity
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.