Skip to content
Account takeover Write-up Intermediate

How I Bypassed 2FA by Changing One Request Parameter — and Earned a $$ Bounty

The server did not verify that the challenge_name sent by the client matched the authentication_flow stored in the session, allowing an attacker to choose a challenge type that requires no code. By sending MFA_SETUP instead of the required SOFTWARE_TOKEN_MFA, an attacker with the victim's password could bypass two-factor authentication and obtain a full session.

nowisar Follow

Published on nowisar.medium.com

Pentesting

Mohamed Nowisar, on nowisar.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

The target is a web application whose login flow is a two-step handshake. Step one takes a username and password. If the account has 2FA configured, the server does not complete the login: it returns an intermediate session and states which challenge it is waiting for. Step two, respond-to-auth-challenge, takes that session back along with a challenge_name and an answer (the code).

The finding is a logic flaw in that second step: the server never checks that the challenge_name sent by the client matches the authentication_flow stored in the session. By sending a different challenge name, the researcher obtained a fully authenticated session without submitting any TOTP code or OTP.

Setup

The researcher tested against an account that genuinely had 2FA turned on. It describes four target hostnames being tested, all of which were vulnerable. The account used for the password-change test was the researcher's own, with a planned revert.

Finding it

The login flow begins with a username and password:

HTTP
POST /api/v1.0/auth/initiate-auth/{"username":"<victim>","password":"<known password>"}

Because the account has 2FA configured, the server does not log the user in. It returns an intermediate session and names the challenge it expects:

HTTP
200 OK{"challenge_name":"SOFTWARE_TOKEN_MFA","session":"<JWT>"}

Decoding the session JWT confirms the same decision from the server's side:

JSON
{"authentication_flow":"SOFTWARE_TOKEN_MFA","scope":"authentication","user_id":1698586}

The server has already decided that this account needs a TOTP code before login is complete, and that decision is baked into the session. The design intent of step two is that challenge_name is simply the server echoing back what it decided in step one, while answer proves the challenge was cleared. The flaw is that the server branches on whatever challenge_name string the client sends, without comparing it to the authentication_flow in the session. The client therefore chooses which challenge to satisfy, including one that requires nothing at all.

From the original on nowisar.medium.com

Exploitation

Step 1: initiate authentication

Send the victim's username and the known password to initiate-auth. The response is a 200 containing challenge_name set to SOFTWARE_TOKEN_MFA and a session JWT whose authentication_flow claim is also SOFTWARE_TOKEN_MFA. This establishes that the account has 2FA and that the server intends to require a TOTP code.

Step 2: send a different challenge name

MFA_SETUP is the branch intended for a user who has no second factor yet and is going through the one-time setup screen. It is not supposed to be reachable once SOFTWARE_TOKEN_MFA is the recorded flow. The researcher sent it anyway, against an account with 2FA turned on, with no answer field at all:

HTTP
POST /api/v1.0/auth/respond-to-auth-challenge/{"session":"<session from step 1>","challenge_name":"MFA_SETUP"}

The server responded with a completed session:

HTTP
200 OK{"token":"<DRF token>","jwt":{"access":"...","refresh":"..."}}

No TOTP code was submitted and no OTP was sent. Decoding the access token shows the login is complete from the API's point of view:

JSON
{"token_type":"access","user":{"id":1698586,"profile":{"role":"manager"}}}

There is no authentication_flow claim left on the token.

From the original on nowisar.medium.com

Step 3: confirm the token is genuine and the bypass is specific

The researcher checked four things:

  1. The token works. GET /api/v2.0/users/me/ returned 200 with the real account's profile, and GET /api/v1.0/candidates/ returned 200 with real tenant data.
  2. Not any string works. A superseded token returned 401 {"detail":"Invalid token."}, so only a genuine server-minted token is accepted.
  3. The honest path still behaves correctly. Sending the real challenge name, SOFTWARE_TOKEN_MFA, with no code returned 400 {"retry_after":...}, correctly refused. The same happened for NEW_PASSWORD_REQUIRED, PASSWORD and SMS_MFA. MFA_SETUP is the one name that bypasses, and it bypasses specifically on accounts where it should be the least applicable option.
  4. Every gateway is affected. All four target hostnames tested were vulnerable, 4 out of 4.

