Skip to content
Account takeover Write-up Beginner

My First And Second Bugs Are — 2FA Bypass

Two websites returned a flag in the login response indicating whether two-factor authentication was required, and the author changed that flag client-side to skip the second factor. On the second site the bypass alone gave no session token, but a separate order-page login form returned the customer's name, ID and an authorisation token without asking for the one-time code, which allowed a full login.

JAI NIRESH J Follow

Published on medium.com

This write up is about my very first bug and the second one that i found shortly after the first one, which are IMPROPER AUTHENTICATION CONTROLS that led to a 2FA bypass.

JAI NIRESH J, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

This write-up covers two separate findings, both of them improper authentication controls that led to a 2FA bypass. The first was on a cryptocurrency wallet website, referred to here as redacted.com. The second was on an unrelated website, referred to as bluedacted.com, which had an order page where customers could order items.

In both cases the feature under test is the login flow of an account that has 2FA enabled. Normally, after the username and password are accepted, the application asks for the one-time password; on the second target an authorisation token is issued only once that step succeeds.

Setup

The researcher used Burp as an intercepting proxy and the browser's developer tools to inspect AJAX responses. Two accounts were involved: an account without 2FA and an account with 2FA enabled. No versions, endpoints or parameters beyond those quoted below are given in the report.

Finding it

The starting point in both cases was the shape of the login response. On the first target, the response body contained a parameter named required, whose value differed depending on whether the account had 2FA enabled. On the second target, the login response contained a parameter named need2FA. Both parameters indicate whether the second factor is needed, and changing them in the response led to a redirect to the dashboard.

Exploitation

First bug: flipping required

  1. Log in with an account that has 2FA enabled and intercept the login response in Burp. The response looks like this:
Text
{... ,... ,required: true}
  1. For comparison, an account without 2FA receives a response of the same shape with the flag set the other way:
Text
{... ,... ,required: false}
  1. Change the value of required from true to false in the intercepted response and forward it.

Because the redirect to the dashboard is driven by this client-side value, the browser sent the researcher to the dashboard. The account details were then available and the researcher was logged in to the account.

The lesson recorded in the report: always check for interesting parameters in the response.

Second bug: flipping need2FA, then recovering the token elsewhere

  1. On bluedacted.com, inspect the login response. It looks like this:
Text
400 BAD REQUEST...{error:"xxx",message:"xxx",need2FA:true}
  1. Apply the same response manipulation as before, changing need2FA so that the client no longer believes 2FA is required. The researcher was again redirected to the dashboard.

  2. This time the redirect was all that happened. The inner dashboard and option pages loaded, but the details of the user being logged in to were not returned. The site uses an authorisation token that is issued only after the 2FA step completes, and because the response was manipulated rather than the flow completed, no token was ever issued. Every subsequent request from the browser carried:

HTTP
Authorization: Bearer undefined
  1. Later, while browsing the site, the researcher found an order page for customers to order items. It contained a login form that makes an AJAX request to the server to fetch just the customer ID and the name of the customer logging in.

  2. Submitting the credentials of the 2FA-protected account to that form returned the name and customer ID without asking for the OTP.

  3. Inspecting the AJAX response in the browser's developer tools showed a JSON body containing the account details and an authorisation token:

JSON
{"customer_ID": 1452,"name": Magma,"token": xxxxxxxxxxxxxxxx}
  1. Returning to the real login page, the researcher replaced the Authorization: Bearer undefined header with the token obtained from the order page's login form. The session was then authenticated as the user, completing the 2FA bypass.

The lesson recorded in the report: spider around all login pages and forms.

Root cause

The first target returned a required flag in the login response, and editing it in the browser was enough to reach the dashboard. The second target also returned a need2FA flag, but the dashboard rendered without a usable token being issued. The bypass only became complete because a second login form on the order page returned the customer's name, customer ID and authorisation token after a password-only check, without requiring the OTP. In other words, the order page's login form returned the token without requiring the OTP.

Impact

On the first target, manipulating the response reached the dashboard and exposed the account details. On the second target, response manipulation alone only reached the inner dashboard and option pages; full account access required the token leaked by the order page's login form, which returned the customer ID, name and token for a 2FA-protected account given only the credentials. Both findings required valid account credentials, and the second also depended on the order page's login form being present.

Fix

The report does not describe any fix that was applied. Based on the findings, the server should decide server-side whether the second factor has been completed and should not rely on a flag in the response body to gate the authenticated area. Any endpoint that accepts credentials and returns an authorisation token, including secondary login forms such as the one on the order page, should enforce the same 2FA step as the main login flow before issuing the token.

