From the blog

Role-Based Access Control Testing: When "Admin" and "Member" Share More Than They Should

A QA engineer logs in as a Member, the lowest-privilege role in the product, and confirms the admin-only "Manage Billing" button is correctly missing from the navigation. Test passes. What never…

Palak BhanushaliSecurity research17 Nov 20268 min read

A QA engineer logs in as a Member, the lowest-privilege role in the product, and confirms the admin-only "Manage Billing" button is correctly missing from the navigation. Test passes. What never gets tried is calling the billing endpoint directly, the same request an admin's browser would send, just with the Member account's own valid token attached. When someone eventually does exactly that, out of curiosity or worse, the endpoint responds with a full billing record and processes the request without complaint, because nothing on the server ever asked what role made the call. The button was missing. The permission was not.

This is the specific gap role-based access control testing exists to close, and it's a different gap than the one most authorization testing already covers.

A Different Question Than Object-Level Authorization

Testing whether one user can access another user's specific record, order 4821, invoice 991, is object-level authorization, often shortened to BOLA or IDOR. It answers "can this account see this particular thing."

Role-based access control testing answers a related but distinct question: "is this account's role allowed to perform this category of action at all," independent of which specific record is involved. A Member account trying to view another Member's invoice is an object-level problem. A Member account trying to call an admin-only endpoint, promote a user, change billing settings, delete another account, is a role-level problem, and it exists even if the Member account is only ever touching resources that genuinely belong to its own tenant.

Both gaps come from the same root cause: authentication confirms who is making the request, but authorization, both object-level and role-level, has to be checked separately and explicitly. A system can authenticate perfectly and still let a low-privilege role reach high-privilege functionality, because nothing about having a valid session says anything about which actions that session is entitled to perform.

Why Hiding the Button Doesn't Count

Frontend applications routinely hide admin controls from non-admin users, which is good practice for usability, nobody wants a Member staring at buttons that will only reject them. The mistake is treating that hidden button as the access control itself. The frontend's job is to present a clean interface for the role a user actually has. The backend's job is to independently refuse any request that role isn't entitled to make, regardless of how the request was constructed or what client sent it.

A test suite that only ever interacts with the application through its UI will never catch this gap, because the UI was specifically built not to offer the forbidden action in the first place. The only way to test whether the restriction is real is to bypass the UI and call the endpoint directly with a lower-privileged account's credentials.

Where Role Checks Actually Go Missing