Step 4: escalate to account takeover

The researcher tested the password change on their own account, with a planned revert:

HTTP
POST /api/v1.0/account/change-password/-H 'Authorization: Token <bypass-derived token>'{"old_password":"<known>","new_password":"<new>","new_password_confirmation":"<new>"}

The response was:

HTTP
200 {"status":"Password changed successfully"}

The old password then returned 400. The new password logged in, and still prompted SOFTWARE_TOKEN_MFA on the next login, because the 2FA enrolment itself was never touched. It was only skipped, not removed.

Root cause

challenge_name should be derived from the session the server already issued, never read from the request. Letting the client choose it turns a step that is supposed to verify a factor into a step where the client picks which factor to satisfy, including none. The server had already recorded the required flow in the session JWT, but did not compare the client-supplied name against it before branching.

Impact

An attacker who knows an account's password can complete login without the second factor, obtaining a full session with the account's role and access to its data. Because the bypass leaves the 2FA enrolment intact, the victim's authenticator app keeps working and their security settings show nothing has changed. Nothing tells them that someone bypassed their second factor on the way to taking the account. With the bypass in play, an account with 2FA enabled is in practice protected by its password alone. The researcher also demonstrated that the bypassed session can change the account password, locking the real owner out. The write-up does not state how many accounts or tenants were affected beyond the researcher's own tests.

Fix

The write-up does not say what the target changed. The stated root cause is that challenge_name should be derived from the session the server issued, never read from the request.

Variants to test

  1. Challenge-name substitution on other multi-step logins. Send a challenge name that requires no answer (setup, enrolment, skip or similar) against an account whose session records a real factor. A positive result is a 200 with a usable access token and no authentication_flow claim.
  2. Compare the session claim with the request field. Decode the intermediate session and check whether the server enforces the recorded flow. A positive result is any request whose challenge_name differs from the session's authentication_flow and is still accepted.
  3. Test every challenge name the API knows. Send each name with no answer and record which return 200 rather than 400. A positive result is one name that completes login on an account where it should not apply.
  4. Check the token after bypass. Call an authenticated endpoint such as a profile or tenant-data route with the bypass-derived token. A positive result is 200 with real data, confirming the token is not a placeholder.
  5. Test the bypassed session for sensitive actions. Attempt a password change or other account-modifying request with the bypass-derived token. A positive result is a 200 that changes state, showing the bypass reaches account takeover.
  6. Repeat across hostnames. Run the same sequence against every hostname serving the API. A positive result is the same bypass on each, showing it is not one misconfigured box.

Timeline

  • Discovery and reproduction: Oct 20, 2026
  • Reported to the target
  • Bounty awarded: $$$ USD
From the original on nowisar.medium.com

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

What happened, in plain words

A security researcher found a way to log into an account without ever typing the six-digit code that a phone app normally produces. The account had two-factor authentication (2FA) turned on, which is the extra step where, after your password, a site asks for a short code from an app or a text message. The researcher still got in, using only the password and one small change to a request.

To understand how, you need three everyday ideas.

  • A website is a front door; an API is the waiter behind it. When you click a button in a browser, the page usually sends a message to a server behind the scenes. That message is an API request. API stands for Application Programming Interface: it is simply the agreed way for one program to ask another program to do something. Think of a restaurant: you (the browser) tell the waiter (the API) what you want, and the waiter goes to the kitchen (the server) and brings back a result.
  • A token is a wristband. After you prove who you are, many sites hand your browser a long string of characters called a token. On every later request you show that string, and the server treats it as proof that you already logged in. It works like the paper wristband you get at an event: show it at the door and you get back in without buying another ticket.
  • 2FA is a second lock. A password is one lock. 2FA adds a second lock that needs a code from your phone. The whole point is that a thief who steals your password still cannot get in, because they do not have your phone.

