Authentication bypass via flawed state machine
Understanding the Vulnerability
This vulnerability demonstrates a serious flaw in session state management and workflow enforcement, where the application incorrectly assigns privileges when an expected intermediate step is skipped. Instead of securely requiring completion of the role-selection process, the backend mishandles incomplete session states and grants elevated access by default.
This type of vulnerability can lead to privilege escalation, allowing a normal authenticated user to gain unauthorized administrator access without exploiting traditional issues such as SQL injection or broken passwords.
Step 1: User Logs In Normally
The attack starts with a legitimate login attempt using valid credentials.
The user submits a request like:
POST /login
At this stage, the application verifies the username and password successfully.
However, instead of immediately taking the user to the dashboard, the application triggers an additional step before finalizing the session.
Step 2: Backend Requests Role Selection
After authentication succeeds, the backend responds with a redirect or request to a role-selection endpoint:
GET /role-selector
This page is intended to allow the user to select which role they want to assume in the session.
Examples could include:
- Standard user
- Support staff
- Administrator
At this point, the session is only partially initialized.
The user is authenticated, but the role has not yet been assigned.
This is why trying to access privileged pages such as:
/admin
directly from the role selection page does not work.
Step 3: Intercept the Role-Selector Request
Using Burp Suite Proxy, the attacker intercepts the request before it reaches the browser.
The intercepted request looks like:
GET /role-selector
Instead of forwarding it, the attacker drops the request.
This prevents the role-selection page from loading and stops the workflow before completion.
At this point:
- The user is authenticated
- No role has been explicitly selected
- The session is incomplete
A secure application should now:
- invalidate the session
- redirect back to role selection
- deny access to all protected pages
But this application does not.
Step 4: Manually Request the Home Page
After dropping the role-selector request, the attacker manually browses to the application’s main page.
Example request:
GET /
and forwards it.
This is where the vulnerability occurs.
Instead of checking whether the role-selection process was completed, the backend assumes the session is valid.
Step 5: Application Defaults to Administrator
Because the role value was never set, the backend falls back to an insecure default.
Instead of assigning:
user
or:
guest
it assigns:
administrator
This causes the session to inherit full administrative privileges.
Now the attacker can access:
/admin
without ever selecting or being authorized for that role.
The admin panel appears immediately.
Comments