Skip to content
Account takeover Write-up Intermediate

2FA Bypass due to information disclosure & Improper access control.

The login response disclosed a JWT token and the names and IDs of the user's organisations, including whether each had 2FA enabled. An attacker who knows the victim's password could use the leaked token and an organisation ID to call an organisation-switch endpoint and log in without completing the account's 2FA.

Akash Hamal Follow

Published on akashhamal0x01.medium.com

Today i will be explaining how i found a 2FA bypass while i was looking for DOS but DOS is possible if the logic isn’t implemented so its worth to look these types of vulnerabilities in organization/team based websites, etc. I hope you enjoy and learn something from it too.

Akash Hamal, on akashhamal0x01.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. 6 min read.

Context

This write-up describes a 2FA bypass found while the researcher was actually hunting for denial-of-service style logic flaws. The target is a multi-tenant product where users can create their own organisations and join other organisations, and where authentication can be protected at two levels: account-based 2FA and organisation-based 2FA. The report does not name the product or the program.

The feature that matters here is the login flow. When a user submits their email and password, the server responds with a JWT token under a 2fa parameter, and that token must be sent back together with the six-digit authenticator code to complete the second factor. The same login flow also decides which organisation the user lands in after authenticating, based on the organisation they were in when they last logged out.

The researcher frames the finding as a logic issue: whether the bypass is possible depends entirely on how the organisation switching and 2FA exceptions are implemented.

Setup

The attack requires a website with the following properties, as listed in the report:

  1. You can create your own organisation and join other organisations.
  2. You are logged into the organisation you were in when you logged out. For example, if you are the owner of Org A and have joined Org B, switching to Org B and logging out means the next login puts you back in Org B.
  3. There are two kinds of 2FA: account-based 2FA and organisation-based 2FA. If organisation-based 2FA is enabled, account-based 2FA must also be enabled in order to log into that organisation.

The researcher enabled account 2FA on their own account and then started probing the authentication flow. No specific tools or versions are mentioned beyond issuing HTTP requests directly against the API, which the site uses for most CRUD actions.

Finding it

After submitting email and password, the login response leaked more than it should:

  • It contained a parameter holding a JWT token, in the form "2fa":"<JWT_TOKEN>".
  • It also revealed the names of the organisations the user had joined, together with their organisation IDs, and whether each of those organisations had 2FA enabled.

The researcher first tried to use the leaked <JWT_TOKEN> to issue direct HTTP requests to API endpoints. Those attempts returned 403 Denied, because the token is not an authentication token. That was a deliberate check to see whether anything would happen, not a working path.

The token's real purpose is in the 2FA request: it is sent alongside the code parameter, where code is the six-digit Google Authenticator value. The flow is:

  1. Enter email and password, and the response reveals "2fa":"<JWT_TOKEN>".
  2. You are asked for the 2FA code.
  3. You submit the six-digit code, and the HTTP body contains {"2fa":"<JWT_TOKEN>", "code":<6 digit 2fa code>}.

The 2fa value is issued together with the code parameter, and together they complete the 2FA step and log the user into the account. The 2fa value is therefore necessary to complete the second factor.

No vulnerability turned up in that flow directly, but the researcher thought about a scenario that might lead to a denial of service, and decided to test it.

Exploitation

The scenario the researcher had in mind: a user has joined two organisations, one they own (where they are Owner) and an attacker-controlled organisation (where they have the Member role). Assume the user does not have account 2FA enabled and neither organisation has organisation-based 2FA enabled. The user is logged into the attacker organisation (Org B) and logs out. On the next login they land in Org B, because that was the organisation they were in when they logged out.

The question was what happens if, before the user logs in again, the owner of the attacker organisation enables organisation-based 2FA. Since 2FA is now required to log into that organisation, would the user be denied login?

Step 1: Log in and observe the options

After entering email and password in that situation, the user is given two options:

  1. A "This Org have 2FA enabled, please Setup 2FA" option. Clicking it sends a code to the email address, which the attacker does not control, so this option is not useful.
  2. A "Switch Org" option, which allows switching to an organisation that does not have 2FA enabled, in this case the user's own organisation.

