Skip to content
XSS Disclosed report Intermediate

Stored XSS via SMTP Error Message

The email validation page inserted SMTP error messages into the page without sanitisation, so an attacker controlling an SMTP server could store JavaScript that runs when the victim views the page. This could lead to account takeover if staff view the same bounce history.

chse_ Follow

Originally disclosed on HackerOne

Bounty$250incl. $50 bonus Low View original
  • Fixed in 6 hours
  • Paid in 4 hours
  • Disclosed after 7 hours

Summary by the program

Summary

A Stored Cross-Site Scripting (XSS) vulnerability is identified on the /account/email page for www.xvideos.com. The vulnerability arises from the improper handling of SMTP error messages. These error messages are passed into the html() method without proper sanitization, allowing an attacker to store and execute arbitrary JavaScript code on the affected page. The vulnerability is classified as CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').

Steps to Reproduce

  1. Configure a Postfix 3.7.11 SMTP server with the following settings:

    • Add to /etc/postfix/main.cf:
      smtpd_recipient_restrictions =
          check_recipient_access hash:/etc/postfix/recipient_access,
          reject_unverified_recipient,
          permit
      
    • Create /etc/postfix/recipient_access with:
      [email protected] REJECT 5.1.1 <img src="" onerror="alert('hackerone!')" />
      
    • Update Postfix database: postmap /etc/postfix/recipient_access
    • Restart Postfix: systemctl restart postfix
  2. Navigate to www.xvideos.com using an up-to-date browser.

  3. Click on the "Join for FREE" button.

  4. Create an account using the configured email address (e.g., [email protected]).

  5. Once the account is created, go to the /account/email route.

  6. Click on "Please click Here to validate it."

  7. Wait approximately 45 minutes.

If successful, an alert message saying "hackerone!" should appear on the screen.

Impact

The vulnerability allows an attacker running an SMTP server to inject their own JavaScript payloads targeting users of the affected sites. Users who misspell their email domain could also be affected if an attacker controls the mistyped domain. If staff members can view a user's bounce history in the same way as on the /account/email page, they may be subjected to an account takeover. These scenarios can result in the leak of sensitive information.

The severity of this vulnerability is rated as low by the organization.

The original report as published on HackerOne, by chse_. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

XVideos is a high-traffic site with a free registration flow. The feature at the centre of this report is the email address management page at /account/email, where a logged-in user can change the address on their account and trigger a validation email. When the site sends that message, it talks to the recipient's mail server over SMTP. If the receiving server rejects the recipient, the SMTP error text comes back to the application, and the application shows it to the user on the same page.

The report describes a stored cross-site scripting issue in that error display. The SMTP rejection message is passed into an html() method without sanitisation, so text controlled by whoever runs the receiving mail server ends up as markup in the page. The weakness is classified as CWE-79, Improper Neutralization of Input During Web Page Generation.

Setup

The researcher needed control of the mail server that would answer the SMTP conversation for the address used at registration. The report specifies Postfix 3.7.11, configured to reject a chosen recipient with a custom message. No other tooling, account role or version is given.

The precondition is that the attacker can register an account with an email address whose domain points at a server they control, and that the site later displays the SMTP rejection text for that address on /account/email.

Finding it

The report states that SMTP error messages are passed into html() without proper sanitisation. Because the content of an SMTP rejection is chosen by the receiving mail server, an attacker who owns that server can place arbitrary text, including HTML and JavaScript, into the message. That text is then stored and shown to the user on the affected page.

Exploitation

Step 1: Configure a Postfix server that rejects with an HTML payload

Add the following to /etc/postfix/main.cf:

Text
smtpd_recipient_restrictions =
    check_recipient_access hash:/etc/postfix/recipient_access,
    reject_unverified_recipient,
    permit

This makes Postfix consult a recipient access table before accepting the recipient, and reject unverified recipients.

Create /etc/postfix/recipient_access with:

Text
[redacted] REJECT 5.1.1 <img src="" onerror="alert('hackerone!')' />

This maps the address [redacted] to an SMTP rejection with enhanced status code 5.1.1 and a custom text. The text is an img element with an empty src and an onerror handler that calls alert('hackerone!'). That text is what the target site will receive as the SMTP error.

