Account Takeover + A Bonus Vulnerability
The login link sent to a user's email was built from a host value supplied in the websocket request, so an attacker could replace it with their own domain and capture the victim's quick-login token. After the fix, the path portion of the link was still attacker-controlled, allowing an attacker to inject their own login token into the victim's link and log the victim into the attacker's account.
Published on medium.com
Hello everyone, In the article I will explain how I was able to takeover any account of redacted.com. This attack is very much similar to Host Header Injection but app was using websockets so its a little different.
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.
Context
The target is a login portal on redacted.com that offers passwordless sign-in. A user enters an email address and asks the application to send a login link. Clicking the link in the email logs the user in automatically, with no password required. The application delivers this feature over a WebSocket connection rather than a plain HTTP request, which is what makes the attack resemble host header injection while behaving a little differently.
The write-up covers two issues found in the same feature: an account takeover by rewriting the host in the login link, and, after that was fixed, a second abuse of the remaining path segment that let an attacker force a victim into the attacker's own session.
Setup
The researcher used a victim email address and Burp Collaborator to receive out-of-band requests. No versions, roles or special preconditions are given beyond a working account on the portal and the ability to intercept and modify the WebSocket traffic. The victim only has to click the link that arrives by email.
Finding it
The login flow sends a WebSocket request when the user clicks "Send me a login link". Inside the request, the params field carries two values: the recipient email and a link, in this shape:
[\"[redacted]\",\"https://www.redacted.com/login\"]
The email that arrived contained a link of the form:
https://www.redacted.com/login?quickLogin=XXXXXXXXXXXXXXXXXXXX
The first part of that link matched the second value the client had sent in the WebSocket request. That is the signal: the client-supplied link is being used to build the link that goes into the email, so the host portion is attacker-controlled.
Exploitation
Step 1: replace the host in the WebSocket request
The researcher changed the second element of params to a Burp Collaborator domain and sent the request:
[\"[redacted]\",\"mycollarboratorlink.net\"]


The email delivered to the victim then contained a login link pointing at the Collaborator domain instead of redacted.com.

Step 2: capture the login code
When the victim clicks the modified link, the request reaches the Collaborator, and the researcher receives the login code there.

Step 3: use the code
The captured code is appended to the legitimate login URL:
https://www.redacter.com/login?quickLogin=
With that, the researcher could log in as the victim. Because the profile section allows the email address to be changed, an attacker who reaches the account can swap the email and keep access permanently, which the author describes as permanent account takeover.
Root cause
The application trusted the client to supply the base of the login link and used it verbatim when composing the email. The host that received the click was not validated against the application's own domain, so the secret code travelled to whatever host the requester named. This is the same class of mistake as host header injection, with the WebSocket params array acting as the injection point instead of an HTTP header.
Fix
After the report, the fix removed the host from the client's control. The request now carries only the path:
/login

The backend prepends https://www.redacted.com and appends quickLogin=XXXXXXXXXXXXXXXXXXXXXXXX around that path, so the first and last parts are added by the app. The first vulnerability was reported and fixed within two working days.
The bonus vulnerability
With the host fixed, the middle segment, /login, was still under the requester's control and changes to it were reflected in the link that arrived by email. The researcher therefore tried to inject the attacker's own login code into a link requested for the victim.
Step 1: obtain the attacker's token
The researcher requested a login link from the attacker's own account and copied the token from it.
Step 2: modify the path
The request was changed from /login to:
/login?quickLogin=attackers_token?ref=\

This places the attacker's token inside the path segment that the backend wraps with its own host.
Step 3: send it for the victim's address
The modified request was sent while requesting a login link for the victim's email. The link the victim received contained the attacker's token.

When the victim clicks it, they are logged in to the attacker's account without realising it. The author describes this as exploiting a single vulnerability in two different ways. It was reported on 2 February 2021, acknowledged on 3 February and fixed on 4 February.
Impact
The first issue allowed takeover of any account whose owner clicked the emailed link, with the captured code replayed against the legitimate login endpoint. Because the profile email can be changed, the takeover could be made permanent. The second issue does not hand the attacker the victim's account; it silently logs the victim into the attacker's account. Both depend on the victim clicking the link.
Timeline
| Date | Event |
|---|---|
| 30 Jan 2021 | Account takeover reported |
| 31 Jan 2021 | Acknowledged |
| 2 Feb 2021 | Fixed and paid |
| 2 Feb 2021 | Second issue reported |
| 3 Feb 2021 | Acknowledged |
| 4 Feb 2021 | Fixed and paid |
Variants to test
- Passwordless and magic-link flows that build the URL client-side: intercept the request and replace the host with a Collaborator domain. A positive result is an email whose link points at your domain and a captured token when it is clicked.
- WebSocket-based login requests: inspect every element of array-style
paramsfor URLs, hosts or paths that end up in the email. A positive result is any client value reflected in the delivered link. - Post-fix path reflection: after a host restriction is added, change only the path or add query strings inside it. A positive result is a delivered link that contains your injected parameters alongside the server-generated token.
- Token injection into another user's link: request a link for a victim address while embedding your own token in the path. A positive result is a victim link that logs the victim into your account.
- Email change after takeover: check whether the profile allows changing the address. A positive result is persistent access after the takeover.
What happened, in plain words
A website let people log in without a password: you typed your email address, the site emailed you a special link, and clicking that link signed you in. The researcher found that the site built that link partly from information the browser sent, and it never checked that the information was trustworthy. By changing one value in the request, the researcher could make the email link point to a server they controlled. When the victim clicked it, the secret login code arrived at the researcher's server instead of the real site, and the researcher could use it to log in as the victim. After the site fixed that, the researcher found a second way to abuse the same feature: by putting their own login code into the request for the victim's link, they could make the victim's link log the victim into the researcher's account. Both attacks needed the victim to click a link in an email.
Background: the login feature and the tools
Passwordless login (magic links)
Many sites offer "passwordless" sign-in. Instead of a password, you enter your email address and ask the site to send you a login link. The link contains a long random code (a token). Clicking it proves you received the email, so the site logs you in. This is convenient but means the link itself is a secret: anyone who gets the code can use it.
WebSocket
A WebSocket is a two-way connection between your browser and a server that stays open, like a phone call, instead of the usual request-response pattern of web pages (where the browser asks and the server answers, then the connection closes). The login portal in this report used a WebSocket to send the request that asks for a login link. That matters because the data sent over a WebSocket can look different from a normal web request, and it can carry structured values such as lists.
API
An API (Application Programming Interface) is the set of rules a program uses to talk to another program. In web terms, it is the endpoint (URL) your browser calls to perform an action, such as "send a login link". The request and response have a defined format, often JSON (a text format for structured data).
Token
A token is a piece of data that stands in for something else, usually a secret. Here, the login token is the random code inside the magic link. If you have the token, you can log in as the person it was issued to, until it expires or is used.
Host header injection (the class of bug)
When a browser talks to a web server, it includes a Host header saying which site it wants. If an application uses that value without checking it, an attacker can supply a different host and make the application generate links or send emails pointing to the attacker's server. This report is similar: instead of an HTTP header, the attacker-controlled value is a field inside a WebSocket request. The principle is the same: never trust input from the client when building something security-sensitive, such as a link that carries a secret.
Burp Collaborator
Burp Collaborator is a service that gives you a unique domain name and records any requests sent to it. You can put that domain in a payload; if the application later makes a request to it (for example, when a victim clicks a link), you see the request and its contents. It is a way to catch out-of-band interactions.
The first vulnerability: account takeover by changing the host
Step 1: observe the normal request
The researcher used their own account and a victim email address. They clicked "Send me a login link" and intercepted the WebSocket request. The request contained a field called params with two values: the recipient's email address and a URL. It looked like this:
[\"[redacted]\",\"https://www.redacted.com/login\"]
Line by line:
- The outer brackets
[ ... ]mean this is a list (an array) of two items. - The first item,
\"[redacted]\", is the email address that will receive the login link. The backslashes are escape characters; in the actual data the quotes are just quotes. - The second item,
\"https://www.redacted.com/login\", is a URL. It is the base of the login link.
The researcher then looked at the email that arrived. The link inside it was:
https://www.redacted.com/login?quickLogin=XXXXXXXXXXXXXXXXXXXX
Line by line:
https://www.redacted.com/loginis the same base URL that was sent in the WebSocket request.?quickLogin=XXXXXXXXXXXXXXXXXXXXis a query string: the part after the question mark carries extra data. HerequickLoginis the parameter name andXXXXXXXXXXXXXXXXXXXXis the secret token (redacted in the report).
Why this matters: the first part of the link in the email matched the second value the browser had sent. That is a strong hint that the application takes the URL from the client and uses it directly to build the link. If the client can change that URL, the link in the email will change too.


Step 2: replace the host with a server you control
The researcher changed the second item in params to a Burp Collaborator domain and sent the request:
[\"[redacted]\",\"mycollarboratorlink.net\"]
Line by line:
- The first item is still the victim's email address, so the email will go to the victim.
- The second item is now
mycollarboratorlink.net, a domain the researcher controls (via Burp Collaborator). It replaces the legitimatehttps://www.redacted.com/login.
Why: if the application uses this value as the base of the link, the email will contain a link pointing to the researcher's domain instead of the real site. The secret token will then be sent to the researcher when the victim clicks.
The email delivered to the victim contained a login link pointing at the Collaborator domain instead of redacted.com.

Step 3: capture the login code
When the victim clicks the modified link, the request goes to the Collaborator domain. The researcher sees the request and the login code inside it.

Why: the token is in the URL. By making the victim's browser request that URL from the attacker's server, the attacker receives the token.
Step 4: use the code to log in as the victim
The researcher took the captured code and appended it to the legitimate login URL:
https://www.redacter.com/login?quickLogin=
Line by line:
https://www.redacter.com/loginis the real login page (note the spelling in the report:redacter, notredacted).?quickLogin=is the parameter that expects the token. The token is appended after the equals sign.
With that, the researcher could log in as the victim. Because the profile section allows changing the email address, an attacker who reaches the account can change the email and keep access permanently. The author calls this permanent account takeover.
Why it worked (root cause)
The application trusted the client to supply the base of the login link and used it exactly as given when composing the email. The host that would receive the click was not checked against the application's own domain. So the secret code travelled to whatever host the requester named. This is the same kind of mistake as host header injection, with the WebSocket params array acting as the injection point instead of an HTTP header.
The fix
After the report, the fix removed the host from the client's control. The request now carries only the path:
/login
Line by line:
/loginis just a path, not a full URL. It has no host, so the client cannot choose where the link points.
The backend now prepends https://www.redacted.com and appends quickLogin=XXXXXXXXXXXXXXXXXXXXXXXX around that path, so the first and last parts are added by the app. The first vulnerability was reported and fixed within two working days.

The bonus vulnerability: forcing the victim into the attacker's session
With the host fixed, the middle segment, /login, was still under the requester's control, and changes to it were reflected in the link that arrived by email. The researcher therefore tried to inject the attacker's own login code into a link requested for the victim.
Step 1: obtain the attacker's token
The researcher requested a login link from their own account and copied the token from it.
Why: the attacker needs a valid token that belongs to their own account. They will try to make the victim's link contain that token.
Step 2: modify the path
The request was changed from /login to:
/login?quickLogin=attackers_token?ref=\
Line by line:
/loginis the path the client is allowed to send.?quickLogin=attackers_tokenadds a query parameter namedquickLoginwith the attacker's token as its value. The literal textattackers_tokenstands for the real token the researcher copied.?ref=\adds another parameter namedrefwith a backslash as its value. The backslash is likely there to break out of the surrounding structure or to test how the server parses the string; the report does not explain its purpose.
Why: the backend wraps this path with its own host. By putting a quickLogin parameter inside the path, the attacker hopes the server will use the attacker's token instead of generating a new one for the victim.

Step 3: send it for the victim's address
The modified request was sent while requesting a login link for the victim's email. The link the victim received contained the attacker's token.

When the victim clicks it, they are logged in to the attacker's account without realising it. The author describes this as exploiting a single vulnerability in two different ways. It was reported on 2 February 2021, acknowledged on 3 February and fixed on 4 February.
Impact
The first issue allowed takeover of any account whose owner clicked the emailed link, with the captured code replayed against the legitimate login endpoint. Because the profile email can be changed, the takeover could be made permanent. The second issue does not hand the attacker the victim's account; it silently logs the victim into the attacker's account. Both depend on the victim clicking the link.
Timeline
| Date | Event |
|---|---|
| 30 Jan 2021 | Account takeover reported |
| 31 Jan 2021 | Acknowledged |
| 2 Feb 2021 | Fixed and paid |
| 2 Feb 2021 | Second issue reported |
| 3 Feb 2021 | Acknowledged |
| 4 Feb 2021 | Fixed and paid |
Variants to test
- Passwordless and magic-link flows that build the URL client-side: intercept the request and replace the host with a Collaborator domain. A positive result is an email whose link points at your domain and a captured token when it is clicked.
- WebSocket-based login requests: inspect every element of array-style
paramsfor URLs, hosts or paths that end up in the email. A positive result is any client value reflected in the delivered link. - Post-fix path reflection: after a host restriction is added, change only the path or add query strings inside it. A positive result is a delivered link that contains your injected parameters alongside the server-generated token.
- Token injection into another user's link: request a link for a victim address while embedding your own token in the path. A positive result is a victim link that logs the victim into your account.
- Email change after takeover: check whether the profile allows changing the address. A positive result is persistent access after the takeover.
Glossary
- API: the set of rules and endpoints a program uses to talk to another program; in web terms, the URL your browser calls to perform an action.
- Account takeover: gaining control of another person's account, usually by obtaining their credentials or a valid session.
- Burp Collaborator: a service that provides a unique domain and records requests sent to it, used to detect out-of-band interactions.
- Host header injection: a vulnerability where an application uses the client-supplied
Hostheader without validation, allowing an attacker to influence generated links or redirects. - JSON: a text format for structured data, using objects and arrays.
- Magic link: a login link sent by email that contains a secret token and logs the user in when clicked.
- Passwordless login: authentication without a password, often via a magic link or a one-time code.
- Query string: the part of a URL after the question mark, carrying parameters as name=value pairs.
- Session: a period of interaction between a user and a site, identified by a cookie or token, during which the user is considered logged in.
- Token: a piece of data, often random and secret, that stands in for something else, such as a login credential.
- WebSocket: a two-way, persistent connection between a browser and a server, allowing real-time data exchange.
- Host: the domain name part of a URL, such as
www.redacted.com. - Path: the part of a URL after the host, such as
/login. - Parameter: a named value in a request, such as
quickLoginin a query string. - Out-of-band: a channel separate from the main request-response, used to receive data indirectly (e.g. a request to a Collaborator domain).
- Session fixation: an attack where an attacker forces a victim to use a session identifier known to the attacker; here, the second vulnerability is similar in effect: the victim is logged into the attacker's session.