Skip to content
Account takeover Write-up Intermediate

An Unusual Tale of Email Verification Bypass

The email change process sent a 4-digit OTP to the new address without rate limiting, but after 120 attempts a hidden client-side parameter 'sec' was added, causing correct OTPs to be rejected. By removing this parameter, an attacker could brute-force the OTP and change the account email to any victim's address.

Sagar Sajeev Follow

Published on sagarsajeev.medium.com

In this small writeup I would like to share how I reported a case of Email Verification Bypass. But what makes it unique is the way in which it has to be exploited.

Sagar Sajeev, on sagarsajeev.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 describes an email verification bypass in the account settings of a web application. The researcher refers to the target only as https://www.redacted.com/account/login, so the product itself is not identified. The affected feature is the change email option inside an authenticated account: a user asks to move the account from one address to another, and the application confirms the change by sending a 4 digit OTP to the new address. The OTP has to be typed back into the page before the change is accepted.

What makes the case interesting is not the bypass itself, which the author calls a common bug, but the way the application behaved once the OTP was being guessed. A hidden parameter appeared in the requests, and the correct OTP was rejected until that parameter was removed.

Setup

  • Two email addresses are used throughout: [redacted], the account the researcher controls, and [redacted], the address the account is being moved to.
  • The only tool named in the report is Burp Suite's Repeater, used to send the OTP attempts manually and to inspect each request.
  • No versions, browser details or other tooling are given.
  • The precondition is an authenticated session on the attacker account and access to the change email feature.

Finding it

The flow starts normally. The researcher logs in as [redacted], opens the change email option and submits [redacted] as the new address. The application sends a 4 digit OTP to [redacted] to confirm the change.

No rate limit was set on the OTP check, so the correct OTP could be found by bruteforcing. The surprise came afterwards: when the correct OTP was submitted, the page showed incorrect OTP.

From the original on sagarsajeev.medium.com

At this point the researcher could not understand why the website rejected a value that was known to be correct. Every request was inspected manually in Repeater, and after about two hours of trial and error a hidden parameter called sec turned up embedded in the request.

The parameter was peculiar in two ways:

  1. It appeared only after the 120th request in Repeater. The researcher verified this three times and it was indeed appearing only after the 120th request.
  2. From the 120th request onwards it incremented by a step value of 1:

120th request has sec value 1

121st request has sec value 2

122nd request has sec value 3

123rd request has sec value 4

etc

Every attempt after the 120th request also led to a 302 redirect to a different subdomain. The researcher is not sure of the reason, but suggests it may be a way for the target to reduce traffic on the website or to prevent bruteforce attacks.

Exploitation

Step 1: start the email change

Log in as [redacted] and use the change email option to set the address to [redacted]. A 4 digit OTP is sent to [redacted] to confirm the change.

Step 2: bruteforce the OTP

Because no rate limit was set, the correct OTP can be found by bruteforcing the 4 digit value. The report does not include the raw request used for this, only that the attempts were sent through Repeater.

Step 3: observe the rejection

Submitting the correct OTP returns a page saying the OTP is incorrect. This is the point where the flow stops working as expected.

From the original on sagarsajeev.medium.com

Step 4: find the hidden parameter

Inspecting the bruteforce requests manually shows a parameter named sec embedded in the request. It first appears on the 120th request and increases by 1 on each request after that. From the same point, responses become a 302 redirect to a different subdomain.

Step 5: remove the parameter

The sec parameter was heavily dependent on the client side. Removing it from the 120th request removes the parameter from every subsequent request.

Step 6: repeat the bruteforce and submit

With sec gone, the OTP bruteforcing is repeated, the correct OTP is obtained and typed in. The email is then changed from [redacted] to [redacted].

From the original on sagarsajeev.medium.com

Root cause

The report does not describe the server side implementation, so the following is likely rather than confirmed. The application appears to add a client side counter, sec, to requests once a threshold of attempts is crossed, and the correct OTP was rejected while it was present. Because the parameter is generated and attached on the client, an attacker who removes it from the request also removes it from every later request.