Step 2: Inspect the switch request

Analysing the HTTP request behind the switch, the researcher found that the leaked information can be used in that request to get into the organisation that does not have 2FA enabled. The request to switch organisation was:

HTTP
POST /api/org/<ORGID>
Host: example.com

{"2fa":"<JWT_TOKEN>"}

The endpoint accepts the leaked 2fa value and lets the caller into the account. That is the endpoint the researcher discovered.

Step 3: The final scenario

In this scenario the victim has joined two organisations, only one of which has 2FA enabled, and the victim has account-based 2FA enabled.

  1. Enter email and password. The response returns "2fa":"<JWT>" and the organisation ID of the organisation that does not have 2FA enabled.
  2. Issue the following request:
HTTP
POST /api/org/<ORG ID>
Host: example.com

{"2fa":"<JWT_TOKEN>"}

This logs the caller into the account, bypassing account 2FA. In short, the researcher found an endpoint that accepts the leaked values and lets you into the account.

Root cause

The login response discloses two things it should not: the 2fa JWT token and the list of organisations with their IDs and 2FA status. The organisation switch request carries only the 2fa token, with no code field, and the researcher reports that it logs the caller into the account. Because the switch path is an exception to the 2FA requirement, it becomes a way around the account-level 2FA that the victim has enabled.

The report does not describe the server-side code, so the exact implementation mistake is not shown. The researcher's own framing is that the write-up depends mostly on how functionalities, exceptions and edge cases are implemented, The researcher's own framing is that the write-up depends mostly on how functionalities, exceptions and edge cases are implemented.

Impact

An attacker who knows a victim's email and password can complete login without the victim's authenticator code in the specific configuration described: the victim joined an attacker-controlled organisation, was in it at logout, and the attacker enabled organisation-based 2FA on it. The leaked 2fa token from the first login step and the leaked organisation ID are enough to call the switch endpoint and land in the account. The victim's account-based 2FA is bypassed.

The researcher notes that the write-up is mostly applicable to finding denial-of-service style issues and new endpoints, and that the bypass depends on the specific organisation and 2FA configuration described above.

Fix

Based on the described behaviour, the login response should not disclose the 2fa token or the organisation list with 2FA status, and the organisation switch endpoint should not accept the 2fa token as a substitute for a completed second factor. Whether either change was made is not stated.

Variants to test

  1. Leaky login responses. Submit email and password on multi-tenant applications and inspect the response for tokens, organisation IDs, role names or 2FA status flags. A positive result is any of these appearing before the second factor is completed.
  2. Pre-auth tokens reused on other endpoints. Take any token issued before 2FA completion and replay it against organisation switch, invitation accept, password change and profile endpoints. A positive result is a 200 that performs a state change or returns account data.
  3. Switch-org exceptions. On applications where the last-used organisation determines the post-login context, enable organisation 2FA on that organisation and look for a switch path to an organisation without 2FA. A positive result is a switch request that succeeds without a valid code.
  4. Partial 2FA state. Check whether the pre-2FA token is accepted with an empty, missing or replayed code parameter. A positive result is a login or session issued without a fresh six-digit code.
  5. Organisation enumeration. Compare the organisation list returned at login with the organisations the user actually belongs to. A positive result is IDs or 2FA status for organisations the user should not see.

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. 13 min read.

What happened, in plain words

A security researcher was testing a website that lets people create their own organisations (think of a company workspace inside a shared product) and join other people's organisations. While looking for a different kind of bug, they found a way to get into an account without the second security step that the account owner had switched on.

The second step is called two-factor authentication, or 2FA. Normally, after you type your email and password, the site asks for a short six-digit code from an app on your phone. The researcher found that the site's login response handed back a small piece of data (a token) and a list of the organisations the user belonged to, and that a particular request for switching organisations accepted that token on its own, without any six-digit code. That request logged the caller straight into the account, so the phone code was never needed.