Update the Postfix database and restart the service:

Bash
postmap /etc/postfix/recipient_access
systemctl restart postfix

Step 2: Open the site

Navigate to www.xvideos.com using an up-to-date browser.

Step 3: Start registration

Click the "Join for FREE" button.

Step 4: Register with the rejecting address

Create an account using the configured email address, for example [redacted]. Because that domain is served by the attacker's Postfix instance, the site's validation email will be rejected with the crafted message.

Step 5: Go to the email page

Once the account is created, go to the /account/email route.

Step 6: Trigger validation

Click on "Please click Here to validate it." Click on "Please click Here to validate it."

Step 7: Wait for the error to be displayed

Wait approximately 45 minutes. If the attack succeeds, an alert message saying "hackerone!" appears on the screen, which shows that the injected handler executed in the context of the page.

Root cause

The SMTP error message is passed into the html() method without proper sanitisation. The application treats server-supplied error text as safe markup, so any HTML in the rejection message becomes part of the page. Because the rejection text is chosen by the receiving mail server, an attacker who controls that server controls the markup that is stored and later rendered. The report does not describe any output encoding or content security policy that would have blocked the handler from running.

Impact

The attacker must run the SMTP server that handles the address used at registration, or control a domain that a user mistypes. Users who misspell their email domain could be affected if an attacker controls the mistyped domain. The report also notes that if staff members can view a user's bounce history in the same way as on the /account/email page, they may be subjected to an account takeover. These scenarios can result in the leak of sensitive information. The organisation rated the severity as low.

Fix

The report does not state what was changed. The fix implied by the root cause is to treat SMTP error text as untrusted data: encode it before it reaches the page rather than passing it to html(), so that any markup in the rejection message is displayed as text.

Variants to test

  1. Other places where bounce or delivery-failure text is shown, such as admin bounce-history views. A positive result is the injected handler executing in a staff session.
  2. Different SMTP rejection fields, such as the enhanced status text or the server greeting, if the application surfaces them. A positive result is any of those fields rendering as markup.
  3. Addresses on domains a user is likely to mistype, with the attacker controlling the mistyped domain. A positive result is the payload executing for a victim who registered with the wrong domain.

Hunting notes

This bug lives where an application displays text that originated from a remote protocol peer, here the SMTP rejection from the recipient's mail server. During recon, look for features that send email and then show delivery status or errors back to the user, and for any page that renders server-provided error strings. The signal is a page that echoes protocol-level text verbatim. To show impact, the researcher demonstrated execution with a controlled mail server and a visible alert, and described the staff bounce-history and mistyped-domain scenarios as the paths to other users.

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

What happened, in plain words

XVideos is a large website with a free sign-up flow. When you create an account, you give an email address, and the site sends you a message to check that the address really belongs to you. To send that message, the site has to talk to the mail server that handles your email address. That conversation uses a set of rules called SMTP, which is simply the language mail servers use to pass messages to each other.

Sometimes the receiving mail server says no. For example, it may reply that the address does not exist. When that happens, the mail server sends back a short piece of text explaining the refusal. This is called an SMTP error message. The XVideos page at /account/email, where you manage your email address, takes that refusal text and shows it to you on the page.

The problem is how the page shows it. The site passes the refusal text into a method called html(), which tells the page to treat the text as HTML, the language used to build web pages. It does this without cleaning the text first. Cleaning, or sanitising, means removing anything dangerous before it is displayed. Because the text is not cleaned, whoever runs the receiving mail server can put HTML and JavaScript into the refusal message, and the page will run it as if the site itself had written it. JavaScript is the programming language that runs inside your browser and makes pages interactive.

This kind of bug is called stored cross-site scripting, or stored XSS. "Stored" means the harmful text is saved somewhere and shown later. "Cross-site scripting" means an attacker gets their own code to run inside someone else's website, in the browser of a person viewing that site. The official classification for this weakness is CWE-79, which stands for Improper Neutralization of Input During Web Page Generation. In everyday terms: the site takes text from an untrusted source and puts it into a page without checking it.

