Skip to content
Account takeover Write-up Intermediate

Rate Limit Bypassing Allowing Identity Spoofing

The OTP verification endpoint enforced a rate limit of 60 requests per minute, but adding a spoofed forwarding header raised the allowed number of attempts to 6000 per minute. An attacker could then brute force the six-digit OTP and take over the identity tied to a phone number that was not yet registered.

Mohamed Talaat Follow

Published on 0xt4144t.medium.com

{{media:0}}

Mohamed Talaat (@T4144t), on 0xt4144t.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. 3 min read.

Context

The target was a program on HackerOne (H1). The researcher needed an account to start exploring authenticated requests of the application. Registration was tied to a phone number, and the application only accepted phone numbers from specific countries. The researcher's own phone number was not accepted, so obtaining an account became the first problem to solve.

Registration worked by sending an SMS to the supplied phone number and then asking the user to verify it. The verification function enforced three controls:

  1. A rate limit that allowed only 60 requests per minute.
  2. Once the rate limit was exceeded, the IP address and the phone number were blocked for some time.
  3. A six-digit code, which makes brute force harder.

The goal was therefore to bypass the rate limit, increase the number of allowed trials, and recover the OTP sent to a user's phone.

Setup

No special tooling, versions or roles are described beyond hunting on the H1 program and interacting with the registration and verification endpoints.

Finding it

Rate limiting is an API control set by developers to mitigate attacks such as brute force, resource exhaustion and distributed denial of service. It is commonly applied to authentication functions: login, password reset, account verification, two-factor authentication, and any function that sends messages or emails.

Here the limit was 60 requests per minute, with an IP and phone block after exceeding it, plus a six-digit OTP. The researcher set out to raise the number of allowed trials so that the six-digit space became reachable.

Exploitation

Step 1: Change client-controlled values

The first attempt was to vary request headers that a client can set: the user-agent, obtaining a new cookie, and changing the source IP address. None of these worked; the rate limit still applied.

Step 2: Add a forwarding header

The second attempt was to add a new header with this value:

HTTP
X-Forwarded-For: [redacted]

With that header present, the response showed the number of allowed trials rising from 60 to 6000 per minute. The researcher suggests this misconfiguration may have existed for testing purposes from localhost.

Root cause

Adding the header raised the allowed trials from 60 to 6000 per minute. Sending that value in the header raised the allowance from 60 to 6000 per minute.

Impact

With 6000 trials per minute, brute forcing the six-digit OTP became practical. That in turn allowed spoofing the identity of any user by using their phone number, provided that the number was still not registered.

Fix

The report does not describe a fix. The measure implied by the finding is to stop trusting client-supplied forwarding headers for rate-limiting decisions, or to only honour them from known proxies, and to remove any exemption for loopback addresses that can be reached through such headers.

Variants to test

  • Send X-Forwarded-For: [redacted] on any rate-limited endpoint (login, password reset, OTP verification). A positive result is a response showing a higher allowance or no lockout after the normal threshold.
  • Try other loopback and private representations, such as [redacted], ::1 or localhost, in the same header. A positive result is the same increase in allowed trials.
  • Try related forwarding headers such as X-Real-IP or X-Originating-IP with a loopback value. A positive result is that the limit is keyed on the supplied value rather than the connection.
  • Rotate the header value per request and observe whether each value gets its own counter. A positive result is that the limit resets with every new value, which removes the need for a loopback exemption at all.
  • Combine the bypass with OTP verification and measure how many guesses are accepted before any block. A positive result is a trial count far above the documented limit with no IP or phone block.

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

What happened, in plain words

A security researcher was taking part in a bug bounty programme on HackerOne (often shortened to H1). A bug bounty programme is a scheme where a company invites independent researchers to look for security weaknesses in its systems and report them, usually for a reward. To explore the application properly, the researcher needed an account, because many parts of a website only behave differently once you are logged in.

Registration on this application was tied to a phone number, and the application only accepted phone numbers from certain countries. The researcher's own number was not accepted, so getting an account became the first problem to solve.

Registration worked like this: you typed in a phone number, the application sent an SMS to that number containing a short code, and you typed the code back to prove the number was yours. That short code is called an OTP, a one-time password. The verification step had three protections in place, and the researcher's goal was to bypass the rate limit to increase the number of allowed trials.

The three controls on verification

The verification function enforced three controls:

  1. A rate limit that allowed only 60 requests per minute.
  2. Once the rate limit was exceeded, the IP address and the phone number were blocked for some time.
  3. A six-digit code, which makes brute force harder.

Before going further, three ideas need explaining.

A rate limit is a cap on how many times you may do something in a given period. Think of a shop that will only serve you 60 times a minute: after that, the till stops and you have to wait. Websites use this to stop automated programs from hammering a feature.

An IP address is the number that identifies your connection on the internet, roughly like the return address on an envelope. Blocking an IP address means the server refuses to talk to that connection for a while.

Brute force means guessing a secret by trying every possibility, one after another, very fast. A computer can try thousands of guesses per second. A six-digit code has one million possible values (from 000000 to 999999), which is far too many to guess by hand but not necessarily too many for a program, if the program is allowed to keep trying.

The researcher's plan was therefore simple in outline: raise the number of allowed trials so that the six-digit space became reachable, and then recover the OTP sent to a user's phone.

What rate limiting is for

Rate limiting is an API control set by developers to mitigate attacks such as brute force, resource exhaustion and distributed denial of service.

