HomeTopicsA01 Broken Access Control
Lesson 1 / 10

A01: Broken Access Control

Access control enforces policy such that users cannot act outside of their intended permissions. Failures lead to unauthorized information disclosure, modification, or destruction of data.

Key Vulnerabilities

1

Violation of the principle of least privilege — access should be deny-by-default

2

Bypassing access control by modifying URLs, internal state, or API requests

3

Insecure Direct Object References (IDOR) — accessing other users' data by guessing IDs

4

Missing access controls for POST, PUT, DELETE on APIs

5

Elevation of privilege — acting as admin without proper authorization

6

CORS misconfiguration allowing unauthorized API access

Prevention Strategies

Deny by default — except for public resources

Implement access control once, reuse throughout the app

Enforce record ownership in data models

Disable directory listing and remove metadata from web roots

Log access control failures and alert admins

Rate-limit API and controller access

Invalidate session tokens server-side on logout

Real-World Example

In 2019, a major US financial services company exposed 100 million customer records due to a misconfigured WAF that allowed SSRF attacks — a form of broken access control.

Code Comparison

Vulnerable Code
// VULNERABLE: Direct parameter access without authorization check
app.get('/api/account', (req, res) => {
  const accountId = req.query.acct;
  // No check if user owns this account!
  db.query('SELECT * FROM accounts WHERE id = ?', [accountId]);
});
// Attacker: /api/account?acct=someone_elses_id
Secure Code
// SECURE: Verify user owns the requested resource
app.get('/api/account', authenticate, (req, res) => {
  const accountId = req.query.acct;
  const userId = req.user.id;
  db.query(
    'SELECT * FROM accounts WHERE id = ? AND owner_id = ?',
    [accountId, userId]
  );
});