A simple comparison: imagine a receptionist who reads out any note handed to them, word for word, including instructions like "now unlock the safe". The receptionist is not being malicious; they simply treat every note as safe. Here, the website is the receptionist, the SMTP error is the note, and the JavaScript is the instruction.

Setting up the trap

To make the site receive a refusal message of the attacker's choosing, the researcher needed to control the mail server that answers for the email address used at registration. The report names Postfix 3.7.11 as the mail server software. Postfix is a common program that runs mail servers. The researcher configured it to reject one chosen address and to include a custom message in the rejection.

The precondition is straightforward: the attacker must be able to register an account with an email address whose domain points at a server they control. A domain is the part after the @ sign, such as example.org. If the attacker owns that domain, they own the mail server behind it, and they decide what it says when it refuses a message. The site must then show that refusal text on /account/email.

Finding it

The report states that SMTP error messages are passed into html() without proper sanitisation. Because the content of an SMTP rejection is chosen by the receiving mail server, an attacker who owns that server can place any text they like into the message, including HTML and JavaScript. That text is then stored and shown to the user on the affected page.

Exploitation

Step 1: Configure a Postfix server that rejects with an HTML payload

A payload here means the piece of code the attacker wants to run. The first change is made to the main Postfix configuration file, /etc/postfix/main.cf:

Text
smtpd_recipient_restrictions =
    check_recipient_access hash:/etc/postfix/recipient_access,
    reject_unverified_recipient,
    permit

Line by line:

  • smtpd_recipient_restrictions is the setting that lists the checks Postfix performs on the recipient of an incoming message, in order.
  • check_recipient_access hash:/etc/postfix/recipient_access tells Postfix to look the recipient up in a table stored in the file /etc/postfix/recipient_access. The hash: prefix means the file is kept in a fast lookup format rather than plain text.
  • reject_unverified_recipient tells Postfix to refuse recipients it cannot verify.
  • permit means that anything that passes the earlier checks is allowed through.

The effect is that Postfix consults the recipient table before accepting a recipient, and rejects unverified ones. This is what gives the attacker a place to attach a custom refusal message.

Next, the researcher creates /etc/postfix/recipient_access with:

Text
[redacted] REJECT 5.1.1 <img src="" onerror="alert('hackerone!')' />

This line maps the address [redacted] to an SMTP rejection. REJECT is the instruction to refuse. 5.1.1 is an enhanced status code, a standard number that means the recipient address does not exist. The rest of the line is the custom text that goes back to the sender.

That custom text is an img element, the HTML tag for an image. Its src attribute, which normally holds the image address, is empty. Because the image cannot load, the browser fires an onerror event, which is a handler that runs when something goes wrong. The handler here calls alert('hackerone!'), which opens a pop-up box in the browser showing the text hackerone!. That text is what the target site will receive as the SMTP error.

Then the database is rebuilt and the service restarted:

Bash
postmap /etc/postfix/recipient_access
systemctl restart postfix
  • postmap /etc/postfix/recipient_access converts the plain text file into the fast lookup format Postfix expects, so the hash: reference works.
  • systemctl restart postfix stops and starts the Postfix service so the new configuration takes effect.

Step 2: Open the site

Navigate to www.xvideos.com using an up-to-date browser.

Step 3: Start registration

Click the "Join for FREE" button. This begins the normal account creation flow.

Step 4: Register with the rejecting address

Create an account using the configured email address, for example [redacted]. Because that domain is served by the attacker's Postfix instance, the site's validation email will be rejected with the crafted message. In other words, the site tries to send the confirmation email, the attacker's mail server says no, and the refusal carries the attacker's HTML.

Step 5: Go to the email page

Once the account is created, go to the /account/email route. A route is simply a path on the website, the part that appears after the domain name in the address bar. This is the page where the site shows the status of the email address on the account.

Step 6: Trigger validation

Click on "Please click Here to validate it." Click on "Please click Here to validate it." The site then has the attacker's text in hand and is about to display it.

Step 7: Wait for the error to be displayed

