Skip to content
Account takeover Write-up Intermediate

How I was able to bypass OTP code requirement in Razer [The story of a critical bug]

The application validated the OTP token without checking that it belonged to the same user, so an attacker could use their own valid OTP token to bypass the OTP requirement when changing a victim's email address. This allowed an attacker with the victim's credentials to change the victim's email without knowing the OTP code.

Ananda Dhakal Follow

Published on medium.com

Bounty$1,000 View original

{{media:0}}

Ananda Dhakal, 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. 7 min read.

Context

Razer ran a bug bounty program on HackerOne. The researcher, Ananda Dhakal (@dhakal_ananda), had been invited to the private program before it went public and had declined the invitation; when the program became public it caught his attention and he started testing straight away. His stated interest is bypassing security functionality rather than hunting XSS or SQLi, and the OTP (one-time password) requirement on the Razer ID account page is what drew him in first.

The feature under test is the account settings page at razerid.razer.com/account. When a user tries to change sensitive information, in this case the email address, the application asks for an OTP code. The application validates whether the OTP has been entered using a long token, and that OTP token is only issued after a valid OTP code has been entered.

Ananda Dhakal
Ananda Dhakal From the original on medium.com

Setup

  • Two accounts: an attacker account and a victim account. The researcher assumes the attacker knows the victim's credentials, which is the condition the triage team later asked for in a PoC.
  • A proxy that can intercept and replay requests, with a repeater tab for resending modified requests.
  • The captured request carries a Chrome 77 on Windows User-Agent header.
  • No special tooling beyond fuzzing and manual request manipulation is described.

Finding it

After fuzzing for a while, the researcher found that the application used a long token to validate whether the OTP code had been entered, and that this token was only provided after a valid OTP code was submitted. The idea he pursued was to use the attacker's token to validate the victim's token. He tried it and it worked.

Image for post
Image for post From the original on medium.com

Exploitation

The simplified reproduction the researcher published is as follows.

  1. Log in to the attacker's account.
  2. Go to https://razerid.razer.com/account and click on the email field.
  3. A dialog appears saying that an OTP code must be entered.
  4. Enter the valid code and intercept the request that changes the email.
  5. Send the request to repeater.
  6. Log in to the victim's account, assuming the attacker has the victim's credentials.
  7. Intercept the request that changes the name.
  8. Copy the user_id and user_token and save them in a file.
  9. Paste the victim's user_id and user_token into the attacker's user_id and user_token fields in the request sitting in the repeater.
  10. Submit the request: the email address is added to the victim's account without the OTP token requirement.

The captured request looks like this:

