Skip to content
Info disclosure Write-up Beginner

[Bug Bounty] Email Content Injection

The username field in a 'Notify Me' form was inserted into the body of an automated email without sanitisation, allowing an attacker to inject arbitrary text and links into the message. This could be used for phishing by making the email appear to come from the target website.

Navneet Follow

Published on medium.com

Bounty$25 View original

Cybersecurity

Navneet, on 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. 4 min read.

Context

This write-up covers an email content injection bug found in a private bug bounty program. The target is an e-commerce site with a shop section where products are sold. The relevant feature is the out-of-stock flow: on a product page, when a product is out of stock, a button labelled "Notify Me" is shown. Clicking it sends an automatically generated email to the address the visitor supplies, confirming that they have subscribed to be notified about that out-of-stock product and that they will be told when it comes back in stock.

The bug is what the author calls email content injection: injecting content, including a link, into the email the target website sends to the user.

Setup

The report does not describe any accounts, roles, tools or versions. The only precondition is access to the product page of an out-of-stock item, where the "Notify Me" button and its input fields are displayed. The work was done against a private program, so the hostname and endpoints are not given.

Finding it

Above the "Notify Me" button there are two input fields, one for a username and one for an email address. Clicking the button generates a POST HTTP request whose body contains the parameters username, email and others. The first test was to change the email value to a different email address, to check whether there was any restriction on it. The email arrived at the different address, so the value was not restricted to the address the visitor had entered.

The more interesting observation was on the username parameter. When its value was changed to content that also contained a link, the corresponding email started with Dear "INJECTED CONTENT.....and also the link" instead of Dear "USERNAME". In other words, the username value is placed verbatim into the body of the outgoing email.

Exploitation

Step 1: Change the email address

The first step was to replace the email parameter value with a different email address and submit the form. The request is a POST whose body carries username, email and other parameters. The report does not reproduce the raw request, only the parameter names. The result was that the email was successfully received at the different address, confirming there was no restriction tying the recipient to the entered address.

Step 2: Inject content through the username

The second step was to change the username parameter to content containing a link. The report does not reproduce the exact payload. The resulting email began with:

Text
Dear "INJECTED CONTENT.....and also the link"

instead of the expected Dear "USERNAME". For the proof of concept the author injected text along the lines of a message telling the customer that this is an important email, that they should do something, and pointing to a link. The injected string is rendered inside the greeting of the email, so the recipient sees attacker-controlled wording and an attacker-controlled link in a message that comes from the target site.

Root cause

The username value from the subscription request appears verbatim in the greeting of the generated email, so whatever the requester supplies becomes part of the message text. The report does not describe the server-side code or the exact mechanism. The recipient address was not tied to the address the visitor entered: a different address was accepted, which is what makes the injected message deliverable to a chosen inbox rather than only to the person who submitted the form.

Impact

The author's conclusion is that effective phishing can be done using this bug. Because the injected content, including a link, appears in an email sent by the target website, the message carries the site's legitimacy, and because the recipient address can be changed, the attacker can direct it to a victim of their choosing. The report does not quantify how many users could be reached or describe any further consequences beyond phishing.

Fix

The issue was reported to the security team, and they removed the username parameter to mitigate it.

Reward

The author expected a good amount for the bug but was rewarded with $25.

Take away

When doing penetration testing, look at every HTTP request that generates or sends an email to a user, and check whether it contains a parameter that can be used to inject content into the email.

Variants to test

  1. Contact, feedback and support forms: submit a name or subject containing a link and see whether it appears verbatim in the notification email.
  2. Newsletter and notification subscriptions: change the recipient address and the display name, and check whether the email arrives at the new address with the injected greeting.
  3. Password reset and account emails: put markup or a URL in the display name or other profile fields and check whether it is reflected in the message body.
  4. Order and shipping notifications: inject into address or order-note fields and check the confirmation email.
  5. Invitation flows: inject into the inviter name or message field and check the email the invitee receives.

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

What happened, in plain words

A security researcher found a bug in a website that sells products online. The bug let him put his own words, including a link, into an email that the website sends to customers. Because the email comes from the real shop, a reader would trust it, and the researcher could also choose who received it. That combination makes a convincing phishing email possible. He reported it, the company fixed it by removing one of the form fields, and he was paid 25 US dollars.

This is a beginner's walkthrough of that report. You only need to know how to use a browser. Every technical term is explained the first time it appears, and there is a glossary at the end.

The feature that was abused

The site has a shop section where products are sold. As on most online shops, you can open a product page, add the product to a cart, or buy it. There is one extra case: when a product is out of stock, the page shows a button labelled "Notify Me".

Clicking that button sends an automatically generated email to the address the visitor typed in. The email confirms that the visitor has subscribed to be notified about that out-of-stock product, and that they will be told when it is back in stock.

That is a normal, friendly feature. The problem is how the site builds the email.

What "email content injection" means

The researcher calls the bug email content injection. Injection, in security, means that data a user supplies is treated as part of the program's own instructions or output instead of staying plain data. A simple comparison: imagine a form letter that says "Dear ____" and someone fills the blank with a whole paragraph of their own, plus a web address. The letter now says whatever they wanted it to say, in the letterhead of the organisation that sent it.

Here the blank is the username field, and the letter is an email sent by the shop.

A Picture just for story preview 😅 From the original on medium.com

The image is a picture the author used as a story preview.

