Course contentsShow
← Security
Lesson 1022 of 3,05221. Web Security - API SecurityFree lesson

Horizontal and Vertical Privilege Escalation

Exploiting authorization flaws to access peers' data or elevate to administrative functions in APIs.

Horizontal and Vertical Privilege Escalation

What you'll learn: How attackers exploit authorization flaws to access other users' data or gain administrative privileges in APIs.

The Core Concept

When authorization checks fail in APIs, attackers can escalate their privileges in two distinct directions:

Horizontal Privilege Escalation occurs when a user accesses resources belonging to another user at the same privilege level. Think of it like a hotel guest using their keycard to open another guest's room—same level of access, wrong target.

Vertical Privilege Escalation happens when a user gains access to higher-level functions or administrative capabilities they shouldn't have. This is like a hotel guest somehow accessing the master key system to control all rooms.

Real-World Examples

Horizontal escalation:

GET /api/users/456/orders
Authorization: Bearer user_123_token

User 123 shouldn't see user 456's orders, but weak authorization allows it. The attacker simply changes the user ID parameter.

Vertical escalation:

POST /api/admin/delete-user
Authorization: Bearer regular_user_token

A regular user calls an admin-only endpoint. If the API only checks authentication (is someone logged in?) but not authorization (does this user have permission?), the attack succeeds.

Why This Happens

These vulnerabilities stem from:

  • Missing authorization checks on endpoints
  • Only validating authentication, not permission levels
  • Relying on client-side access controls
  • Not checking resource ownership before operations

Detection Strategy

Test by manipulating identifiers and attempting privileged actions with low-privilege credentials while monitoring responses for successful unauthorized access.

Key Takeaway: Horizontal escalation lets attackers access peers' data by manipulating identifiers, while vertical escalation grants administrative functions—both exploit missing or weak authorization enforcement at the API layer.