The bug was in the login process. The login happens in two steps. In step one you send your username and password. If the account has 2FA, the server does not let you in yet. Instead it sends back a note saying, in effect, "this person still owes me a code from their phone app", plus a temporary pass (a session) that remembers this. In step two you send that temporary pass back, together with the code.

The flaw: in step two the server also lets the client say which kind of check it wants to complete. The client is the program making the request, in this case the researcher's tool. The server never checked that this stated kind of check matched the one it had already written down in step one. So the researcher asked to complete a different kind of check, one that needs no code at all, and the server happily handed over a full login.

No code was typed. No text message was sent. The researcher got a complete, working session, and then showed on their own account that such a session could change the password.

From the original on nowisar.medium.com

The setup

The target's login is a two-step handshake. A handshake here just means a back-and-forth: you say something, the server answers, you answer back, and only then is the deal done.

Step one: send a username and a password. If the account has 2FA configured, the server does not log you in yet. It returns an intermediate session, meaning a temporary pass that is not yet a full login, and it tells you exactly what it is waiting for next.

POST /api/v1.0/auth/initiate-auth/{"username":"<victim>","password":"<known password>"}

Line by line:

  • POST is the type of request. Think of it as "here is some information, please act on it". A GET would be "please show me something". POST is used when you are sending data, such as a login form.
  • /api/v1.0/auth/initiate-auth/ is the address of the specific action on the server. auth means authentication, the process of proving who you are. initiate-auth means "start the login". v1.0 is just a version number, like an edition of a book.
  • {"username":"<victim>","password":"<known password>"} is the body of the request, written in JSON. JSON is a simple text format for data, made of names and values in curly brackets. Here it says: the username is the victim's, and the password is one the researcher already knew. The angle brackets are placeholders, not literal text.

The server's answer:

200 OK{"challenge_name":"SOFTWARE_TOKEN_MFA","session":"<JWT>"}

Line by line:

  • 200 OK is the status code. Status codes are three-digit numbers that say how the request went. 200 means "all good, here is your result". You will meet others later: 400 means "your request was wrong", 401 means "you are not allowed", and so on.
  • challenge_name is the name of the check the server wants you to pass. Here it is SOFTWARE_TOKEN_MFA. MFA means multi-factor authentication, the general name for "more than just a password". SOFTWARE_TOKEN means the code comes from a software app on your phone, the kind that shows a new six-digit number every thirty seconds. A TOTP, short for time-based one-time password, is exactly that kind of code.
  • session is the temporary pass mentioned above. The <JWT> placeholder stands for a JWT, a JSON Web Token. A JWT is a token whose contents are readable text, encoded so it can travel safely, and it can carry small facts about you, such as which account it belongs to and what step the login is at.

Decode that session JWT, meaning read its contents, and it confirms the same thing from the server's side:

JSON
{"authentication_flow":"SOFTWARE_TOKEN_MFA","scope":"authentication","user_id":1698586}

Line by line:

  • authentication_flow is the server's own record of which login path this session is on. It says SOFTWARE_TOKEN_MFA, the phone-app code.
  • scope says what the token is for. Here it is authentication, meaning this pass is only good for finishing the login, not for using the account yet.
  • user_id is the account's internal number. It identifies which user this session belongs to.

The server has already decided that this account needs a TOTP code before the login is finished, and that decision is written into the session. It is like a cloakroom ticket with a note on the back saying "this customer must also show ID".

The bug, spelled out

Step two is called respond-to-auth-challenge. In plain words: "here is my answer to the check you asked for". It takes the session back, plus two things that the client supplies: a challenge_name and an answer, the code itself.