Variants to test

  1. Look for boolean flags in login and step-up responses (required, need2FA, mfaRequired, otpVerified and similar) and flip them in the proxy. A positive result is being redirected into the authenticated area without submitting an OTP.
  2. After a manipulated response, check whether requests carry a placeholder token such as Authorization: Bearer undefined. If they do, the bypass is only partial and a token still has to be obtained.
  3. Spider the application for secondary login forms, order pages, support forms and AJAX endpoints that accept credentials. A positive result is any of them returning account data or a token for a 2FA-protected account without an OTP prompt.
  4. Compare the responses of the same login request for a 2FA-enabled and a non-2FA account and diff the fields. Any field that differs is a candidate for manipulation.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 9 min read.

What happened, in plain words

This is the story of two bugs I found early on, both of which let someone get past the second factor of a login (the extra code you type after your password, often called 2FA or two-factor authentication). The first bug was on a cryptocurrency wallet website, which I call redacted.com here. The second was on a different site, bluedacted.com, which had an order page where customers could order items.

In both cases the feature I was testing was the login flow for an account that has 2FA turned on. Normally, after you type your username and password, the site asks for a one-time password (OTP). I found ways to skip that step, at least partly, by changing what the server sends back to the browser.

To follow along you only need to know how to use a browser and a computer. I will explain every technical term as it comes up.

The tools I used

I used two tools:

  • Burp (short for Burp Suite): a program that sits between your browser and the website. It lets you see every request your browser sends and every response the server sends back, and you can pause a response and edit it before the browser sees it. Think of it as a mail interception service: the letter is already written, but you can open it, change a word, and reseal it before it reaches the recipient.
  • Browser developer tools: the built-in panel in every modern browser (usually opened with F12) that shows the network requests the page makes, including AJAX requests. AJAX is just a way for a web page to talk to the server in the background without reloading the whole page, like sending a quick text message instead of making a phone call.

I had two accounts: one without 2FA and one with 2FA enabled. The report does not give any version numbers, endpoint paths or extra parameters beyond what is quoted below.

How I found the first bug

I started by looking at the shape of the login response. When you log in, the server sends back a chunk of data, usually in JSON (a text format that looks like {"key": "value"}). That data tells the browser what to do next. On the first site, the response contained a field called required. Its value was different depending on whether the account had 2FA enabled.

Here is what an account without 2FA received:

Text
{... ,... ,required: false}

This is a JSON object. The ... stands for other fields I am not showing. The important part is required: false, which tells the browser: "this user does not need to do a second step".

And here is what an account with 2FA received:

Text
{... ,... ,required: true}

Same shape, but required: true, meaning: "this user must complete the second step".

The browser reads this value and decides where to send you: if false, it sends you straight to the dashboard (the main page you see after logging in). The problem is that this decision is made in the browser, using data the server sent. If I can change that data before the browser reads it, I can change the decision.

Exploiting the first bug: flipping required

  1. I logged in with the account that has 2FA enabled and set Burp to pause the login response. The response looked like the required: true example above.
  2. For comparison, I logged in with the account without 2FA and saw the same shape with required: false.
  3. In Burp, I changed the value of required from true to false in the paused response, then let it continue to the browser.

Because the redirect to the dashboard is driven by this value in the browser, the browser sent me to the dashboard. The account details were then available, and I was logged in to the account.

The lesson I wrote down: always check for interesting parameters in the response. In other words, look at what the server sends back, not just what you send.

How I found the second bug

This one was harder to find, not because the idea was complex, but because it involved several different pages (endpoints) that took time to locate. An endpoint is simply a URL that the application uses to do something, like /login or /order.

On bluedacted.com, the first thing I checked was the response to the login request. It looked like this:

Text
400 BAD REQUEST...{error:"xxx",message:"xxx",need2FA:true}

Let me break that down. 400 BAD REQUEST is an HTTP status code: the server is saying "something about your request was not acceptable". The part after it is JSON with three fields: error and message (both shown as "xxx", meaning I am not revealing their real content) and need2FA: true. That last field is the interesting one: it tells the browser that this account needs the second factor.

Exploiting the second bug: flipping need2FA, then finding the token elsewhere

  1. I inspected the login response on bluedacted.com and saw the need2FA: true field shown above.
  2. I applied the same trick as before: I changed need2FA so the browser no longer believed 2FA was required. I was again redirected to the dashboard.
  3. This time the redirect was all that happened. The inner dashboard and option pages loaded, but the details of the user I was trying to log in as were not returned. The site uses an authorisation token (a long secret string that proves who you are on every request, like a wristband you get at an event that lets you back in without showing your ticket again) that is issued only after the 2FA step completes. Because I had manipulated the response rather than completed the flow, no token was ever issued. Every subsequent request from my browser carried:
