← All tracks
FoundationsBroken Access Control10 labsFoundation → Intermediate → Advanced4h practice

Broken Access Control: The Door Next to the Login

Authentication is who. Authorization is what, where, and when.

“The login was perfect. The door next to it was open.”

CWE-284OWASP Top 10 A01:2021OWASP ASVS 4.1
The mental model
Every request needs two answers: who is calling, and may this caller perform this action on this object right now? A login page only answers the first.

Routes rely on hidden links, client-side role checks, or a single check at the entry point. The attacker requests the admin route directly, changes a cookie, uses a different HTTP method, or reaches an older API version.

We test the front door and forget the side doors. Attackers enumerate the building.

Threat model

What is actually at stake?

Before touching a payload, map the assets, the actors and the boundary that is supposed to protect them. A finding only becomes a vulnerability when you can connect the failed boundary to a real asset.

Assets

  • Administrative actions and configuration
  • Other users' data and privileged reports
  • Approval, refund and account-recovery workflows

Actors

  • Authenticated user with a normal role
  • Former employee with a still-valid session
  • Attacker who learns a hidden route or parameter

Trust boundaries

  • Route to role
  • UI state to server state
  • HTTP method to handler
  • Tenant or department scope
  • Break-glass and debug paths to production

Abuse cases

  • Request an admin route directly
  • Change a GET-only restriction by sending POST or PUT
  • Add a trusted header such as X-Admin or a debug flag
  • Use an older API version that lacks the new policy
PrerequisitesAuthentication versus authorizationHTTP verbs and route matchingRole-based access control basics
Request anatomy

Follow the decision, not the payload

Every family has a moment where trusted data becomes an authorization, parsing or state decision. Learn to point at that moment in the request path.

  1. 01

    Authenticate

    Identify the subject, session strength and any step-up requirements.

  2. 02

    Map the request

    Normalize the path, method, API version and action. Aliases and legacy routes must map to the same policy.

  3. 03

    Evaluate policy

    Decide function-level access, data scope and context in one place. Deny by default when no rule matches.

  4. 04

    Enforce

    Apply the decision at the server boundary, before side effects, and repeat it in background jobs that act on user intent.

  5. 05

    Audit

    Record the subject, action, object and decision. A denied request is a signal, not just a 403.

Case study

The admin console that trusted the client

Composite case study from public access-control disclosures
Context

A composite case drawn from common SaaS disclosures: the admin interface was hidden from normal users, but the underlying route accepted any authenticated session.

Discovery

A tester enumerated routes from JavaScript bundles and found an administrative export endpoint. The UI never linked it, but the handler checked only that a session existed.

Impact

A normal user could export customer records and change feature flags for the whole tenant. The missing control affected confidentiality and integrity at the same time.

Root cause

Authorization lived in the front end and in scattered route handlers. There was no central policy and no deny-by-default fallback.

Fix

Introduce a server-side policy layer keyed by action, enforce it in every route and job, remove debug bypasses, and add a role-by-route test matrix.

Read it as a chain: discovery → failed decision → impact → fix. Then ask which link would have broken earliest.

Attacker lens

A repeatable testing sequence

  1. Map roles, routes and API versions.
  2. Try admin and debug routes without the UI link.
  3. Change cookies, headers, methods and object IDs.
  4. Compare responses for normal users, admins and unauthenticated requests.

Where smart people get fooled

  • A hidden link is not a permission check.
  • A 401 on one route does not mean every route checks roles.
  • Client-side role checks are editable.
Detection engineering

What would the logs show?

A control is stronger when someone can see it fail. These signals are starting points for a detection rule, not a complete SIEM use case.

  • A low-privilege subject reaches an administrative action
  • 403 responses followed by a successful method change on the same path
  • Requests containing debug, impersonation or internal-admin headers
  • Access through deprecated API versions or alternate route aliases
  • Bulk exports initiated outside normal hours or from unusual clients
Starter query
index=web sourcetype=app_logs | eval privileged=if(match(action,"^(admin|export|refund|approve|impersonate)"),1,0) | where privileged=1 AND role!="admin" | stats count values(action) by user_id, path, method | where count > 0
The defender's move