The design intent is obvious once you see it. challenge_name should simply be the server's own decision echoed back, like repeating your name at a counter so the clerk can match it to the form. answer is how you prove you cleared the check.

Here is the actual bug: the server never checks that the challenge_name the client sends matches the authentication_flow stored in the session. It just looks at whatever string you send and branches on it. Branching means choosing which piece of code to run based on a value, like a railway switch that sends the train down one track or another depending on how it is set. That means the client gets to pick which check it wants to satisfy, including picking one that requires nothing at all.

MFA_SETUP is the branch meant for a completely different situation: a user who has no second factor yet and is going through the one-time setup screen to add one. It is not supposed to be reachable once SOFTWARE_TOKEN_MFA is the recorded flow. The researcher sent it anyway, against an account that genuinely has 2FA turned on, with no answer field at all:

POST /api/v1.0/auth/respond-to-auth-challenge/{"session":"<session from step 1>","challenge_name":"MFA_SETUP"}

Line by line:

  • POST again: sending data to the server.
  • /api/v1.0/auth/respond-to-auth-challenge/ is the address for step two, the "answer the check" action.
  • "session":"<session from step 1>" is the temporary pass from step one, pasted back in. This is the researcher proving they are the same person who started the login.
  • "challenge_name":"MFA_SETUP" is the trick. Instead of echoing SOFTWARE_TOKEN_MFA, the researcher names the setup branch, the one that needs no code.
  • There is no answer field at all. Nothing is being proved.

The server's answer:

200 OK{"token":"<DRF token>","jwt":{"access":"...","refresh":"..."}}

Line by line:

  • 200 OK means the server accepted it.
  • token is a login token. token is a login token, shown here as a placeholder. You do not need to know the toolkit to follow the story: it is just a string that proves you are logged in.
  • jwt holds two more tokens. access is the one you use on each request, like the wristband. refresh is a longer-lived one used to get a new access token when the old one expires, like a receipt you can swap for a fresh wristband.

No TOTP code was submitted. No OTP was sent. OTP stands for one-time password, a code that is valid once; a TOTP is a type of OTP. A full, finished session was handed back. Decoding the access token confirms it:

JSON
{"token_type":"access","user":{"id":1698586,"profile":{"role":"manager"}}}

Line by line:

  • token_type says this is the access token, the wristband itself.
  • user describes the account it belongs to: id is the same account number as before, and profile says its role is manager. A role is the level of permission an account has, like a staff badge that opens more doors than a visitor badge.

There is no authentication_flow claim left on it. A claim is a fact written inside a token. Its absence means the token is no longer "halfway through a login"; as far as the API is concerned, the login is complete.

From the original on nowisar.medium.com

Proving it is real, not a fluke

A single odd response could be a coincidence, a caching quirk or a mistake in the researcher's tool. So the researcher checked four things.

  1. The token actually works. GET /api/v2.0/users/me/ returned 200 with the real account's profile, and GET /api/v1.0/candidates/ returned 200 with real tenant data. GET means "please show me". users/me means "the profile of whoever this token belongs to". A tenant is one customer organisation on a shared platform, like one company's office inside a shared building. Getting real data back proves the token is not a decorative string.
  2. It is not "any string works". A superseded token, meaning an older token that had been replaced, returned 401 {"detail":"Invalid token."}. 401 means "not allowed". So only a genuine token minted by the server is accepted; the bypass is not simply the server accepting rubbish.
  3. The honest path still works correctly. Sending the real challenge name, SOFTWARE_TOKEN_MFA, with no code returned 400 {"retry_after":...}, correctly refused. 400 means "your request was wrong", and 400 means "your request was wrong". The same happened for NEW_PASSWORD_REQUIRED, PASSWORD and SMS_MFA: other challenge names the API knows, all correctly refused without an answer. MFA_SETUP is the one name that bypasses, and it bypasses specifically on accounts where it should be the least applicable option of all.
  4. It is every gateway, not one misconfigured box. All four target hostnames tested were vulnerable, 4 out of 4. A hostname is the name of a server, the part of a web address before the first slash. Testing several shows the flaw is in the shared code, not in one badly set-up machine.