This article walks through the whole story from the beginning, explaining every term as it appears. It follows the same steps the researcher took, in the same order, with the same requests.

Background: the pieces you need to know

Before the story makes sense, here are the ideas it relies on.

What an API is

A website you see in a browser is made of pages. Behind those pages, most modern sites also expose an API (application programming interface): a set of addresses that a program can talk to directly, sending and receiving data instead of pretty pages. A useful comparison is a restaurant. The menu and the dining room are the website you see; the kitchen is the server; the API is the waiter who takes your order to the kitchen and brings back the food. You can order through the waiter without ever walking into the kitchen.

The researcher in this report sent requests straight to the API, skipping the browser pages. The report says the site uses its API for most CRUD actions. CRUD stands for Create, Read, Update, Delete: the four basic things you do with data (make a new record, look at it, change it, remove it).

What a token is

When you log in somewhere, the server needs a way to remember who you are on the next request. Browsers and servers do this with a token: a long string of characters that the server hands you after login and that you show on later requests, like a cloakroom ticket. Whoever holds the ticket can collect the coat, so a token must be kept secret.

A JWT (JSON Web Token) is one common format for such a token. It is a string that carries some information and is signed by the server so it cannot be quietly altered. Not every JWT is a login token: a site can issue a JWT for a narrow purpose, such as remembering that you passed the first step of login, and that token will not work as a general login ticket.

What 2FA is, and the two kinds here

2FA (two-factor authentication) means proving who you are with two different things: usually your password (something you know) plus a code from an app such as Google Authenticator (something you have). The six-digit code changes every so often, so a stolen password alone is not enough.

This product had two layers of 2FA:

  • Account-based 2FA: protection on your personal account.
  • Organisation-based 2FA: protection on a particular organisation, so that everyone entering that workspace must use a second factor.

The report states a rule the site enforced: if organisation-based 2FA is enabled, you must also have account-based 2FA enabled in order to log into that organisation.

What a logic flaw is

Many security bugs are technical, such as a programming mistake that lets data overflow. A logic flaw is different: every piece of code works as written, but the rules combine in a way the designers did not intend. A comparison is a building where every door lock works perfectly, but the fire exit opens from the outside because nobody thought about it. The researcher describes this finding as exactly that kind of issue: whether the bypass works depends on how the organisation switching and the 2FA exceptions were implemented.

What denial of service means

Denial of service (DoS) means making a service unusable for its rightful users, for example by locking them out or overwhelming them. The researcher was originally hunting for that kind of problem, on the theory that a badly implemented rule can lock a user out of their own account. The report notes that DoS is possible when logic is not implemented carefully, which is why these organisation and team based sites are worth examining.

The conditions the site must meet

The attack only works on a site with certain features. The report lists them:

  1. You can create your own organisation and join other organisations.
  2. You are logged into the organisation you were in when you logged out. For example, if you are the owner of Org A and have joined Org B, switching to Org B and logging out means the next login puts you back in Org B.
  3. There are two kinds of 2FA: account-based 2FA and organisation-based 2FA. If organisation-based 2FA is enabled, account-based 2FA must also be enabled in order to log into that organisation.

Point 2 is the one to hold on to. The site remembers your last organisation and drops you back into it after login. That convenience is what the attack later leans on.

The researcher enabled account 2FA on their own account and then started poking at the authentication flow. The report does not mention any particular tools or versions; the work was done by sending HTTP requests directly to the API.

Finding it: the login response says too much

After entering an email address and password, the login response contained more than it should:

  • A parameter holding a JWT token, in the form "2fa":"<JWT_TOKEN>".
  • The names of the organisations the user had joined, together with their organisation IDs, and whether each of those organisations had 2FA enabled.

An organisation ID is simply the unique number or string the site uses to identify a particular organisation internally, the way a customer number identifies a customer.

