CWE-269OWASP A01:2021CWE-285CWE-862

CWE-269: Privilege Escalation

An application assigns, elevates, or fails to drop privileges so a user can act with more authority than their role allows.

Also known as: Privilege escalation, Improper privilege management, Broken role enforcement

Risk

Typically high to critical. A user who gains admin or elevated rights can read, change, or destroy data across the whole system, and the step up is often a single unchecked field or route.

Definition

What it is

CWE-269 occurs when an application manages privileges incorrectly: it grants more than a role needs, lets a user raise their own level, or does not drop elevated rights after a privileged step. The result is that a normal account can perform actions reserved for administrators or other higher roles. The flaw is in how roles and permissions are assigned and enforced, not in authentication. It often hides in a role field the client can set, an admin route with no role check, or a default that is too permissive.

Use-cases

How it shows up in real code

Self-assigned admin role

A sign-up or profile-update endpoint accepts a role field from the client. A normal user sets it to admin and gains full control of the application.

Unchecked admin route

An administrative endpoint confirms the caller is logged in but never checks their role. Any authenticated user can reach it and perform privileged actions.

Privilege not dropped

A background job runs as a superuser and then processes user-supplied input without lowering its rights, so a crafted request acts with full privilege.

Over-broad default role

New accounts are created with a manager role by default to simplify testing, and that default reaches production, giving every user elevated access.

AI risk

Why AI-generated code has increased the exposure

  • Assistants wire up role or permission fields to match the prompt but rarely add the server-side check that only an admin may change them, because the privilege model is context the model lacks.
  • The correct role hierarchy lives in a policy the model cannot see from a short prompt, so generated code often trusts a client-supplied role value.
  • Models optimize for code that runs, and the simplest working version grants broad privileges rather than the least needed.
  • Insecure patterns such as reading the role from the request body appear widely in training data and are reproduced as the default.
  • As the assistant scaffolds more privileged routes and admin features, each one is another place the role check can be omitted, and volume scales the exposure.

Vibe coding

How vibe coding amplifies the risk

  • Vibe coding ships role-handling code without reading it, so a client-settable role field is never noticed as dangerous.
  • During testing the developer uses a single admin account, so every privileged action succeeds and nothing looks broken.
  • Prompt-and-ship skips the review where someone would ask whether a normal user can reach this admin route.
  • A permissive default role added to speed up a prototype rides straight to production.
  • Rapid feature growth adds privileged endpoints faster than anyone audits each for a role check.

Detection

How to find it

  • List every privileged action and confirm the server checks the caller's role or permission before running it, not just that they are authenticated.
  • Search for role, isAdmin, or permission values that are read from the request body or query string rather than the server.
  • Review default roles assigned at account creation and confirm they grant the least privilege needed.
  • Test privileged endpoints with a low-privilege account and confirm each is refused.

Remediation

How to fix it

  • Enforce a server-side role or permission check on every privileged action, derived from the authenticated session.
  • Never accept a role or privilege level from client input; set it server-side under an existing admin's authority.
  • Grant the least privilege a role needs and drop elevated rights as soon as a privileged step completes.
  • Centralize privilege decisions in one authorization layer so every route is checked the same way.
  • Add tests that attempt each privileged action as a low-privilege user and fail the build if one succeeds.

Frequently asked questions

What is CWE-269 (privilege escalation)?
CWE-269 is improper privilege management: the application assigns, elevates, or fails to drop privileges so a user can act with more authority than their role should allow. It commonly appears as a client-settable role field or an admin route that checks only that the caller is logged in.
How have AI assistants and vibe coding increased privilege escalation risk?
Assistants generate role and permission handling that matches the prompt but omit the server-side check that only an admin may change a role, because the privilege model is context they lack. Vibe coding ships that code unread, and because the developer tests with a single admin account, the missing check stays invisible until a normal user escalates.
How do I fix privilege escalation?
Enforce a server-side role check on every privileged action, never take the role from client input, grant the least privilege needed and drop elevated rights promptly, and add tests that attempt privileged actions as a low-privilege user.

Related weaknesses

Catch CWE-269 before you ship

Tethlyn Audit scans your codebase and its git history for CWE-269 and the rest of the broken access control & authorization class, then ranks each finding by real exploitability and data sensitivity.

See Tethlyn Audit