Taking it from "logic bug" to account takeover

A logic bug is a flaw in the rules the program follows, rather than in a broken lock or a leaked password. The rules are written down in code, and the code here made a wrong decision about who to trust.

A bypass that only grants read access is bad. One that lets the attacker lock the real owner out is a different severity entirely. Severity is how serious a flaw is judged to be. So the researcher tested that too, on their own account, with a planned revert, meaning they intended to undo the change afterwards:

POST /api/v1.0/account/change-password/-H 'Authorization: Token <bypass-derived token>'{"old_password":"<known>","new_password":"<new>","new_password_confirmation":"<new>"}

Line by line:

  • POST /api/v1.0/account/change-password/ is the address for changing the account password.
  • -H 'Authorization: Token <bypass-derived token>' is a header. Headers are extra labels attached to a request, like the address and stamps on an envelope. Authorization is the header where you show your token. The token here is the one obtained through the bypass.
  • The body sends three values: the old_password, the new_password, and new_password_confirmation, which repeats the new password so a typo cannot lock you out. The angle brackets are placeholders again.

The response was:

200 {"status":"Password changed successfully"}

200 means it worked, and the message says the password was changed.

The old password then returned 400, meaning it no longer worked. The new password logged in, and still prompted SOFTWARE_TOKEN_MFA on the next login, because the 2FA enrolment itself was never touched. Enrolment is the act of setting up 2FA in the first place. It was only skipped, not removed.

That is the part that makes this dangerous in practice. The victim's authenticator app keeps working, their security settings show nothing has changed, and nothing tells them that someone bypassed their second factor entirely on the way to taking their account. With 2FA enabled, an account here is, in practice, protected by its password alone: the second factor adds no real barrier once this challenge-name bypass is in play.

Root cause

challenge_name should be derived from the session the server already issued, never read from the request. Letting the client choose it turns a step that is supposed to verify a factor into a step where the client picks which factor to satisfy, including "none". The server had already recorded the required flow in the session JWT, but did not compare the client-supplied name against it before branching.

Impact

An attacker who knows an account's password can complete login without the second factor, obtaining a full session with the account's role and access to its data. Because the bypass leaves the 2FA enrolment intact, the victim's authenticator app keeps working and their security settings show nothing has changed. Nothing tells them that someone bypassed their second factor on the way to taking the account. With the bypass in play, an account with 2FA enabled is in practice protected by its password alone. The researcher also demonstrated that the bypassed session can change the account password, locking the real owner out. The write-up does not state how many accounts or tenants were affected beyond the researcher's own tests.

Fix

The write-up does not say what the target changed. The stated root cause is that challenge_name should be derived from the session the server issued, never read from the request.

Variants to test

Each one names what a positive result looks like, so you know when you have found something.

  1. Challenge-name substitution on other multi-step logins. Send a challenge name that requires no answer, such as setup, enrolment or skip, against an account whose session records a real factor. A positive result is a 200 with a usable access token and no authentication_flow claim.
  2. Compare the session claim with the request field. Decode the intermediate session and check whether the server enforces the recorded flow. A positive result is any request whose challenge_name differs from the session's authentication_flow and is still accepted.
  3. Test every challenge name the API knows. Send each name with no answer and record which return 200 rather than 400. A positive result is one name that completes login on an account where it should not apply.
  4. Check the token after bypass. Call an authenticated endpoint such as a profile or tenant-data route with the bypass-derived token. A positive result is 200 with real data, confirming the token is not a placeholder.
  5. Test the bypassed session for sensitive actions. Attempt a password change or other account-modifying request with the bypass-derived token. A positive result is a 200 that changes state, showing the bypass reaches account takeover.
  6. Repeat across hostnames. Run the same sequence against every hostname serving the API. A positive result is the same bypass on each, showing it is not one misconfigured box.

