CHAPTER 10
Authentication and Access Control Security
Updated: May 15, 2026
25 min read
# CHAPTER 10
Authentication and Access Control Security
1. Introduction
If SQL Injection is breaking through the vault wall, and XSS is stealing a customer's wallet in the lobby, Authentication and Access Control vulnerabilities are simply walking through the front door because the guard handed you the master key. Authentication verifies *who* you are; Access Control (Authorization) determines *what* you are allowed to do. Flaws in these systems are rampant, consistently occupying the #1 spot on the OWASP Top 10 (Broken Access Control). In this chapter, we will explore how attackers bypass login portals, hijack active sessions, and exploit poorly configured permission structures to escalate their privileges from standard users to full administrators.2. Learning Objectives
By the end of this chapter, you will be able to:- Differentiate between Authentication (Identity) and Authorization (Access Control).
- Understand the mechanics of Session Management (Cookies and Tokens).
- Identify Insecure Direct Object Reference (IDOR) vulnerabilities.
- Understand the concepts of Horizontal and Vertical Privilege Escalation.
- Apply the Principle of Least Privilege and Role-Based Access Control (RBAC).
3. Beginner-Friendly Explanation
Imagine a high-security office building.- Authentication (Who are you?): You walk up to the front desk, show your ID, and type a PIN. The guard verifies you are "Bob" and hands you a blue badge.
- Session Management (Remembering you): You don't have to show your ID at every single hallway. You just wear the blue badge. As long as you have the badge, the building remembers you are Bob.
- Authorization/Access Control (What can you do?): Bob tries to open the "Server Room" door. The door reads the blue badge and says, "Access Denied. Only red badges (Admins) can enter here."
If a hacker steals Bob's blue badge, that's a Session Management failure. If Bob figures out he can just push the Server Room door hard enough to bypass the lock, that's Broken Access Control.
4. Session Management Vulnerabilities
HTTP is a "stateless" protocol. It has no memory. To keep users logged in, servers issue a Session ID (usually a Cookie). Vulnerabilities:-
Predictable Session IDs: If the server assigns User 1 the Session ID
001, and User 2 the ID002, an attacker can just guess that Session ID003belongs to the next user, hijack it, and become them. Session IDs must be long, cryptographically random, and impossible to guess.
- Session Fixation: An attacker tricks a victim into logging in using a Session ID the attacker generated. The attacker now knows the active Session ID and hijacks the account.
5. Broken Access Control (Privilege Escalation)
Once logged in, can a user access things they shouldn't?-
Horizontal Privilege Escalation (IDOR): Bob logs into his bank account and the URL says
bank.com/account?id=100. Bob changes the URL toid=101. The server fails to check if Bob *owns* account 101. It blindly returns Alice's financial data. This is an Insecure Direct Object Reference (IDOR).
-
Vertical Privilege Escalation: Bob (a standard user) discovers the URL
company.com/admin_panel. The developers hid the link, but forgot to put an authorization check on the actual page. Bob accesses the admin panel and deletes the database.
6. Mini Project: Harden Demo Authentication System
Let's conceptualize fixing an IDOR vulnerability. The defense relies on strict, server-side authorization checks on *every single request*.Step-by-Step Architecture Concept (Secure Remediation):
php
php
7. Real-World Scenarios
A popular social media application had an API endpoint for deleting photos:api.app.com/deletephoto?photoid=555. A penetration tester created two accounts. They uploaded a photo on Account A (photoid=555). They logged into Account B, and sent a request to delete photoid=555. The server successfully deleted the photo. Because the server failed to verify that Account B actually owned the photo, the tester wrote a script that looped through numbers 1 to 1,000,000, deleting every single photograph on the entire social media platform in minutes. This catastrophic IDOR vulnerability was caused by a missing 3-line authorization check.
8. Best Practices
-
Role-Based Access Control (RBAC): Do not hardcode permissions based on usernames (e.g.,
if user == 'adminbob'). Assign users to Roles (e.g.,Moderator,Viewer). Assign permissions to Roles. Check the Role at every access point. This ensures scalable, centralized security management.
-
Deny by Default: If a web page does not explicitly say a user is allowed to view it, the server must default to
HTTP 403 Forbidden.
9. Security Recommendations
- Multi-Factor Authentication (MFA/2FA): Passwords will be stolen, guessed, or leaked in third-party breaches. MFA is the most effective defense against stolen credentials. By requiring a secondary token (like a Time-based One-Time Password from Google Authenticator), an attacker who steals a password still cannot authenticate to the application.
10. Troubleshooting Tips
-
Hidden UI vs. Real Security: Developers often try to secure admin panels by simply removing the "Admin Dashboard" button from the menu for standard users. This provides zero security. An attacker uses a proxy or directory brute-forcing tool to find
/admindashboard.phpand accesses it directly. Security must be enforced on the backend server execution, not just by hiding front-end UI elements.
11. Exercises
- 1. Explain the operational difference between Authentication and Authorization.
- 2. What is an Insecure Direct Object Reference (IDOR), and how does it facilitate Horizontal Privilege Escalation?
12. FAQs
Q: How long should a Session Cookie last? A: It depends on the application's risk profile. A banking application should invalidate (destroy) the session cookie after 15 minutes of inactivity. A social media app might keep the session alive for 30 days. However, all applications must destroy the session securely on the backend the moment the user clicks "Log Out."13. Interview Questions
- Q: Describe the mechanics of a Vertical Privilege Escalation attack. Why is relying on front-end UI obfuscation (hiding links) an insufficient defense against this vulnerability?
- Q: Explain the necessity of implementing Role-Based Access Control (RBAC). How does enforcing server-side ownership validation prevent Insecure Direct Object Reference (IDOR) attacks?