HTTP
Authorization: Bearer undefined

This is an HTTP header. Headers are extra lines of information sent with a request or response. Authorization is the header name, and Bearer is the scheme used for tokens. undefined is a placeholder meaning "no value". So the browser was sending "I have no token" on every request, which is why the account details were missing.

  1. Later, while browsing the site, I found an order page for customers to order items. It contained a login form that makes an AJAX request to the server to fetch just the customer ID and the name of the customer logging in.
  2. I submitted the credentials of my 2FA-protected account to that form, and it returned my name and customer ID without asking for the OTP.
  3. I opened the browser's developer tools and looked at the AJAX response. It was a JSON body containing the account details and an authorisation token:
JSON
{"customer_ID": 1452,"name": Magma,"token": xxxxxxxxxxxxxxxx}

Here customer_ID is a number identifying the customer, name is the customer's name, and token is the secret string. I have replaced the real token with xxxxxxxxxxxxxxxx.

  1. I went back to the real login page and replaced the Authorization: Bearer undefined header with the token I had obtained from the order page's login form. The session was then authenticated as the user, completing the 2FA bypass.

The lesson I wrote down: spider around all login pages and forms. "Spidering" means systematically exploring the site to find every page and form, rather than only looking at the main login page.

Why it worked

The first site returned a required flag in the response. Because the redirect was driven by this value in the browser, editing the response was enough to reach the dashboard.

The second site also returned a need2FA flag, but the dashboard rendered without a usable token being issued. The bypass only became complete because a second login form on the order page returned the customer's name, customer ID and authorisation token after a password-only check, without requiring the OTP. In other words, the order page's login form returned the token without requiring the OTP.

What an attacker could do

On the first site, manipulating the response reached the dashboard and exposed the account details. On the second site, response manipulation alone only reached the inner dashboard and option pages; full account access required the token leaked by the order page's login form, which returned the customer ID, name and token for a 2FA-protected account given only the credentials. Both findings required valid account credentials, and the second also depended on the order page's login form being present.

How to fix it

The report does not describe any fix that was applied. Based on the findings, the server should decide server-side whether the second factor has been completed and should not rely on a flag in the response body to gate the authenticated area. Any endpoint that accepts credentials and returns an authorisation token, including secondary login forms such as the one on the order page, should enforce the same 2FA step as the main login flow before issuing the token.

Variants to test

  1. Look for boolean flags in login and step-up responses (required, need2FA, mfaRequired, otpVerified and similar) and flip them in the proxy. A positive result is being redirected into the authenticated area without submitting an OTP.
  2. After a manipulated response, check whether requests carry a placeholder token such as Authorization: Bearer undefined. If they do, the bypass is only partial and a token still has to be obtained.
  3. Spider the application for secondary login forms, order pages, support forms and AJAX endpoints that accept credentials. A positive result is any of them returning account data or a token for a 2FA-protected account without an OTP prompt.
  4. Compare the responses of the same login request for a 2FA-enabled and a non-2FA account and diff the fields. Any field that differs is a candidate for manipulation.

Glossary

  • 2FA (two-factor authentication): a login that requires two things, usually your password plus a one-time code, so a stolen password alone is not enough.
  • AJAX: a way for a web page to exchange data with the server in the background without reloading the page.
  • Authorisation token: a secret string issued after login that the browser sends with each request to prove who you are, like a wristband at an event.
  • Burp (Burp Suite): a tool that sits between your browser and a website so you can view and edit requests and responses.
  • Developer tools: the built-in browser panel (often F12) that shows network requests and other technical details.
  • Endpoint: a URL that the application uses to perform an action, such as a login or order page.
  • Header: extra information sent with an HTTP request or response, such as Authorization.
  • HTTP status code: a number the server returns to say how a request went, for example 400 BAD REQUEST.
  • JSON: a text format for structured data, written as {"key": "value"} pairs.
  • OTP (one-time password): a code that is valid for a single login attempt, usually the second factor.
  • Response: the data the server sends back to the browser after a request.
  • Spidering: systematically exploring a website to discover all its pages and forms.
  • Authorization: Bearer undefined: an HTTP header meaning the browser is trying to send a token but has none (undefined is a placeholder for "no value").

More by JAI NIRESH J

View all

2 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Account takeover

The lesson behind this report.

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.