Blog / A01:2021 Broken Access Control
A01:2021 · Broken Access Control

The role came from a claim the caller controlled

You copy authorities out of an identity token and into the request's permission set. If any of those values are attacker-reachable, so is admin.

Login returnsclaims or…Code readsauthority…Each value isprefixed…Roles enter therequest's…Downstream checksgrant access…ATTACKER INPUTIMPACTcheck absent
Attack path · Login returns claims or profile attributes → Code reads authority values from those claims → Each value is prefixed and turned into a role → Roles enter the request's permission set → Downstream checks grant access on them

You copy authorities out of an identity token and into the request's permission set. If any of those values are attacker-reachable, so is admin.

What goes wrong

After login, you build the caller's permissions by reading a list of authority strings, prefixing each one, and dropping them into the request's permission set. Whatever is in that list becomes a role or a scope your access checks will honor a moment later.

The question nobody asked: where does the list come from? If it is populated from identity-provider claims or profile attributes, some of those values can be influenced by the user or by a provider you do not fully control. Nothing validates them against a known set of roles. An attacker who can shape a claim can name the exact administrative role your system checks for, and it lands in the permission set with no objection.

There is no injection trick here and no memory bug. You asked the token what it was allowed to do, and you believed the answer.

The pattern

Vulnerable
authorities = []
for name in claims.get('authorities'):   # from the token
    authorities.append(Role('ROLE_' + name))
context.setAuthorities(authorities)       # now trusted
# later:
if context.hasRole('ROLE_ADMIN'):
    allow()
Hardened
ALLOWED = {'reader', 'editor', 'auditor'}
roles = rolesForSubject(subject)     # your store, not the token
authorities = []
for name in roles:
    if name not in ALLOWED:
        continue                     # never invent a role
    authorities.append(Role('ROLE_' + name))
context.setAuthorities(authorities)
How the pipeline adjudicated itHELD
ABCDEFGH

Grounding and reachability were confirmed. The exploit-path gate would not conclude without the calling code, so the finding was held and an evidence request was raised instead of being reported as fact.

Ed25519 · per-tenant signing key · gate ledger A–H · verify offline against the published payload hash

Why it matters to you

Federated login makes this easy to get wrong. The token feels trustworthy because it is signed, but a signature proves who issued the claim, not that the claim should grant power in your system. Role mapping is your decision, and it belongs on your side of the boundary.

If an attacker can register attributes, influence a directory sync, or use a weakly governed provider, unvalidated authority mapping is a direct path to privilege escalation. Map external identity to internal roles through an allowlist you own, and never let the caller name the role.

Check your own code