Fix the decision, then prove it stays fixed

  • Deny by default and centralize policy checks.
  • Test every route, method and role, including legacy APIs.
  • Return 404 for objects the caller may not know about.
Vulnerable patterntypescript
if (user.role === "admin") {
  return adminHandler(request);
}
return new Response("Forbidden", { status: 403 });
Safer patterntypescript
const decision = policy.can(user, "customer.export", {
  tenantId: user.tenantId,
  scope: "tenant"
});
if (!decision.allowed) return deny(decision.reason);
return adminHandler(request);

Policy belongs on the server and should be called by every entry point, including jobs, webhooks and older API versions. Default to deny when the action is unknown.

Regression tests a reviewer would ask for

Function matrix

GivenA normal user, a manager and an admin

WhenEach role requests every privileged route and method

ThenOnly explicitly allowed combinations succeed; everything else is denied

Method tampering

GivenA route is protected for GET

WhenThe same path is called with POST, PUT, PATCH, DELETE and HEAD

ThenAll verbs receive the same policy decision

Legacy alias

GivenAn older API version or internal route exists

WhenThe normal user calls the alias directly

ThenThe alias resolves to the same policy and is not a bypass

Background action

GivenA queued job performs an action on behalf of a user

WhenThe job is replayed with a different user context

ThenThe job re-evaluates authorization and does not inherit stale privilege

False positives

What this finding is not

Strong testers kill their own findings before someone else does. These are the shortcuts that turn a real bug into a weak report — or a false alarm into a wasted escalation.

  • The admin button is hidden: hidden UI is not access control.
  • The route returns 403 for GET: test POST, PUT, PATCH and DELETE, plus the legacy API version.
  • A role claim exists in the token: the server must verify the claim and map it to a policy, not trust it blindly.
  • The endpoint is not linked anywhere: route discovery through bundles, sitemaps and error messages is routine.
Working vocabulary

Terms you should be able to use precisely

Function-level authorization
A decision about whether a subject may invoke a particular action or route.
Deny by default
A policy posture where an unlisted action is refused unless a rule explicitly allows it.
Forced browsing
Requesting a route directly instead of navigating through the intended UI.
Privilege escalation
Gaining a role or capability beyond what the subject was granted.
Policy decision point
The central component that evaluates subject, action and context.
Confused deputy
A privileged component that performs an action because it trusts a less-privileged caller's request.
Interview drill

Answer these without reciting a payload

What is the difference between function-level and object-level authorization?

Function-level asks whether the subject may invoke an action or route. Object-level asks whether the subject may act on this specific object. A complete policy needs both.

Why is hiding an admin button insufficient?

The browser is controlled by the user. Routes, API calls and parameters can be discovered and invoked directly, so the server must enforce the decision.

How should legacy routes be handled?

Map every alias and version to the same policy, or remove it. Separate code paths create drift and are a common source of bypasses.

Knowledge check

Can you separate the mechanism from the payload?

Four questions, graded on the server. Answers and explanations are released only after you submit, and signed-in learners keep a best score.

4 questions
01A normal user cannot see the admin button but can call /api/admin/export. What failed?
02Which design is least likely to drift as routes are added?
03GET /admin returns 403. What should you test next?
04What makes a role-by-route test matrix useful?
الخلاصة الموسّعة
لماذا هذا مهم؟

الخطأ الشائع هو اعتبار إخفاء الزر حماية. المستخدم يتحكم بالمتصفح، ويمكنه قراءة الحزم أو تجربة المسارات مباشرة.

الصلاحية الصحيحة تُقرر على الخادم، لكل فعل وليس لكل صفحة فقط، وتكون مرفوضة افتراضيًا عند غياب قاعدة. اختبر المصفوفة كاملة: الدور، المسار، طريقة HTTP، وإصدار الـAPI. وأي مسار قديم أو وظيفة خلفية يجب أن تمر بنفس القرار.

Which request proves the server checked authorization, not just identity?