Role-based access control (RBAC) is documented and enforced
Why it matters
PCI-DSS 4.0 Req 7.1 requires a formal model where access to system components is restricted on a need-to-know basis; Req 7.2 mandates that the access control model documents each user's required access level. Without RBAC, every authenticated user is implicitly authorized to access all data — a customer account can query transaction records for other customers, or a support agent can issue refunds. CWE-285 (Improper Authorization) and OWASP A01 (Broken Access Control) are the most exploited vulnerability class across web applications. NIST AC-2 requires that accounts are managed with assigned access rights enforced in code.
Severity rationale
High because missing or unenforced role separation means any authenticated user can access data or perform actions beyond their authorization scope, directly violating PCI-DSS 4.0 Req 7.2 and enabling horizontal privilege escalation.
Remediation
Define roles in a docs/rbac.md permissions matrix (minimum: admin, merchant, customer), then enforce them in middleware — not inline in each handler. Create a requireRole() helper in src/middleware/auth.ts that returns 403 before any business logic runs.
// src/middleware/auth.ts
export async function requireRole(supabase, requiredRoles: string[]) {
const { data: { user } } = await supabase.auth.getUser();
if (!user) return new Response('Unauthorized', { status: 401 });
const { data } = await supabase.from('user_profiles')
.select('role').eq('user_id', user.id).single();
if (!requiredRoles.includes(data.role))
return new Response('Forbidden', { status: 403 });
return null;
}
Apply it at the top of every API route that touches CDE data before any database query executes.
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 PCI Compliance Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- pci-dss:4.0 · Req 7.1 — Processes and mechanisms for restricting access to system components and cardholder data are defined and understood
- pci-dss:4.0 · Req 7.2 — Access to system components and data is appropriately defined and assigned
- cwe · CWE-285 — Improper Authorization
- owasp:2021 · A01 — Broken Access Control
- nist:rev5 · AC-2 — Account Management
Taxons
History
- 2026-04-18·v1.0.0·Initial import from ecommerce-pci·automated