Security Glossary

Privilege Escalation

Privilege escalation is an attack where a user gains access to resources or capabilities beyond their authorized permission level, either by elevating to a higher role or accessing another user's resources at the same level.

Understanding Privilege Escalation

Privilege escalation comes in two forms. Vertical escalation means gaining a higher privilege level — a regular user becoming an admin. Horizontal escalation means accessing resources belonging to another user at the same privilege level — user A accessing user B's data.

Vertical escalation often exploits missing role checks on admin functionality. A common pattern is an application that hides admin navigation links from regular users but does not enforce role verification on the admin API endpoints. The admin panel's URL or API routes can be discovered through JavaScript source maps, documentation, or brute force. If the endpoints only check authentication (is the user logged in?) but not authorization (is the user an admin?), any authenticated user can perform admin actions.

Horizontal escalation is essentially IDOR — accessing another user's resources by manipulating identifiers. This is the more common form in modern web applications because role-based access control is more frequently implemented than resource-level access control.

Prevention requires implementing authorization at the middleware level so it cannot be accidentally omitted, following the principle of least privilege (users start with no access and are explicitly granted only what they need), maintaining role definitions in the backend (never trusting client-supplied role claims), regularly auditing access patterns to detect anomalies, and logging all privilege-changing operations.

Why This Matters for Vibe-Coded Apps

AI-generated admin interfaces are a major privilege escalation risk. The AI typically creates admin pages and hides them from the navigation for non-admin users, but the underlying API endpoints accept requests from any authenticated user. Admin functionality like user management, configuration changes, and data exports become accessible to regular users who discover the endpoints.

When your AI generates role-based features, verify that role checks happen at the API/server level, not just the UI level. Every admin endpoint should validate the user's role from the server-side session or JWT, not from a client-supplied value. In Next.js, use middleware or server-side checks in route handlers.

Real-World Examples

Windows Print Spooler Vulnerability (PrintNightmare, 2021)

A critical Windows vulnerability allowed any authenticated user to escalate to SYSTEM-level privileges by exploiting the Print Spooler service. The flaw was so severe that CISA issued an emergency directive requiring federal agencies to disable the service immediately.

sudo Baron Samedit (CVE-2021-3156)

A heap overflow in sudo, present for nearly 10 years, allowed any local user to escalate to root on Linux and macOS systems. The vulnerability affected virtually every Unix-like system running sudo, demonstrating how privilege escalation bugs can lurk undetected in critical system utilities.

Twitter Admin Panel Exposure (2020)

Social engineering of Twitter employees gave attackers access to an internal admin tool with the ability to take over any Twitter account. The attackers used this to post cryptocurrency scams from high-profile accounts including those of Elon Musk, Barack Obama, and Jeff Bezos.

Frequently Asked Questions

What is the difference between vertical and horizontal privilege escalation?

Vertical escalation means gaining a higher privilege level than assigned — a regular user performing admin actions. Horizontal escalation means accessing resources at the same privilege level but belonging to another user — user A viewing user B's private data. Vertical escalation is typically more severe because admin access often includes the ability to compromise all users, but horizontal escalation can expose sensitive personal data.

How do I prevent admin API privilege escalation?

Implement role-based middleware that checks the user's role before executing admin endpoints. Store roles server-side (in the database or JWT claims signed by the server) and never accept role information from the client. Apply the middleware to all admin routes in a single configuration point, so new admin endpoints are automatically protected. Test by calling admin endpoints with a regular user token to verify they are rejected.

Can JWT claims be used for privilege escalation?

If the server does not properly validate JWT signatures, an attacker could modify the role claim in a JWT (e.g., changing "role": "user" to "role": "admin") and gain elevated access. Always validate JWT signatures using a secure algorithm. For JWTs issued by your own system, the role in the token should match the role in your database. For third-party JWTs (like Supabase), the claims are set by the auth system and signed cryptographically.

Is hiding the admin URL sufficient protection?

No. Security through obscurity is never sufficient. Admin URLs can be discovered through JavaScript source maps, build artifacts, error messages, documentation, directory brute forcing, or simply guessing common paths like /admin, /dashboard, or /api/admin. Every admin endpoint must independently verify that the requesting user has the required role, regardless of how they discovered the endpoint.

Is Your App Protected?

VAS automatically scans for vulnerabilities related to privilege escalation and provides detailed remediation guidance. Our scanner targets issues common in AI-generated applications.

Scans from $5, results in minutes. Get actionable fixes tailored to your stack.

Get Starter Scan