HTTP
POST /api/emily/7/user-security/post HTTP/1.1Host: razerid.razer.comConnection: closeContent-Length: 260Accept: application/json, text/plain, */*Origin: https://razerid.razer.comUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36DNT: 1Sec-Fetch-Mode: corsContent-Type: application/json;charset=UTF-8Sec-Fetch-Site: same-originReferer: https://razerid.razer.com/account/emailAccept-Encoding: gzip, deflateAccept-Language: en-GB,en-US;q=0.9,en;q=0.8Cookie: ...{"data":"<COP><User><ID>user_id</ID><Token>user_token</Token><OTPToken>otp_token_value_here</OTPToken><login><email>[redacted]</email><method>add</method><primary>1</primary></login></User><ServiceCode>0060</ServiceCode></COP>"}

The researcher notes that this simplified reproduction is not the same as what he submitted in the report; it is simplified and is the actual steps with an exploitable PoC.

Root cause

The application did not validate the cookies and other things. All it validated was user_id, user_token and OTP_token. The OTP_token was validated only for being a valid token, not for belonging to the specific user. As a result, the attacker's token could be pasted into the victim's request and OTP validation for the victim account was bypassed.

The first submission and the misunderstanding

The report was not accepted smoothly. The researcher submitted it with a different, more complicated set of reproduction steps. Those steps and the simplified ones above reach the same end result; the submitted version was simply harder to follow. Following those steps did give access to the victim's settings, and that was what he found first: it involved changing the response and doing things repeatedly.

Image for post
Image for post From the original on medium.com

From those steps, the team members thought the issue would require physical access to the victim's device or browser. The researcher had fuzzed extensively to reach those final steps, but the HackerOne triage team member asked for more information.

He replied, in his own later assessment, with something that did not really answer the question. The report was then closed as Informative. He asked for the internal team to evaluate the issue; the internal team member said it was not a valid issue and also did not clearly understand what he was trying to say. He asked for the report to be reopened so he could self-close it, since they did not seem to understand it at all. He adds that he did not fully understand it himself at that point either. The report was reopened so he could self-close it, because closing it did not have a negative impact on his signal.

His tip from this episode: before submitting a bug like this, make sure the reproduction steps are clear and simplify them as much as possible, because a bug you understand may not be understood by the team member, and you can end up with an N/A or Informative as he did.

Getting it triaged

He left the report and moved on. Three days later he came back to it because he realised something: most applications ask for the 2FA code at login, but this one asked for it when he tried to change sensitive information. He commented on the report that he was bypassing the 2FA requirement, so it had to be a valid vulnerability.

A day later he got a reply along the lines of:

If you have a PoC where you have access only to the victim user's Razer ID account and password and then can access or change profile information, it would be a valid report.

The team member provided the email address and password of a test account so he could change its email address. He changed the email address of that account without accessing the OTP token and removed the previous email, then reported that the email had been changed and that the account could no longer be accessed with the previous email.

One day later the report was reopened and set to Triaged with severity Critical.

Impact

With only a Razer ID account and password, the researcher changed the email address of a test account without accessing the OTP token. In the test-account demonstration he changed the email address and removed the previous email, then said the account could not be accessed with the previous email. The precondition is knowledge of the victim's credentials; the bypass removes the second factor that the application places in front of sensitive account changes.

Fix

The report does not describe the fix. The researcher notes that after two days he intended to write this up and record a video, but the issue was fixed before he could create a video PoC. He was awarded $1000 in total: a $750 bounty and a $250 bonus for the very long misunderstanding. He also mentions finding another OTP bypass a few days into triage, already resolved with a fast and efficient fix, with the bounty pending; no details of that second issue are given.

Variants to test

  • Cross-user token reuse. Take a token issued to your own account after completing an OTP challenge and place it in a request that carries another user's identifier and token. A positive result is the action succeeding for the other user without a fresh OTP challenge.
  • Token validity versus token ownership. Wherever a token is checked, ask whether the check is only "is this a valid token" rather than "is this token valid for this user". A positive result is any endpoint that accepts a token minted for a different session.
  • Context fields ignored. Remove or alter cookies and other context headers while keeping the identifier and token fields intact. A positive result is the request still being accepted.
  • Sensitive-action 2FA. Look for applications that prompt for 2FA on profile or email changes rather than at login, and test whether the prompt can be satisfied with a token from another account.

His closing tip: fuzz the parameters and use one user's tokens in another user's session, because there can be token validation that is missing user-token validation.

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

Razer is a company that makes gaming hardware and runs an online account system called Razer ID. People use a Razer ID to log in to Razer's website and services. Razer also ran a bug bounty programme on a platform called HackerOne. A bug bounty programme is an offer from a company: if you find a security flaw in our systems and report it responsibly, we will pay you a reward (a "bounty"). HackerOne is the website where those reports are filed, discussed and tracked.

The researcher in this story is Ananda Dhakal, who posts as @dhakal_ananda. He had been invited to Razer's private programme before it became public and declined the invitation. When the programme went public he became interested and started testing straight away. He says his interest is in bypassing security functionality rather than hunting for XSS or SQLi (two other common classes of web bug). The thing that caught his eye first was the OTP requirement on the Razer ID account page.

OTP stands for one-time password: a short code, often sent by email or text message, that is valid for a single use. It is a second factor, meaning something you have or receive in addition to your password. The idea is that even if someone steals your password, they still cannot get in or make sensitive changes without the code. The feature under test is the account settings page at razerid.razer.com/account. When a user tries to change sensitive information, in this case the email address, the application asks for an OTP code. The application checks whether the OTP has been entered by using a long token, and that OTP token is only issued after a valid OTP code has been entered.

A token here is a long string of characters that the server hands out and later accepts as proof that something happened. Think of a cloakroom ticket: you hand in your coat, you get a ticket, and later the ticket gets your coat back. The ticket is not your name; it is just proof that you were there. The bug in this story is that the cloakroom attendant never checked whose coat the ticket belonged to.

Ananda Dhakal
Ananda Dhakal From the original on medium.com

The setup

To follow along you need to understand a few everyday ideas first.

  • A request and a response. When you use a website, your browser sends a request to a server ("please show me this page" or "please change my email") and the server sends back a response. Most of what a security tester does is look at these requests and responses.
  • An API. An API (application programming interface) is the part of a website that the browser talks to behind the scenes, usually exchanging data rather than whole web pages. If the website is a restaurant dining room, the API is the kitchen door where orders go in and plates come out.
  • A proxy. A proxy is a tool that sits between your browser and the server. Instead of your browser talking directly to the server, it talks to the proxy, and the proxy forwards the message. This lets you read every request and response, and change them before they are sent. A repeater is a feature of such a proxy that lets you take one captured request, edit it, and send it again as many times as you like without redoing all the clicks in the browser.
  • Fuzzing. Fuzzing means trying lots of small variations of an input to see how the application reacts. It is like jiggling every handle on a row of doors to see which one is unlocked.
  • A cookie. A cookie is a small piece of data your browser stores for a website and sends back with every request, so the server can recognise your session. It is like a wristband at an event: the staff glance at it to know you are allowed in.

The researcher's setup was:

  • Two accounts: an attacker account and a victim account. The researcher assumes the attacker knows the victim's credentials, which is the condition the triage team later asked for in a PoC.
  • A proxy that can intercept and replay requests, with a repeater tab for resending modified requests.
  • The captured request carries a Chrome 77 on Windows User-Agent header.
  • No special tooling beyond fuzzing and manual request manipulation is described.

Finding it

After fuzzing for a while, the researcher found that the application used a long token to validate whether the OTP code had been entered, and that this token was only provided after a valid OTP code was submitted. In other words, the server's proof that "this person passed the OTP check" was a token, and you only got that token by actually passing the check.

The idea he pursued was to use the attacker's token to validate the victim's token. He tried it and it worked. The logic is simple once you see it: if the server only asks "is this a valid OTP token?" and never asks "is this OTP token valid for this particular user?", then a token earned by one account can be used to satisfy the check for another account.

Image for post
Image for post From the original on medium.com

Exploitation

The simplified reproduction the researcher published is as follows.

  1. Log in to the attacker's account.
  2. Go to https://razerid.razer.com/account and click on the email field.
  3. A dialog appears saying that an OTP code must be entered.
  4. Enter the valid code and intercept the request that changes the email.
  5. Send the request to repeater.
  6. Log in to the victim's account, assuming the attacker has the victim's credentials.
  7. Intercept the request that changes the name.
  8. Copy the user_id and user_token and save them in a file.
  9. Paste the victim's user_id and user_token into the attacker's user_id and user_token fields in the request sitting in the repeater.
  10. Submit the request: the email address is added to the victim's account without the OTP token requirement.

Why each step is there:

  1. You need a real account of your own so you can earn a genuine OTP token by passing the check legitimately. That token is the key to the whole trick.
  2. The account page is where the sensitive change lives. Clicking the email field is what triggers the application to ask for the OTP.
  3. The dialog confirms that the application is protecting this action with a second factor. That is the protection we are about to test.
  4. You complete the check honestly so the server issues you a valid OTP token, and you capture the request that carries it. This is your own, legitimate token.
  5. The repeater lets you keep this captured request and edit it later, without having to repeat the browser steps.
  6. You now need the victim's identifiers, so you log in as the victim (the scenario assumes the attacker already has the victim's password).
  7. Changing the name is simply an action that produces a request containing the victim's user_id and user_token. Any request that carries those values would do; this is the one the researcher used.
  8. You save the victim's identifiers so you can move them into the attacker's captured request.
  9. This is the actual attack: you take the request that was made with your own account and your own valid OTP token, and you swap in the victim's identifiers. The OTP token stays yours.
  10. If the server accepts this, the change is applied to the victim's account even though the OTP token belongs to the attacker. That is the bypass.

The captured request looks like this:

HTTP
POST /api/emily/7/user-security/post HTTP/1.1Host: razerid.razer.comConnection: closeContent-Length: 260Accept: application/json, text/plain, */*Origin: https://razerid.razer.comUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36DNT: 1Sec-Fetch-Mode: corsContent-Type: application/json;charset=UTF-8Sec-Fetch-Site: same-originReferer: https://razerid.razer.com/account/emailAccept-Encoding: gzip, deflateAccept-Language: en-GB,en-US;q=0.9,en;q=0.8Cookie: ...{"data":"<COP><User><ID>user_id</ID><Token>user_token</Token><OTPToken>otp_token_value_here</OTPToken><login><email>[redacted]</email><method>add</method><primary>1</primary></login></User><ServiceCode>0060</ServiceCode></COP>"}