No rate limit was set on the OTP check, so the correct OTP could be found by bruteforcing, and the only obstacle was a client controlled parameter that could be dropped.

Impact

As the author puts it, the issue can be used to bypass email verification. An attacker can create an account on behalf of any person without having access to that email account. The report does not go beyond this statement, and no severity or CVSS score is given.

Fix

The report does not say what the target changed. Based on the behaviour described, the counter should be enforced on the server rather than trusted from the client, and the OTP check should be rate limited so that a 4 digit code cannot be exhausted.

Variants to test

  • Client side counters on OTP or verification endpoints. Submit a wrong OTP repeatedly and watch for new parameters appearing after a threshold. A positive result is a parameter that shows up only after N attempts and increments by a fixed step.
  • Removing the counter. Delete the new parameter from the request where it first appears and continue. A positive result is that the parameter stays absent from later requests and the correct OTP is accepted.
  • Threshold behaviour. Note the attempt number at which the parameter and any redirect appear. A positive result is a consistent threshold, here the 120th request, that can be stepped over.
  • Rate limiting on short codes. Try a 4 digit OTP space with no throttling. A positive result is that the full space can be tried and the correct code recovered.
  • Redirect after threshold. Check whether responses switch to a 302 to another subdomain after the threshold. A positive result is a redirect that does not actually block the verification attempt.

Timeline

Submitted : 02-07-2022

Accepted : 03-08-2022

Rewarded with Swag : 09-08-2022

The researcher notes that the report was submitted a while back and that the security team replied only last week, by which time the finding had been forgotten. The reward was swag rather than a cash bounty.

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

What happened, in plain words

A website let people change the email address linked to their account. To make sure the new address really belonged to you, the site sent a short code (a one-time password, or OTP) to that new address, and you had to type the code back into the page. The researcher found that the site did not limit how many times you could guess the code, so a 4 digit code could simply be tried until the right one was found. That alone is a common weakness.

The unusual part came next. Even when the researcher typed the correct code, the site said it was wrong. After inspecting the requests by hand for about two hours, the researcher noticed a hidden extra field called sec appearing in the requests, but only from the 120th attempt onwards, and counting up by one each time. Removing that field from the request made it disappear from all later requests too, and then the correct code was accepted and the email address on the account was changed to one the attacker did not control.

In plain terms: the site tried to slow down guessing with a counter that lived in the browser, and the browser (or the person driving it) could simply throw the counter away.

From the original on sagarsajeev.medium.com

The pieces you need to know first

Before walking through the steps, here are the ideas the report relies on. None of them require any special software to understand.

  • Account and login. A website account is a record the site keeps about you, identified by your email address and protected by a password. Logging in proves to the site that you are the person who owns that account.
  • Change email feature. Inside account settings, many sites let you move your account from one email address to another. This is useful when you change jobs or stop using an old address. Because email is often used to reset passwords, changing it is sensitive: if an attacker can move your account to their address, they can then take it over.
  • OTP (one-time password). A short numeric code that is valid for a single use, usually sent by email or text message. It proves you can read messages sent to a particular address. A 4 digit OTP has 10,000 possible values (0000 to 9999).
  • Bruteforcing. Trying every possible value of something until the right one is found. For a 4 digit code, that means at most 10,000 attempts. A computer can send that many requests quickly, which is why sites are expected to limit attempts.
  • Rate limiting. A rule that says "you may only try this a certain number of times per minute" or "after N failures, stop accepting attempts". It is the main defence against bruteforcing short codes. The report says no rate limit was set on the OTP check.
  • HTTP request and response. When you click a button in a browser, the browser sends a request to the website's server (the computer that runs the site), and the server sends back a response, usually a web page. A tool like Burp Suite lets you see and edit these requests before they are sent.
  • Burp Suite Repeater. A feature of the Burp Suite security tool that lets you take a single request, edit it, send it again and again, and read each response. The researcher used it to send OTP attempts manually and to inspect every request. The report names no other tool and gives no versions or browser details.
  • Parameter (or field). A named piece of data inside a request, such as email=[redacted]. Parameters are how a browser tells the server what the user typed or clicked.
  • Hidden parameter. A parameter the page does not show you in a form, but which the browser adds to the request anyway, usually through JavaScript running in the page. Because it is added by the browser, the person controlling the browser can also remove it.
  • Client side and server side. "Client side" means the work happens in your browser (the client). "Server side" means it happens on the website's computer (the server). A check done only on the client side can be bypassed by anyone who controls the client, because they can change what the browser sends.
  • 302 redirect. An HTTP response that tells the browser "the thing you asked for is somewhere else, go there instead". It is a normal way to move a visitor from one page or subdomain to another.
  • Subdomain. A section of a domain name, for example shop.example.com is a subdomain of example.com. The report says that after the 120th request, responses redirected to a different subdomain, but it does not name it.
  • Email verification bypass. The vulnerability class here. The site is supposed to verify that the person changing the email address can read messages sent to the new address. A bypass means the attacker gets the change accepted without that proof, so the account can be moved to an address the attacker does not own.

