How i got 200$ with an out of the box open redirect vulnerability
The company name parameter used to build an invitation link was not validated, so an attacker could insert a question mark to break out of the intended subdomain and redirect the victim to an arbitrary site. This allowed sending convincing phishing emails from the legitimate service.
Published on medium.com
Tarek Galleze
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
This is a short account of an open redirect found in a company account feature. The site is anonymised in the write-up as www.example.com, so the real host is not named. The feature itself is ordinary: a user can create a company account, and the platform provisions a dedicated subdomain for that company in the form:
*company-name*.example.com
The same feature lets the account owner invite employees by email. When an invitation is sent, the company name is passed as a parameter in the request, and the server turns it into an invitation link of the form:
*company-name*.example.com/?token=.....
That link is placed inside a button in the invitation email. The link carries a token parameter; the subdomain is derived from the company name supplied by the user.
Before hunting this class of bug, the author's own advice is to check the programme policy first and confirm that open redirects are in scope and under which conditions they are accepted.
Setup
No tooling is named; the researcher intercepted the API request behind the invitation. The preconditions are simply an account that can create a company and send employee invitations, plus access to the mailbox that receives the invitation. The researcher sent an invitation to his own email address and intercepted the API request that carries the company name.
Finding it
Two properties of the feature stood out:
- The company name becomes a subdomain, so user-controlled text ends up in the host part of a URL.
- The company name is also passed as a parameter when inviting an employee, and that value is interpolated into the invitation link placed in the email button.
User-controlled input reaching the host portion of a link is the classic precondition for an open redirect, because the browser resolves the host before it looks at anything else in the URL.
Exploitation
Step 1: intercept the invitation request
The researcher sent an invite to his own email and intercepted the API request behind it, then began modifying the company name parameter.
Step 2: try HTML injection in the email
The first attempt was HTML injection, adding buttons and similar markup to the company name in the hope that it would be rendered in the invitation email. This failed because of additional filtering applied to the value.
Step 3: break the link with a question mark
The next idea was to use the ? character to terminate the host portion of the generated URL and redirect elsewhere. The payload was:
evil.com?
With the company name set to that value, the generated invitation link became:
evil.com?.example.com/?token=....
In URL terms, everything before the first ? is the host, so the browser treats evil.com as the destination and the remainder, including the original subdomain suffix and the token, as query string. The link in the email button therefore pointed at the attacker's domain.
The technique worked, and the report records a 200 USD bounty plus swag.
Root cause
The company name is concatenated into the invitation URL without validation of the characters that are meaningful to URL parsing. Because the value is placed at the start of the host portion, a ? in the value ends the authority component early and everything after it is parsed as query string. The application appears to have filtered HTML markup (the first attempt failed) but not URL delimiters, so the redirect target could be changed while the link still looked like it belonged to the platform. The report does not describe the server-side code, so the exact validation logic is not known.
Impact
The invitation email is sent by the platform itself, which makes it a convincing phishing vector: the recipient sees a genuine message from the service, and the button leads to an attacker-controlled site. The researcher notes that this would allow sending phishing emails to anyone, with the added credibility of the mail coming from the website itself. The token in the link is carried along in the query string, so the crafted link still contains the invitation token. The report does not state whether the token was usable at the attacker's site or what the phishing page did with it.
Fix
The natural fix is to validate the company name against a strict allowlist of characters permitted in a DNS label, rejecting ?, #, /, @, : and similar delimiters, and to build the invitation URL from a fixed, trusted base rather than by string concatenation of user input. Encoding the value as a URL component before insertion would also prevent it from altering the host.
Variants to test
- Any parameter that becomes a subdomain: try
?,#,@,\, and a full URL such ashttps://evil.comas the value, and check whether the generated link's host changes. - Invitation and sharing links built from user-supplied names: intercept the API call, substitute the name, and inspect the resulting link in the email or page.
- Values that pass HTML filtering: if markup is stripped, test URL delimiters separately, since the two filters are often implemented independently.
- A positive result is a generated link whose authority is the attacker's domain while the rest of the original URL, including any token, is preserved as query string.
What happened, in plain words
A security researcher found a way to make a company's own website send emails whose buttons led to a different website chosen by the attacker. This kind of flaw is called an open redirect. He found it in a feature that lets a company create an account and invite employees by email. The trick was to put a question mark character into the company name. The platform then built an invitation link that started with the attacker's domain instead of the company's subdomain. The researcher reported it and received a 200 USD bounty plus some swag. The site is anonymised in the write-up as www.example.com, so the real host is not named.
Before hunting this class of bug, the author's own advice is to check the programme policy first and confirm that open redirects are in scope and under which conditions they are accepted.
What an open redirect is
The write-up gives this definition:
An Open Redirection is when a web application or server uses an invalidated user-submitted link to redirect the user to a given website or page. Even though it seems like a harmless action to let a user decide to which page he wants to be redirected,such technique if exploited can have a serious impact on the application security, especially when combined with other vulnerabilities and tricks.
In everyday terms: imagine a receptionist who will walk you to any room you name, without checking whether you are allowed to go there. If someone can hand the receptionist a room number of their choosing, they can send you somewhere you did not intend to go. On the web, the "receptionist" is a link or a redirect that takes a value from the user and uses it as the destination. When that value is not checked, an attacker can point it at their own site.
Why does this matter? Because people trust links that come from a service they know. If the link arrives in a genuine email from the company, the recipient has little reason to suspect it. That is what makes an open redirect useful for phishing: the message is real, but the button leads elsewhere.
The feature that was abused
The site lets a user create a company account. Two things happen when that account is created:
- The platform gives the company its own subdomain, built from the company name. The write-up shows the form as:
*company-name*.example.com
A subdomain is the part of a web address that comes before the main domain. In mail.example.com, the mail part is the subdomain. Here, whatever name the user types for the company becomes that leading part. So user-controlled text ends up in the host portion of a URL.
- The same feature lets the account owner invite employees by email. When an invitation is sent, the company name is passed as a parameter in the request, and the server turns it into an invitation link of the form:
*company-name*.example.com/?token=.....
That link is placed inside a button in the invitation email.
A parameter is simply a named value sent along with a request, the way a form field has a name and a value. An API is the interface a website uses behind the scenes to talk to its server: when you click a button, your browser sends a request to the API, and the server replies with data or performs an action. A token here is a value carried in the invitation link as a parameter.
Why this feature looked promising
Two properties of the feature stood out:
- The company name becomes a subdomain, so user-controlled text ends up in the host part of a URL.
- The company name is also passed as a parameter when inviting an employee, and that value is interpolated into the invitation link placed in the email button.
User-controlled input reaching the host portion of a link is the classic precondition for an open redirect, because the browser resolves the host before it looks at anything else in the URL. In plain words: the browser first works out which website it is going to, and only then reads the rest of the address. If you can control the host, you control where the browser goes.
Step 1: intercept the invitation request
The researcher sent an invite to his own email address and intercepted the API request behind it, then began modifying the company name parameter.
Intercepting means catching the request between your browser and the server so you can read it and change it before it is sent. The write-up does not name the tool used. The preconditions are simply an account that can create a company and send employee invitations, plus access to the mailbox that receives the invitation.
Why do this? Because the company name is sent as a parameter, and parameters are easy to change. By editing the value and resending the request, the researcher could see exactly what link the server would build, without having to guess.
Step 2: try HTML injection in the email
The first attempt was HTML injection: adding buttons and similar markup to the company name in the hope that it would be rendered in the invitation email. This failed because of additional filtering applied to the value.
HTML is the language web pages are written in. Markup such as a button tag tells the browser to draw a button. HTML injection means putting markup into a place where the site expects plain text, hoping the site will treat it as code and display it. If it worked in an email, the attacker could put their own button or link into a message that looks official.
Why try this first? Because the company name was being placed into an email, and emails are often built from HTML. If the value was inserted without escaping, the markup would render. It did not, because the site filtered the value. Filtering means checking the input and removing or rejecting parts that are not allowed.
Step 3: break the link with a question mark
The next idea was to use the ? character to terminate the host portion of the generated URL and redirect elsewhere. The payload was:
evil.com?
Line by line: this is the value the researcher put into the company name parameter. It is a domain name, evil.com, followed by a question mark. The question mark is the character that, in a web address, separates the address of the site from the extra data sent to it.
With the company name set to that value, the generated invitation link became:
evil.com?.example.com/?token=....
Line by line: the server took the company name and placed it at the start of the link, then appended the rest of the original address. The first ? in the resulting string is the one the researcher supplied. Everything before that first ? is treated as the host, so the browser reads evil.com as the destination. Everything after it, including the original subdomain suffix and the token, is treated as query string. Query string is the part of a URL that carries extra values, usually after the question mark, such as `?[redacted]
In URL terms, everything before the first ? is the host, so the browser treats evil.com as the destination and the remainder, including the original subdomain suffix and the token, as query string. The link in the email button therefore pointed at the attacker's domain.
Why did this work when the HTML attempt did not? Because the site had filtered HTML markup but not the characters that are meaningful to URL parsing. The two kinds of filtering are separate, and only one of them was in place.
The technique worked, and the report records a 200 USD bounty plus swag.
Root cause
The company name is concatenated into the invitation URL without validation of the characters that are meaningful to URL parsing. Concatenated means joined together as text, one string after another. Because the value is placed at the start of the host portion, a ? in the value ends the authority component early and everything after it is parsed as query string. The authority component is the part of a URL that names the host, the site you are going to. The application appears to have filtered HTML markup (the first attempt failed) but not URL delimiters, so the redirect target could be changed while the link still looked like it belonged to the platform. The report does not describe the server-side code, so the exact validation logic is not known.
Impact
The invitation email is sent by the platform itself, which makes it a convincing phishing vector: the recipient sees a genuine message from the service, and the button leads to an attacker-controlled site. The researcher notes that this would allow sending phishing emails to anyone, with the added credibility of the mail coming from the website itself. The token in the link is carried along in the query string, so the crafted link still contains the invitation token.
Phishing is the practice of sending a message that pretends to come from a trusted source in order to trick the recipient into clicking a link or handing over information. The strength of this particular case is that the message really does come from the trusted source.
Fix
The natural fix is to validate the company name against a strict allowlist of characters permitted in a DNS label, rejecting ?, #, /, @, : and similar delimiters, and to build the invitation URL from a fixed, trusted base rather than by string concatenation of user input. Encoding the value as a URL component before insertion would also prevent it from altering the host.
An allowlist is the opposite of a blocklist: instead of listing bad things to remove, you list the good things to keep and reject everything else. A DNS label is one part of a domain name, such as the company-name piece in company-name.example.com. Encoding a value as a URL component means converting characters that have special meaning in a URL into a safe form, so they are treated as ordinary text rather than as instructions to the browser.
Variants to test
- Any parameter that becomes a subdomain: try
?,#,@,\, and a full URL such ashttps://evil.comas the value, and check whether the generated link's host changes. - Invitation and sharing links built from user-supplied names: intercept the API call, substitute the name, and inspect the resulting link in the email or page.
- Values that pass HTML filtering: if markup is stripped, test URL delimiters separately, since the two filters are often implemented independently.
- A positive result is a generated link whose authority is the attacker's domain while the rest of the original URL, including any token, is preserved as query string.
Glossary
- Open redirect: a flaw where a site takes a destination from user input and sends the visitor there without checking it.
- Subdomain: the part of a web address before the main domain, such as
mailinmail.example.com. - Host: the part of a URL that names the site the browser is going to.
- URL: the address of a page or resource on the web.
- Query string: the part of a URL after the first
?that carries extra values. - Parameter: a named value sent with a request, like a form field.
- API: the interface a website uses behind the scenes to talk to its server.
- Token: a long, hard-to-guess string that acts as a secret, here identifying an invitation.
- Intercept: to catch a request between browser and server so it can be read or changed.
- Proxy: a tool that sits between your browser and the internet and can inspect or modify traffic.
- HTML: the language web pages are written in.
- HTML injection: putting markup into a place that expects plain text, hoping it is treated as code.
- Filtering: checking input and removing or rejecting parts that are not allowed.
- Concatenation: joining strings together as text, one after another.
- Authority component: the part of a URL that names the host.
- Phishing: sending a message that pretends to come from a trusted source to trick the recipient.
- Allowlist: a list of what is permitted, with everything else rejected.
- DNS label: one part of a domain name, such as the leading piece in
company-name.example.com. - URL encoding: converting characters with special meaning in a URL into a safe form so they are treated as plain text.