The researcher first tried to use the leaked <JWT_TOKEN> to send direct HTTP requests to API endpoints. Those attempts came back as 403 Denied. HTTP is the language browsers and servers use to talk; every request has a method (such as GET to fetch or POST to send data), an address, and a status code in the reply. 403 is the status code for "forbidden": the server understood the request and refused it. The reason here is that the token is not an authentication token. The researcher was trying it deliberately, just to see whether anything would happen, not because it was expected to work.

The token's real job is in the 2FA request: it is sent alongside the code parameter, where code is the six-digit Google Authenticator value. The flow is:

  1. Enter email and password, and the response reveals "2fa":"<JWT_TOKEN>".
  2. You are asked for the 2FA code.
  3. You submit the six-digit code, and the HTTP body contains {"2fa":"<JWT_TOKEN>", "code":<6 digit 2fa code>}.

The 2fa value is issued together with the code parameter, and together they complete the 2FA step and log the user into the account. The 2fa value is therefore necessary to complete the second factor.

Nothing exploitable turned up in that flow directly. But the researcher thought of a scenario that might cause a denial of service, and decided to test it.

Exploitation: the scenario

The scenario the researcher had in mind: a user has joined two organisations, one they own (where they are Owner) and an attacker-controlled organisation (where they have the Member role). Assume the user does not have account 2FA enabled and neither organisation has organisation-based 2FA enabled. The user is logged into the attacker organisation (Org B) and logs out. On the next login they land in Org B, because that was the organisation they were in when they logged out.

The question was what happens if, before the user logs in again, the owner of the attacker organisation enables organisation-based 2FA. Since 2FA is now required to log into that organisation, would the user be denied login?

Step 1: Log in and observe the options

After entering email and password in that situation, the user is given two options:

  1. A "This Org have 2FA enabled, please Setup 2FA" option. Clicking it sends a code to the email address, which the attacker does not control, so this option is not useful.
  2. A "Switch Org" option, which allows switching to an organisation that does not have 2FA enabled, in this case the user's own organisation.

Step 2: Inspect the switch request

Analysing the HTTP request behind the switch, the researcher found that the leaked information can be used in that request to get into the organisation that does not have 2FA enabled. The request to switch organisation was:

HTTP
POST /api/org/<ORGID>
Host: example.com

{"2fa":"<JWT_TOKEN>"}

Line by line:

  • POST /api/org/<ORGID> is the request line. POST is the method used when you are sending data that changes something on the server, here a request to switch into a particular organisation. /api/org/<ORGID> is the address being called: the API path for an organisation, with <ORGID> standing in for the organisation's ID. The angle brackets are a placeholder, not literal text.
  • Host: example.com is a header. Headers are the labelled lines at the top of a request that carry extra information, such as which site the request is aimed at. example.com is a stand-in name, not the real site.
  • The blank line separates the headers from the body.
  • {"2fa":"<JWT_TOKEN>"} is the body, written in JSON (JavaScript Object Notation), a common text format for structured data. It is a pair of curly braces holding a name, 2fa, and its value, the leaked token. Notice what is missing: there is no code field. The request carries the token from the first login step and nothing else.

The endpoint accepts the leaked 2fa value and lets the caller into the account. That is the endpoint the researcher discovered.

Step 3: The final scenario

In this scenario the victim has joined two organisations, only one of which has 2FA enabled, and the victim has account-based 2FA enabled.

  1. Enter email and password. The response returns "2fa":"<JWT>" and the organisation ID of the organisation that does not have 2FA enabled.
  2. Issue the following request:
HTTP
POST /api/org/<ORG ID>
Host: example.com

{"2fa":"<JWT_TOKEN>"}

This is the same shape of request as before. The method is POST, the path points at an organisation by its ID, the Host header names the site, and the body carries only the 2fa token. No six-digit code is sent. This logs the caller into the account, bypassing account 2FA. In short, the researcher found an endpoint that accepts the leaked values and lets you into the account.

Why it works

The login response discloses two things it should not: the 2fa JWT token and the list of organisations with their IDs and 2FA status. The organisation switch request carries only the 2fa token, with no code field, and the researcher reports that it logs the caller into the account. Because the switch path is an exception to the 2FA requirement, it becomes a way around the account-level 2FA that the victim has enabled.