How the researcher found it

  1. He opened the product page of an out-of-stock item, where the "Notify Me" button appears.
  2. Above the button there are two input fields, one for a username and one for an email address.
  3. Clicking the button makes the browser send a request to the website's server. The researcher watched that request.

A request is simply the message your browser sends to a website's computer (the server) when you do something, such as submitting a form. The server replies, for example by sending back a page or by triggering an email. A POST request is a request that carries data in its body, typically the contents of a form. The body is the part of the request that holds the values you typed.

The request body contained the parameters username, email and others. A parameter is one named value in that body, like a labelled box on a form: the label is the name, the value is what you typed.

Step 1: Changing the email address

The first test was to change the value of the email parameter to a different email address, to see whether the site restricted it. The request is a POST whose body carries username, email and other parameters. The report does not reproduce the raw request, only the parameter names.

The result: the email arrived at the different address. So the site did not check that the recipient matched the address the visitor had entered. That matters because it means an attacker can aim the email at someone else, not only at themselves.

Step 2: Injecting content through the username

The second test was to change the username parameter to content that also contained a link. The report does not reproduce the exact payload. The resulting email began with:

Text
Dear "INJECTED CONTENT.....and also the link"

instead of the expected Dear "USERNAME".

Line by line, in plain words:

  • Dear " is the fixed opening of the email's greeting, written by the shop.
  • INJECTED CONTENT.....and also the link is the text the researcher supplied in the username field. It appears exactly as he typed it, inside the greeting.
  • The closing " is the rest of the shop's fixed greeting.

So the username value is copied straight into the body of the outgoing email. Whatever the requester supplies becomes part of the message text.

For the proof of concept (a small demonstration that proves the bug is real), the author injected text along the lines of a message telling the customer that this is an important email, that they should do something, and pointing to a link. The injected string is rendered inside the greeting of the email, so the recipient sees attacker-controlled wording and an attacker-controlled link in a message that comes from the target site.

Why it works

The username value from the subscription request appears verbatim in the greeting of the generated email. Sanitisation means cleaning input so that dangerous characters or markup cannot do anything unexpected. Escaping means converting special characters into harmless text so they are displayed rather than acted on.

The report does not describe the server-side code or the exact mechanism. String interpolation means building a piece of text by dropping values into placeholders, like "Dear " followed by the username.

The recipient address was not tied to the address the visitor entered: a different address was accepted. That is what makes the injected message deliverable to a chosen inbox rather than only to the person who submitted the form.

What an attacker could do with it

The author's conclusion is that effective phishing can be done using this bug. Phishing is a trick in which an attacker sends a message that looks like it comes from a trusted organisation, to get the reader to click a link or hand over information. Because the injected content, including a link, appears in an email sent by the target website, the message carries the site's legitimacy. Because the recipient address can be changed, the attacker can direct it to a victim of their choosing.

The report does not quantify how many users could be reached or describe any further consequences beyond phishing.

The fix and the reward

The issue was reported to the security team, and they removed the username parameter to mitigate it. The report says the username parameter was removed to mitigate it. The report does not say whether any output encoding or recipient validation was added.

The author expected a good amount for the bug but was rewarded with $25.

What to take away

When doing penetration testing (deliberately testing a system's security with permission), look at every HTTP request that generates or sends an email to a user. Check whether it contains a parameter that can be used to inject content into the email.

Variants to test

These are other places where the same idea can be tried:

  1. Contact, feedback and support forms: submit a name or subject containing a link and see whether it appears verbatim in the notification email.
  2. Newsletter and notification subscriptions: change the recipient address and the display name, and check whether the email arrives at the new address with the injected greeting.
  3. Password reset and account emails: put markup or a URL in the display name or other profile fields and check whether it is reflected in the message body.
  4. Order and shipping notifications: inject into address or order-note fields and check the confirmation email.
  5. Invitation flows: inject into the inviter name or message field and check the email the invitee receives.

Glossary

  • Bug bounty program: an arrangement where an organisation pays researchers for reporting security problems to it.
  • Private program: a bug bounty program that only invited researchers can take part in, so the site's details are not public.
  • E-commerce: selling products or services online.
  • Out-of-stock flow: the sequence of pages and actions a shop offers when a product is unavailable, here the "Notify Me" subscription.
  • Email content injection: putting your own text, such as a link, into an email that a website generates and sends.
  • Injection: a class of bug where user-supplied data is treated as part of the program's own instructions or output instead of staying plain data.
  • Request: the message your browser sends to a website's server when you do something.
  • Server: the computer that runs a website and answers requests.
  • POST request: a request that carries data, usually a form's contents, in its body.
  • Body: the part of a request that holds the values you submitted.
  • Parameter: one named value in a request, like a labelled box on a form.
  • Payload: the specific content an attacker supplies to trigger a bug.
  • Proof of concept (PoC): a small demonstration that proves a bug is real.
  • Sanitisation: cleaning input so dangerous characters or markup cannot do anything unexpected.
  • Escaping: converting special characters into harmless text so they are displayed rather than acted on.
  • String interpolation: building text by dropping values into placeholders.
  • Phishing: a trick in which an attacker sends a message that looks like it comes from a trusted organisation, to get the reader to click a link or hand over information.
  • Penetration testing: deliberately testing a system's security, with permission, to find weaknesses before attackers do.
  • Mitigate: reduce or remove the risk from a problem.

More by Navneet

View all

6 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.