The setup

Two email addresses are used throughout the report:

  • [redacted]: the account the researcher controls and is logged into.
  • [redacted]: the address the account is being moved to. The attacker does not have access to it.

The only precondition is an authenticated session on the attacker account, plus access to the change email feature. The target is referred to only as:

Text
https://www.redacted.com/account/login

That is the login page of the site. The product itself is not identified in the report.

Finding it, step by step

The flow starts normally, and each step below explains why it was taken.

  1. Log in as [redacted]. You need a real account to reach the change email option, because the feature only exists for logged-in users.
  2. Open the change email option and set the new address to [redacted]. This is the action being attacked: moving an account to an address the attacker does not control.
  3. The site sends a 4 digit OTP to [redacted]. This is the site's proof step. Only someone who can read mail at that address should be able to complete the change.
  4. Guess the OTP. Because no rate limit was set, the correct OTP could be found by bruteforcing. With only 10,000 possible values and no limit on attempts, this is practical.
  5. Submit the correct OTP and watch it fail. The page showed incorrect OTP even though the value was known to be right. This is the puzzle the rest of the report solves.
From the original on sagarsajeev.medium.com

At this point the researcher could not understand why the website rejected a value that was known to be correct. Every request was inspected manually in Repeater, and after about two hours of trial and error a hidden parameter called sec turned up embedded in the request.

The parameter was peculiar in two ways:

  1. It appeared only after the 120th request in Repeater. The researcher verified this three times and it was indeed appearing only after the 120th request.
  2. From the 120th request onwards it incremented by a step value of 1:

120th request has sec value 1

121st request has sec value 2

122nd request has sec value 3

123rd request has sec value 4

etc

Every attempt after the 120th request also led to a 302 redirect to a different subdomain. The researcher is not sure of the reason, but suggests it may be a way for the target to reduce traffic on the website or to prevent bruteforce attacks.

In everyday terms: imagine a shop that, after your 120th question, starts stamping a number on each of your questions and quietly sending you to a different counter. If you do not carry the stamp, the person at the counter refuses to help, even when your question is correct.

Exploitation

Step 1: start the email change

Log in as [redacted] and use the change email option to set the address to [redacted]. A 4 digit OTP is sent to [redacted] to confirm the change. This step is unchanged from normal use; it just sets up the situation.

Step 2: bruteforce the OTP

Because no rate limit was set, the correct OTP can be found by bruteforcing the 4 digit value. The report does not include the raw request used for this, only that the attempts were sent through Repeater. The reason to do this is simple: the attacker cannot read mail at [redacted], so guessing is the only way to learn the code.

Step 3: observe the rejection

Submitting the correct OTP returns a page saying the OTP is incorrect. This is the point where the flow stops working as expected. The reason to pause here is that a correct value was being rejected.

From the original on sagarsajeev.medium.com

Step 4: find the hidden parameter

Inspecting the bruteforce requests manually shows a parameter named sec embedded in the request. It first appears on the 120th request and increases by 1 on each request after that. From the same point, responses become a 302 redirect to a different subdomain. The reason to look here is that the extra field appeared around the same point as the rejection.

Step 5: remove the parameter