The report does not describe the server-side code, so the exact implementation mistake is not shown. The researcher's own framing is that the write-up depends mostly on how functionalities, exceptions and edge cases are implemented, The researcher's own framing is that the write-up depends mostly on how functionalities, exceptions and edge cases are implemented.

What an attacker could do with it

An attacker who knows a victim's email and password can complete login without the victim's authenticator code in the specific configuration described: the victim joined an attacker-controlled organisation, was in it at logout, and the attacker enabled organisation-based 2FA on it. The leaked 2fa token from the first login step and the leaked organisation ID are enough to call the switch endpoint and land in the account. The victim's account-based 2FA is bypassed.

CVSS is a standard scoring system for rating how serious a vulnerability is. The researcher notes that the write-up is mostly applicable to finding denial-of-service style issues and new endpoints, and that the bypass depends on the specific organisation and 2FA configuration described above.

How it should be fixed

Based on the described behaviour, the login response should not disclose the 2fa token or the organisation list with 2FA status, and the organisation switch endpoint should not accept the 2fa token as a substitute for a completed second factor. Whether either change was made is not stated.

Things to try on other sites

  1. Leaky login responses. Submit email and password on multi-tenant applications and inspect the response for tokens, organisation IDs, role names or 2FA status flags. A positive result is any of these appearing before the second factor is completed.
  2. Pre-auth tokens reused on other endpoints. Take any token issued before 2FA completion and replay it against organisation switch, invitation accept, password change and profile endpoints. A positive result is a 200 that performs a state change or returns account data. (200 is the HTTP status code for a successful request.)
  3. Switch-org exceptions. On applications where the last-used organisation determines the post-login context, enable organisation 2FA on that organisation and look for a switch path to an organisation without 2FA. A positive result is a switch request that succeeds without a valid code.
  4. Partial 2FA state. Check whether the pre-2FA token is accepted with an empty, missing or replayed code parameter. A positive result is a login or session issued without a fresh six-digit code.
  5. Organisation enumeration. Compare the organisation list returned at login with the organisations the user actually belongs to. A positive result is IDs or 2FA status for organisations the user should not see. Enumeration here means learning which records exist, one by one, from what the server tells you.

Glossary

  • 2FA (two-factor authentication): logging in with two different proofs of identity, usually a password plus a changing code from an app.
  • Account-based 2FA: second-factor protection applied to a personal account.
  • API (application programming interface): the set of addresses and rules a program uses to talk to a server directly, without the browser pages.
  • Body: the part of an HTTP request or response that carries the actual data, after the headers.
  • CRUD: Create, Read, Update, Delete, the four basic operations on stored data.
  • CVSS: a standard scoring system for rating the severity of a vulnerability.
  • Denial of service (DoS): making a service unusable for its rightful users.
  • Endpoint: one specific address on an API that performs one specific job.
  • Enumeration: discovering which records exist by observing what a server returns.
  • Header: a labelled line at the top of an HTTP request or response carrying extra information, such as the target host.
  • HTTP: the language browsers and servers use to exchange requests and responses.
  • JSON: a text format for structured data, built from names and values in curly braces.
  • JWT (JSON Web Token): a signed string that carries information and cannot be quietly altered; it may serve a narrow purpose rather than being a full login token.
  • Logic flaw: a bug where the code works as written but the rules combine in an unintended way.
  • Organisation: a shared workspace inside a product that users can create or join.
  • Organisation ID: the unique identifier the site uses for a particular organisation.
  • Organisation-based 2FA: second-factor protection applied to a whole organisation, required of everyone entering it.
  • Parameter: a named value sent with a request, such as 2fa or code.
  • POST: the HTTP method used to send data that changes something on the server.
  • Status code: the number in an HTTP response saying how the request went, such as 200 for success or 403 for forbidden.
  • Token: a string the server issues and the client shows on later requests to prove who it is; it must be kept secret.
  • 403: the HTTP status code meaning the server understood the request and refused it.

More by Akash Hamal

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.