Timeline

  • Discovery and reproduction: Oct 20, 2026
  • Reported to the target
  • Bounty awarded: $$$ USD
From the original on nowisar.medium.com

Glossary

  • 2FA (two-factor authentication): a login that needs two things, usually a password plus a code from a phone, so a stolen password alone is not enough.
  • API (Application Programming Interface): the agreed way for one program to ask another to do something; the waiter between your browser and the server.
  • API request: one message sent to an API, such as "start a login".
  • Access token: the token you show on each request to prove you are logged in; the wristband.
  • Authentication: the process of proving who you are, usually with a password and possibly a code.
  • authentication_flow: the server's own record, stored in the session, of which login path the user is on.
  • Authorization header: the part of a request where you attach your token, like the stamp on an envelope.
  • Body: the part of a request that carries data, such as a username and password.
  • Branch: to choose which piece of code to run based on a value, like a railway switch.
  • Bypass: getting past a check without satisfying it.
  • Challenge: a check the server asks you to pass, such as entering a code.
  • challenge_name: the name of the check the client says it wants to complete.
  • Claim: a fact written inside a token, such as which account it belongs to.
  • Client: the program making the request, such as a browser or a testing tool.
  • Decode: to read the contents of a token, which are encoded rather than secret.
  • DRF (Django REST Framework): a toolkit for building APIs in the Python language; here it names the kind of token issued.
  • Enrolment: the act of setting up 2FA on an account in the first place.
  • GET: a request that asks to be shown something, rather than to change something.
  • Handshake: a back-and-forth exchange where each side answers the other before the deal is done.
  • Header: an extra label attached to a request, such as where to send it or who is asking.
  • Hostname: the name of a server, the part of a web address before the first slash.
  • Impact: how much harm a flaw could cause if abused.
  • Intermediate session: a temporary pass issued halfway through a login, not yet a full login.
  • JSON: a simple text format for data, made of names and values in curly brackets.
  • JWT (JSON Web Token): a token whose contents are readable text, carrying small facts about the user and the login step.
  • Logic bug: a flaw in the rules a program follows, rather than in a broken lock or a leaked password.
  • MFA (multi-factor authentication): the general name for logging in with more than just a password.
  • MFA_SETUP: the branch meant for a user who has no second factor yet and is setting one up; it needs no code.
  • OTP (one-time password): a code valid once; a TOTP is a type of OTP.
  • Password change endpoint: the address that changes an account's password.
  • POST: a request that sends data and asks the server to act on it, such as a login form.
  • Refresh token: a longer-lived token used to get a new access token when the old one expires.
  • Request: one message sent from a client to a server.
  • Response: the server's reply to a request.
  • Role: the level of permission an account has, like a staff badge versus a visitor badge.
  • Root cause: the underlying mistake in the code that makes the flaw possible.
  • Scope: what a token is allowed to be used for.
  • Session: a temporary pass that remembers who you are partway through a process.
  • Severity: how serious a flaw is judged to be.
  • SOFTWARE_TOKEN_MFA: the challenge name for a code from a phone app.
  • Status code: a three-digit number in a response saying how the request went, such as 200, 400 or 401.
  • Superseded token: an older token that has been replaced and is no longer accepted.
  • Tenant: one customer organisation on a shared platform.
  • Token: a long string of characters that proves you are logged in, like an event wristband.
  • TOTP (time-based one-time password): a six-digit code from an app that changes every thirty seconds.
  • Vulnerable: open to being abused by an attacker.
  • 401: the status code meaning "not allowed".
  • 400: the status code meaning "your request was wrong".
  • 200: the status code meaning "all good, here is your result".

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.