Line by line, in plain words:

  • POST /api/emily/7/user-security/post HTTP/1.1 is the first line of the request. POST is the method, meaning "I am sending data and asking you to do something with it". The path /api/emily/7/user-security/post is the address of the API endpoint on the server. HTTP/1.1 is the version of the protocol being spoken.
  • Host: razerid.razer.com tells the server which site the request is for. One server can host many sites, so this is how it knows which one you mean.
  • Connection: close asks that the network connection be closed after this exchange rather than kept open.
  • Content-Length: 260 says how many bytes of body follow. The server uses it to know when the body ends.
  • Accept: application/json, text/plain, */* says which response formats the browser is willing to accept: JSON, plain text, or anything.
  • Origin: https://razerid.razer.com tells the server which site the request came from. Browsers add this automatically for cross-origin requests, and servers can use it as a security check.
  • User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36 identifies the browser and operating system. This is where the report's note about Chrome 77 on Windows comes from.
  • DNT: 1 is the Do Not Track header, a browser preference about tracking.
  • Sec-Fetch-Mode: cors is a header modern browsers add to describe the kind of request being made.
  • Content-Type: application/json;charset=UTF-8 says the body is JSON text encoded in UTF-8. JSON is a common text format for structured data, using curly braces, quoted names and values.
  • Sec-Fetch-Site: same-origin says the request is being made from the same site as the target.
  • Referer: https://razerid.razer.com/account/email says which page the request was made from. Servers sometimes check this to make sure requests come from their own pages.
  • Accept-Encoding: gzip, deflate lists the compression formats the browser can handle for the response.
  • Accept-Language: en-GB,en-US;q=0.9,en;q=0.8 lists the user's preferred languages, with quality values after the semicolons.
  • Cookie: ... is where the browser's cookies would go. The report shows it elided, so we do not know what was in it.
  • XML is another text format for structured data, using tags in angle brackets.

The researcher notes that this simplified reproduction is not the same as what he submitted in the report; it is simplified and is the actual steps with an exploitable PoC. A PoC, or proof of concept, is a concrete demonstration that the bug really works, rather than a description of why it might.

Root cause

The application did not validate the cookies and other things. All it validated was user_id, user_token and OTP_token. The OTP_token was validated only for being a valid token, not for belonging to the specific user. As a result, the attacker's token could be pasted into the victim's request and OTP validation for the victim account was bypassed.

This is the heart of the lesson. There are two different questions a server can ask about a token: "is this a real token that we issued?" and "is this token the right one for the account named in this request?". The first question was asked. The second was not. A token is like a receipt: the shop checked that the receipt was genuine, but never checked that it was for the item you were walking out with.

The first submission and the misunderstanding

The report was not accepted smoothly. The researcher submitted it with a different, more complicated set of reproduction steps. Those steps and the simplified ones above reach the same end result; the submitted version was simply harder to follow. Following those steps did give access to the victim's settings, and that was what he found first: it involved changing the response and doing things repeatedly.

Image for post
Image for post From the original on medium.com

From those steps, the team members thought the issue would require physical access to the victim's device or browser. That is a serious misunderstanding: if a bug only works when you are holding someone's phone, it is far less severe than a bug that works remotely with just a password. The researcher had fuzzed extensively to reach those final steps, but the HackerOne triage team member asked for more information.

He replied, in his own later assessment, with something that did not really answer the question. The report was then closed as Informative. On HackerOne, "Informative" is a status meaning the report contained useful information but was not treated as a valid vulnerability. He asked for the internal team to evaluate the issue; the internal team member said it was not a valid issue and also did not clearly understand what he was trying to say. He asked for the report to be reopened so he could self-close it, since they did not seem to understand it at all. He adds that he did not fully understand it himself at that point either. The report was reopened so he could self-close it, because closing it did not have a negative impact on his signal. "Signal" is HackerOne's measure of how reliable a researcher's reports have been; a badly received report can lower it.

His tip from this episode: before submitting a bug like this, make sure the reproduction steps are clear and simplify them as much as possible, because a bug you understand may not be understood by the team member, and you can end up with an N/A or Informative as he did. N/A means "not applicable", another status for reports that are not accepted.

Getting it triaged

He left the report and moved on. Three days later he came back to it because he realised something: most applications ask for the 2FA code at login, but this one asked for it when he tried to change sensitive information. 2FA means two-factor authentication, the general practice of requiring two different kinds of proof. He commented on the report that he was bypassing the 2FA requirement, so it had to be a valid vulnerability. The reframing matters: the same technical behaviour looks much more serious when described as "the second factor can be skipped for a sensitive action" than when described as a complicated sequence of edits.

A day later he got a reply along the lines of:

If you have a PoC where you have access only to the victim user's Razer ID account and password and then can access or change profile information, it would be a valid report.

The team member provided the email address and password of a test account so he could change its email address. He changed the email address of that account without accessing the OTP token and removed the previous email, then reported that the email had been changed and that the account could no longer be accessed with the previous email. This is the clean demonstration: only a username and password, no OTP, and the previous email was removed.

One day later the report was reopened and set to Triaged with severity Critical. Triaged means the report has been reviewed and accepted as a real issue worth working on. Critical is the highest severity rating.

Impact

With only a Razer ID account and password, the researcher changed the email address of a test account without accessing the OTP token. In the test-account demonstration he changed the email address and removed the previous email, then said the account could not be accessed with the previous email. The precondition is knowledge of the victim's credentials; the bypass lets the OTP requirement be satisfied with another account's token.

That is why changing it is treated as a sensitive action and why it was protected by an OTP in the first place.

Fix

The report does not describe the fix. The researcher notes that after two days he intended to write this up and record a video, but the issue was fixed before he could create a video PoC. He was awarded $1000 in total: a $750 bounty and a $250 bonus for the very long misunderstanding. He also mentions finding another OTP bypass a few days into triage, already resolved with a fast and efficient fix, with the bounty pending; no details of that second issue are given.

Variants to test

These are the general lessons to carry to other applications.

  • Cross-user token reuse. Take a token issued to your own account after completing an OTP challenge and place it in a request that carries another user's identifier and token. A positive result is the action succeeding for the other user without a fresh OTP challenge.
  • Token validity versus token ownership. Wherever a token is checked, ask whether the check is only "is this a valid token" rather than "is this token valid for this user". A positive result is any endpoint that accepts a token minted for a different session.
  • Context fields ignored. Remove or alter cookies and other context headers while keeping the identifier and token fields intact. A positive result is the request still being accepted.
  • Sensitive-action 2FA. Look for applications that prompt for 2FA on profile or email changes rather than at login, and test whether the prompt can be satisfied with a token from another account.

His closing tip: fuzz the parameters and use one user's tokens in another user's session, because there can be token validation that is missing user-token validation.

Glossary

  • API: the part of a website that the browser talks to behind the scenes, usually exchanging data rather than whole pages.
  • Attacker account: the account the tester controls, used to earn a legitimate token.
  • Bounty: a reward paid by a company for a responsibly reported security flaw.
  • Bug bounty programme: a company's standing offer to pay for security reports.
  • Cookie: a small piece of data the browser stores for a site and sends back with each request, used to recognise a session.
  • Critical: the highest severity rating for a vulnerability.
  • Cross-user token reuse: using a token issued to one account in a request for another account.
  • DNT: Do Not Track, a browser header expressing a tracking preference.
  • Fuzzing: trying many small variations of an input to see how an application reacts.
  • HackerOne: the platform where bug bounty reports are filed and discussed.
  • Header: a line of metadata at the top of a request or response, such as Host or Content-Type.
  • Informative: a report status meaning the report was useful but not accepted as a valid vulnerability.
  • JSON: a text format for structured data using curly braces, quoted names and values.
  • N/A: "not applicable", a status for reports that are not accepted.
  • OTP: one-time password, a short code valid for a single use, used as a second factor.
  • OTP token: the long token the server issues after a valid OTP code is entered, used as proof that the check was passed.
  • PoC: proof of concept, a concrete demonstration that a bug works.
  • POST: an HTTP method meaning data is being sent and an action requested.
  • Proxy: a tool that sits between browser and server so requests and responses can be read and modified.
  • Repeater: a proxy feature for editing and resending a captured request repeatedly.
  • Request / response: the message your browser sends to a server and the message the server sends back.
  • Severity: a rating of how serious a vulnerability is.
  • Signal: HackerOne's measure of how reliable a researcher's reports have been.
  • SQLi: SQL injection, a class of web bug where attacker-supplied input changes a database query.
  • Token: a long string the server hands out and later accepts as proof that something happened.
  • Triaged: a report status meaning the report has been reviewed and accepted as a real issue.
  • 2FA: two-factor authentication, requiring two different kinds of proof to act.
  • User-Agent: a header identifying the browser and operating system.
  • Victim account: the account being attacked, whose credentials the attacker is assumed to know.
  • XSS: cross-site scripting, a class of web bug where attacker-supplied script runs in another user's browser.
  • XML: a text format for structured data using tags in angle brackets.

More from Razer

View all

The newest disclosed reports for this program.

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.