Role Hierarchy Enforced
Why it matters
When roles are checked with exact string equality (role === 'member'), a higher-privilege user fails checks designed for lower-privilege users — they must be explicitly listed in every condition they should satisfy. This creates access gaps that worsen as the role model grows. An Admin denied access to a Member-gated feature is a support burden at best; an Admin who can bypass a Member-gated resource because the hierarchy isn't enforced is a CWE-284 / OWASP A01 violation at worst. NIST 800-53 AC-3 expects access enforcement to reflect the intended privilege model, not accidental exclusion through literal comparisons.
Severity rationale
High because exact-equality role checks produce both access gaps (Admins locked out) and privilege inversions (lower roles unexpectedly included) depending on how conditions are written.
Remediation
Replace exact role comparisons with a hasMinimumRole helper that encodes the hierarchy numerically. Once the rank table exists, every future role check becomes a single function call.
// lib/auth/roles.ts
const ROLE_RANK: Record<string, number> = { viewer: 1, member: 2, admin: 3 };
export function hasMinimumRole(user: { role: string }, required: string): boolean {
return (ROLE_RANK[user.role] ?? 0) >= (ROLE_RANK[required] ?? Infinity);
}
// Usage: if (!hasMinimumRole(user, 'member')) return forbidden();
Review all existing user.role === 'x' checks and replace with hasMinimumRole(user, 'x') wherever hierarchy applies.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Authorization Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-284 — Improper Access Control
- cwe · CWE-285 — Improper Authorization
- owasp:2021 · A01
- nist:rev5 · AC-3
- soc2:2017 · CC6.3 — Role-based access and least privilege
Taxons
History
- 2026-04-18·v1.0.0·Initial import from saas-authorization·automated
- 2026-07-06·v1.0.1·Add SOC 2 TSC mapping (CC6.3) from the verified compliance crosswalk register (docs/compliance/).·by soc2-mapping-enrichment-ship-2