Complete Mediation and Access Checks
What you'll learn: Why you must verify authorization on every single access attempt, not just once.
The Danger of "Check Once and Forget"
Imagine a nightclub bouncer who checks your ID at the door, then lets you roam freely—including into the VIP area, staff rooms, and cash office. That's what happens when applications check permissions once and assume they'll stay valid forever.
Complete mediation means every access to a protected resource must be authorized, every time. Never cache authorization decisions or assume that because a user was allowed five seconds ago, they're still allowed now.
Why This Matters
When you skip repeated checks, attackers can:
- Session hijack: Steal a valid session token and access resources the original user could
- Privilege escalation: Get promoted or demoted in the system, but cached permissions don't reflect the change
- TOCTOU attacks: Exploit race conditions where permissions change between check and use (Time-of-Check-Time-of-Use)
- Context manipulation: Change URL parameters or API calls to access resources they shouldn't, bypassing the single initial check
The Right Approach
Before accessing any sensitive resource:
- Check if the current user has permission to perform this specific action on this specific resource
- Don't trust that a previous check is still valid
- Don't assume URL structure implies authorization
- Re-verify permissions even within the same request if accessing multiple resources
Think of it like a secure building where your badge is checked at every door, not just the entrance. Your credentials might be valid, but you still need proper authorization for each room.
Key Takeaway: Verify authorization at every access point—never assume past permission checks guarantee current access rights.