Wait approximately 45 minutes. Wait approximately 45 minutes. If the attack succeeds, an alert message saying "hackerone!" appears on the screen. That pop-up is proof that the injected handler executed in the context of the page, meaning the browser treated the attacker's text as part of the site's own code.

Why it works

The SMTP error message is passed into the html() method without proper sanitisation. The application treats server-supplied error text as safe markup, so any HTML in the rejection message becomes part of the page. Because the rejection text is chosen by the receiving mail server, an attacker who controls that server controls the markup that is stored and later rendered. The report does not describe any output encoding or content security policy that would have blocked the handler from running. Output encoding is the practice of converting special characters into harmless text before display. A content security policy is a browser rule that limits which scripts a page may run.

What an attacker could do with it

The attacker must run the SMTP server that handles the address used at registration, or control a domain that a user mistypes. In the second, users who misspell their email domain could be affected if an attacker controls the mistyped domain. For example, someone who types a slightly wrong domain could end up sending their confirmation email to a server the attacker owns.

The report also notes that if staff members can view a user's bounce history in the same way as on the /account/email page, they may be subjected to an account takeover. A bounce is a delivery failure, and bounce history is the record of those failures. Account takeover means someone else gains control of an account. These scenarios can result in the leak of sensitive information. The organisation rated the severity as low.

The fix

The report does not state what was changed. The fix implied by the root cause is to treat SMTP error text as untrusted data: encode it before it reaches the page rather than passing it to html(), so that any markup in the rejection message is displayed as text. In the receptionist comparison, the receptionist would read the note aloud as a quotation rather than following its instructions.

Other places to test

  1. Other places where bounce or delivery-failure text is shown, such as admin bounce-history views. A positive result is the injected handler executing in a staff session.
  2. Different SMTP rejection fields, such as the enhanced status text or the server greeting, if the application surfaces them. A positive result is any of those fields rendering as markup.
  3. Addresses on domains a user is likely to mistype, with the attacker controlling the mistyped domain. A positive result is the payload executing for a victim who registered with the wrong domain.

How to look for this yourself

This bug lives where an application displays text that originated from a remote protocol peer, here the SMTP rejection from the recipient's mail server. During recon, which means the early information-gathering phase of a security test, look for features that send email and then show delivery status or errors back to the user, and for any page that renders server-provided error strings. The signal is a page that echoes protocol-level text verbatim. To show impact, the researcher demonstrated execution with a controlled mail server and a visible alert, and described the staff bounce-history and mistyped-domain scenarios as the paths to other users.

Glossary

  • SMTP: the set of rules mail servers use to send and receive email.
  • Mail server: a computer program that handles email for a domain.
  • Postfix: a common mail server program.
  • Domain: the part of an email address after the @ sign, such as example.org.
  • SMTP error message: the text a receiving mail server sends back when it refuses a message.
  • Enhanced status code: a standard number in an SMTP reply that describes the reason for a refusal, such as 5.1.1 for a non-existent recipient.
  • HTML: the language used to structure web pages.
  • JavaScript: the programming language that runs in the browser and makes pages interactive.
  • html() method: a function that tells the page to treat a piece of text as HTML.
  • Sanitisation: cleaning text to remove anything dangerous before it is displayed.
  • Output encoding: converting special characters into harmless text so they are shown rather than executed.
  • Stored XSS: cross-site scripting where the harmful text is saved and shown later to whoever views the page.
  • Cross-site scripting (XSS): a bug where an attacker gets their own code to run inside someone else's website, in a visitor's browser.
  • CWE-79: the standard classification for cross-site scripting, formally Improper Neutralization of Input During Web Page Generation.
  • Payload: the piece of code an attacker wants to run.
  • Attribute: a setting inside an HTML tag, such as src or onerror.
  • onerror handler: code that runs when an element, such as an image, fails to load.
  • alert(): a browser function that opens a pop-up box with a message.
  • Route: a path on a website, the part after the domain name in the address bar.
  • Content security policy: a browser rule that limits which scripts a page may run.
  • Bounce: a delivery failure for an email message.
  • Bounce history: the record of delivery failures for an address.
  • Account takeover: a situation where someone else gains control of an account.
  • Recon: the early information-gathering phase of a security test.

More from XVIDEOS

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.