An API is the part of a website that the page talks to behind the scenes. When you fill in a form and press a button, your browser sends a request to the API, and the API sends back an answer. It is like a waiter: you do not walk into the kitchen yourself, you tell the waiter what you want and the waiter brings it back.

Resource exhaustion means using up a server's capacity, for example by making it do so much work that it cannot serve anyone else. Distributed denial of service (DDoS) is the same idea carried out from many machines at once, so the traffic looks like a crowd rather than one person.

Rate limiting is commonly applied to authentication functions: login, password reset, account verification, two-factor authentication, and any function that sends messages or emails. The reason is that all of these either check a secret or cost the company money (sending an SMS is not free), so they are attractive targets.

Here the limit was 60 requests per minute, with an IP and phone block after exceeding it, plus a six-digit OTP. The researcher set out to raise the number of allowed trials so that the six-digit space became reachable.

Step 1: change values the client controls

The first attempt was to vary request headers that a client can set: the user-agent, obtaining a new cookie, and changing the source IP address. None of these worked; the rate limit still applied.

A request header is a small piece of extra information your browser attaches to every request, a bit like the label on a parcel. The user-agent header says which browser and operating system you are using. A cookie is a small note the website asks your browser to keep and send back with later requests, so the site can remember who you are between page loads. Changing the source IP address means making the request appear to come from a different connection.

The reasoning behind this step was: if the server counts requests per browser or per connection, then looking like a different browser or a different connection should give a fresh counter. It did not, which told the researcher the server was counting on something else.

Step 2: add a forwarding header

The second attempt was to add a new header with this value:

HTTP
X-Forwarded-For: [redacted]

Line by line: X-Forwarded-For is the name of the header. It is a convention used when a request passes through a proxy or load balancer, so that the final server can still learn the original visitor's address. [redacted] is the loopback address, a special address that always means "this very machine". When a program talks to a service running on the same computer, it uses this address. The colon separates the header name from its value.

With that header present, the response showed the number of allowed trials rising from 60 to 6000 per minute. The researcher suggests this misconfiguration may have existed for testing purposes from localhost.

Why it worked

Adding the header raised the allowed trials from 60 to 6000 per minute. Sending that value in the header raised the allowance from 60 to 6000 per minute.

This is the heart of the bug. A value that the visitor can write freely was being used as if it were a fact established by the server.

What the researcher could do with it

With 6000 trials per minute, brute forcing the six-digit OTP became practical. That in turn allowed spoofing the identity of any user by using their phone number, provided that the number was still not registered.

Identity spoofing here means passing yourself off as the owner of a phone number. If a number has not yet been registered, and you can guess the code that was sent to it, you end up holding an account that belongs to that number, not to you.

Fix

The report does not describe a fix. The measure implied by the finding is to stop trusting client-supplied forwarding headers for rate-limiting decisions, or to only honour them from known proxies, and to remove any exemption for loopback addresses that can be reached through such headers.

Variants to test

If you want to look for the same pattern elsewhere, these are the variations worth trying. Each one lists what a positive result looks like.

  • Send X-Forwarded-For: [redacted] on any rate-limited endpoint (login, password reset, OTP verification). A positive result is a response showing a higher allowance or no lockout after the normal threshold.
  • Try other loopback and private representations, such as [redacted], ::1 or localhost, in the same header. A positive result is the same increase in allowed trials.
  • Try related forwarding headers such as X-Real-IP or X-Originating-IP with a loopback value. A positive result is that the limit is keyed on the supplied value rather than the connection.
  • Rotate the header value per request and observe whether each value gets its own counter. A positive result is that the limit resets with every new value, which removes the need for a loopback exemption at all.
  • Combine the bypass with OTP verification and measure how many guesses are accepted before any block. A positive result is a trial count far above the documented limit with no IP or phone block.

Glossary

  • API: the part of a website that pages talk to behind the scenes to fetch or change data.
  • Authentication: the process of proving who you are, usually with a password or a code.
  • Brute force: guessing a secret by trying possibilities one after another, very quickly.
  • Bug bounty programme: a scheme where a company invites outside researchers to find and report security weaknesses.
  • Cookie: a small note a website asks your browser to store and send back with later requests, used to remember you.
  • DDoS (distributed denial of service): flooding a service with traffic from many machines so that it cannot serve normal users.
  • Header: extra information attached to a request or response, such as the browser type or a forwarding address.
  • HackerOne (H1): a platform where bug bounty programmes are hosted and reports are submitted.
  • Identity spoofing: pretending to be someone else, here the owner of a phone number.
  • IP address: the number identifying a connection on the internet.
  • Load balancer: a machine that spreads incoming requests across several servers.
  • Loopback address: the special address [redacted], which always refers to the same machine the program is running on.
  • Localhost: the name for the machine itself, the same idea as the loopback address.
  • Misconfiguration: a setting left in a state that was not intended for production use.
  • OTP (one-time password): a short code, valid once, used to prove you control a phone number or account.
  • Proxy: an intermediary that forwards requests on your behalf, often adding forwarding headers.
  • Rate limit: a cap on how many requests are allowed in a period of time.
  • Resource exhaustion: using up a server's capacity so it cannot handle other work.
  • SMS: a text message, here used to deliver the OTP.
  • Two-factor authentication: logging in with two separate proofs, such as a password plus a code.
  • User-agent: the header that states which browser and operating system made the request.
  • X-Forwarded-For: a header used by proxies to pass along the original visitor's address; it can be set by the client.
  • X-Real-IP: a header with a similar purpose to X-Forwarded-For, carrying the original address.
  • X-Originating-IP: another header of the same family, carrying the original address.

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.