The sec parameter was heavily dependent on the client side. Removing it from the 120th request removes the parameter from every subsequent request. The reason this works is that the value is generated in the browser: if the browser never adds it, the server never receives it.

Step 6: repeat the bruteforce and submit

With sec gone, the OTP bruteforcing is repeated, the correct OTP is obtained and typed in. The email is then changed from [redacted] to [redacted].

From the original on sagarsajeev.medium.com

Why it worked

The report does not describe the server side implementation, so the following is likely rather than confirmed. The application appears to add a client side counter, sec, to requests once a threshold of attempts is crossed, and to reject OTP submissions that do not carry the expected value. Because the parameter is generated and attached on the client, an attacker who removes it from the request also removes it from every later request, and the server side check that depends on it never sees the value it expects.

No rate limit was set on the OTP check, so the correct OTP could be found by bruteforcing, and the only obstacle was a client controlled parameter that could be dropped.

A useful comparison: a bouncer who checks a wristband that the customer prints at home is not really checking anything, because the customer can simply not print one. A check only counts when the thing being checked is issued and verified by the side doing the checking.

Impact

As the author puts it, the issue can be used to bypass email verification. An attacker can create an account on behalf of any person without having access to that email account. The report does not go beyond this statement, and no severity or CVSS score is given.

Fix

Based on the behaviour described, the counter should be enforced on the server rather than trusted from the client, and the OTP check should be rate limited so that a 4 digit code cannot be exhausted.

Variants to test

These are the same ideas generalised, so a beginner can look for similar behaviour elsewhere. Each one lists what a positive result looks like.

  • Client side counters on OTP or verification endpoints. Submit a wrong OTP repeatedly and watch for new parameters appearing after a threshold. A positive result is a parameter that shows up only after N attempts and increments by a fixed step.
  • Removing the counter. Delete the new parameter from the request where it first appears and continue. A positive result is that the parameter stays absent from later requests and the correct OTP is accepted.
  • Threshold behaviour. Note the attempt number at which the parameter and any redirect appear. A positive result is a consistent threshold, here the 120th request, that can be stepped over.
  • Rate limiting on short codes. Try a 4 digit OTP space with no throttling. A positive result is that the full space can be tried and the correct code recovered.
  • Redirect after threshold. Check whether responses switch to a 302 to another subdomain after the threshold. A positive result is a redirect that does not actually block the verification attempt.

Timeline

Submitted : 02-07-2022

Accepted : 03-08-2022

Rewarded with Swag : 09-08-2022

The researcher notes that the report was submitted a while back and that the security team replied only last week, by which time the finding had been forgotten. The reward was swag rather than a cash bounty.

Glossary

  • 302 redirect: an HTTP response telling the browser to go to a different address instead of the one it asked for.
  • Account: the record a website keeps about a user, usually identified by an email address and protected by a password.
  • Bruteforcing: trying every possible value of something, one after another, until the right one is found.
  • Burp Suite Repeater: a tool feature that lets you take a single HTTP request, edit it, resend it many times and read each response.
  • Client side: work that happens in the user's browser rather than on the website's server.
  • CVSS: a standard scoring system for rating the severity of a security issue. The report gives no score.
  • Email verification bypass: getting an email change or signup accepted without proving control of the email address, for example by defeating the OTP step.
  • Hidden parameter: a field added to a request by the page's own code rather than shown in a form, so the user does not see it but can still remove it.
  • HTTP request: the message a browser sends to a server asking for a page or an action.
  • HTTP response: the message a server sends back, containing the page or a status such as a redirect.
  • OTP (one-time password): a short code valid for a single use, sent to an email address or phone to prove the person can read messages there.
  • Parameter: a named value inside a request, such as email=[redacted].
  • Rate limiting: a rule limiting how many times an action can be attempted in a period, used to stop guessing attacks.
  • Server side: work that happens on the website's own computer, which the user cannot directly change.
  • Subdomain: a section of a domain name, such as shop.example.com under example.com.
  • Swag: promotional items such as clothing or stickers given as a reward, instead of a cash bounty.
  • Vulnerability class: a category of security weakness, such as email verification bypass or bruteforce.

More by Sagar Sajeev

View all

7 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.