Checked at the route level, not the endpoint level. A common pattern is guarding entire page routes based on role, /admin/* redirects non-admins, while the individual API endpoints those pages call have no equivalent check of their own. The route guard protects the page. It does nothing for a request sent directly to the API.

Checked in the list view, not the detail action. An admin dashboard's list of users might correctly filter what a Member sees, but the underlying "promote user," "suspend account," or "reset password" action endpoints, reached by ID, often go untested because nobody constructs a request to them outside the context of a UI element that was never rendered for that role in the first place.

Role elevation through a writable field. A profile update endpoint that accepts a role field in its request body, intended only to be set by an admin creating a new user, can sometimes be called by the user being updated, submitting their own role change alongside an otherwise ordinary profile edit. This is role-based access control failing through mass assignment rather than through a missing route check, and it's one of the more serious variants, since it lets an account escalate its own privileges rather than just reach functionality meant for a different role.

Role matrix drift as the product grows. A product that launches with two roles, Admin and Member, and later adds a third, Billing Manager, or a fourth, Viewer, often accumulates new endpoints faster than the authorization logic for every existing endpoint gets revisited. A check written for "is this an Admin" doesn't automatically account for a new role that should also be restricted from that same action, and a check written as "is this NOT a Member" can silently allow a brand new, even lower-privileged role through, since it was never part of the original either/or logic.

Building a Role Matrix as the Actual Test Plan

The most reliable way to test this systematically is to build an explicit matrix before writing a single test: every role down one side, every sensitive action across the other, with each cell marked allowed or denied. This turns an open-ended "test the permissions" task into a concrete, finite list of request-and-account combinations to actually send.

ActionAdminBilling ManagerMemberViewer
View billingAllowAllowDenyDeny
Change billing planAllowAllowDenyDeny
Promote a user to AdminAllowDenyDenyDeny
Create a projectAllowDenyAllowDeny
View a projectAllowDenyAllowAllow

A matrix like this is also what actually catches role-drift, since adding a new role or a new action means adding a new row or column, and a cell left unfilled is itself a visible gap in the review rather than an implicit assumption nobody wrote down.

The Core Test Pattern

test('member cannot promote another user to admin', async ({ request }) => {
  const member = await loginAs('[email protected]');

  const res = await request.post('/api/users/promote', {
    headers: { Authorization: `Bearer ${member.token}` },
    data: { userId: 'target-user-id', role: 'admin' },
  });

  expect(res.status()).toBe(403);
});

test('member cannot set their own role via profile update', async ({ request }) => {
  const member = await loginAs('[email protected]');

  const res = await request.patch('/api/users/me', {
    headers: { Authorization: `Bearer ${member.token}` },
    data: { name: 'Updated Name', role: 'admin' },
  });

  const profile = await res.json();
  expect(profile.role).toBe('member'); // the role field must be ignored or rejected, not applied
});

The pattern repeats for every cell in the matrix marked "Deny": a valid, authenticated request from a specific role, aimed at a specific action, confirming the server refuses it rather than trusting that the UI would never have offered the option.

What's Different From Testing a Single Admin Account

A suite that only has one test account, usually an Admin, because that's the account with permission to do everything the tests need to verify, cannot catch any of this, structurally. Confirming an Admin can promote a user says nothing about whether a Member can. Role-based access control testing requires at minimum one authenticated account per distinct role, maintained as standard fixtures, the same way object-level authorization testing requires at least two accounts rather than one.

Frequently asked questions

BOLA and IDOR testing checks whether an account can access a specific record it doesn't own. RBAC testing checks whether an account's role is allowed to perform a category of action at all, independent of which record is involved. A product needs both; they catch different bugs.

Final Thoughts

The Member account that could reach a billing endpoint never did anything sophisticated to get there. It sent a normal, valid, authenticated request, the kind any role can send, to an endpoint that simply never asked whose role was attached. Testing role-based access control well means treating that question as something that has to be asked at every sensitive action, explicitly, for every role that isn't supposed to pass, rather than trusting that a button nobody can see is the same thing as a door nobody can open.

How FlawPilot helps

FlawPilot finds security and quality issues in your AI-built app and shows you how to fix them. It checks your deployed site across security, performance, infrastructure, and SEO, and scans your source code for vulnerabilities, hardcoded secrets, and vulnerable dependencies.

Every finding is prioritized and explained in plain English, with the actual fix: the configuration change, DNS record, security header, or code change needed. For supported findings, AI-powered guidance adds step-by-step instructions and suggested code fixes.

Connect your Git provider to scan your repository alongside your live site, so application findings, code vulnerabilities, secrets, and dependency issues all land in one place.

It fits your existing workflow too: a REST API for scores and findings, an embeddable security badge, and an MCP server so tools like Claude, Cursor, or ChatGPT can read your findings and help you work through them.

The boundaries are clear: the public website scan reads only publicly accessible signals, with no agent or credentials required, and source-code scanning is opt-in and read-only. Fixes are never applied or merged without your review.

RBAC TestingAccess ControlApplication SecurityAPI TestingQA TestingAuthorization

Verify your AI-generated app is production-ready.

117 security checks in 60 seconds - free, no account needed.

Scan one page

Enter a URL - no account, no install.

Run a Site Health check

Requires a free account

Crawls every page we can reach and scores each one, so a slow template deep in the site stops hiding behind a healthy homepage.

Scan your source code

Requires a free account

Connect a Git provider to check for vulnerabilities, secrets, and risky dependencies.