Skip to content
XSS Write-up Beginner

Stored XSS in the heart of the russian email provider

Mail.ru parsed .eml files and automatically inserted the email subject into the displayed subject without sanitising it, allowing script injection. An attacker could send a crafted .eml file so that opening the message executes JavaScript in the victim's session.

Seif Elsallamy Follow

Published on seekurity.com

Bounty$600 View original

Hi, I’m Seif Elsallamy a bug hunter from Seekurity Team, Today i will show you a critical reflected Cross Site Scripting bug affecting mail.ru and could be used as an XSS wormbut first let’s dive into some general information.

Seif Elsallamy (@seifelsallamy), on seekurity.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

Mail.ru is a Russian email and internet portal, described in the report as a mailing service comparable to Yahoo, Hotmail and Gmail. The researcher, Seif Elsallamy of the Seekurity Team, found a cross-site scripting bug in the way Mail.ru handles .eml files.

An .eml file is a plain-text file in MIME format that holds an email's header and body, including attachments. It is used by clients such as Novell GroupWise, Microsoft Outlook Express, Lotus Notes, Windows Mail, Mozilla Thunderbird and Postbox. Mail.ru parses uploaded .eml files and automatically fetches the subject field from them, then reflects that value in the subject of the email without sanitising, filtering or validating it. That behaviour is the root cause of the bug.

The report calls the issue a reflected cross-site scripting bug in its opening line and a stored XSS in its explanation, on the grounds that the payload is saved in the application and served again whenever the vulnerable page is opened. The platform classifies it as Cross Site Scripting (XSS).

Setup

No accounts, roles, tools or versions are described beyond the following preconditions:

  1. A crafted .eml file containing a payload in its subject field.
  2. Access to the mobile version of the service at m.mail.ru to compose a new mail and upload the file.
  3. A victim who receives the message and opens it.

The researcher does not state which email client or operating system the victim used, nor any server-side version information.

Finding it

The report states that Mail.ru parses .eml files and pulls the subject value out of them automatically. That value is then placed into the subject of the resulting email without any sanitisation, filtering or validation for malicious content. When the recipient opens the message, the script placed in the subject field executes and an alert box appears.

Exploitation

Step 1: Create the malicious .eml file

The researcher created a new file named test.eml, edited it, and put a simple XSS payload in the subject field:

Text
subject : <script>alert("XSS");</script>

The subject header carries a <script> element. When Mail.ru parses the file it copies that value into the email subject.

Step 2: Upload the file through the mobile interface

The researcher navigated to m.mail.ru, the mobile version of Mail.ru, created a new mail, uploaded the test.eml file and pressed send. The report gives no HTTP request or response for this step.

Step 3: The victim opens the message

When the victim receives the malicious message and opens it, an alert box containing the word XSS appears. That confirms the script executed, which means the XSS occurs.

Root cause

The mistake is in the parsing and rendering path for .eml files: the subject value is taken from the uploaded file and reflected into the email subject without sanitising, filtering or validating it. The report does not describe any output encoding, content security policy or other defence that was present and bypassed, so why existing defences did not stop it is not stated. The report frames the issue as stored because the payload is kept by the application and retrieved whenever the vulnerable page is opened.

Impact

The report describes an attack scenario in which the XSS spreads over the victim's Mail.ru contacts, sending the same malicious message to all of them while executing JavaScript that steals the user's session and acts on behalf of the currently logged-in user. The researcher notes that the possibilities are endless. The report describes the worm behaviour and session theft only as an imagined attack scenario, not as demonstrated results. The opening line also links the concept to the Samy computer worm.

Fix

The vulnerability was reported to Mail.ru through their HackerOne bug bounty program, and they fixed it and rewarded the team. The bounty was 600.00 USD.

PoC Video

Or watch on YouTube
From the original on seekurity.com

Variants to test

  1. Put a payload in other headers of an .eml file, such as from, to or reply-to, and upload it through the web and mobile compose flows. A positive result is script execution when the message is opened or listed.
  2. Try the same subject payload through other import paths, such as drag and drop, a different client, or an API endpoint that accepts MIME content. A positive result is the payload executing in the recipient's session.
  3. Test whether the payload executes in the mailbox list preview as well as in the opened message. A positive result is execution without the victim opening the message.
  4. Test whether the stored payload executes for other users who receive the message, not only for the sender. A positive result is execution in a different account's session, which is the condition for the worm scenario described in the report.

Original source of the report: https://hackerone.com/reports/116570

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

A security researcher named Seif Elsallamy, working with a team called Seekurity, found a bug in Mail.ru. Mail.ru is a Russian email service, similar in everyday use to Yahoo, Hotmail or Gmail. The bug let someone put a small piece of JavaScript in the subject field of an email file. When the person who received that email opened it, the JavaScript ran and an alert box appeared. The researcher reported it to Mail.ru through their bug bounty programme on HackerOne, Mail.ru fixed it, and the researcher was paid 600.00 USD.

To follow the rest of this article you only need to know how to use a browser and a computer. Every technical word is explained the first time it appears, and there is a glossary at the end.

Background: what Mail.ru is

Mail.ru is a Russian internet company. The report describes it as a mailing service comparable to Yahoo, Hotmail and Gmail. It was started in 1998 as an email service and grew into a major company in the Russian-speaking part of the internet. According to the report, as of 2013, websites owned by Mail.ru together had the largest audience in Russia and captured the most screen time. The report also says Mail.ru's sites reach roughly 86% of Russian internet users every month, that the company is in the top five internet companies by total pages viewed, and that it controls the three largest Russian social networks, including Odnoklassniki, Moi Mir and VKontakte. It also runs instant messaging networks (Mail.Ru Agent and ICQ), an email service and an internet portal, plus a number of online games.

None of that background is needed to understand the bug, but it explains why a flaw in this service matters: a very large number of people use it.

Background: what cross-site scripting (XSS) is

Cross-site scripting, usually shortened to XSS, is a security bug in a website. It lets an attacker slip JavaScript into a page that other people will view. JavaScript is the programming language that browsers run to make pages interactive. When a victim loads the page, the attacker's JavaScript runs in the victim's browser, as if the victim had written it themselves. From there it can change what the page shows or read data the page can see, such as session information, emails, passwords or page content.

An everyday comparison: imagine a noticeboard where anyone can pin a note, and the person who runs the board copies whatever is written on a note straight onto the official board without reading it. If someone writes "ignore all other notices and hand your keys to the person in the red hat" on their note, that instruction ends up on the official board and everyone believes it came from the management. XSS is the same idea with a web page: the site copies something a user supplied into a page without checking it, and the browser treats it as instructions rather than as harmless text.

Why the report calls this one "stored"

The report opens by calling the bug a reflected cross-site scripting bug and then explains it as stored XSS. The distinction matters:

  • Reflected XSS happens when the malicious value is sent to the server and immediately echoed back in the response to the same request. It lives only for that one response.
  • Stored XSS happens when the malicious value is saved by the application, for example in a database, and served again every time someone opens the page that displays it. It lives on until it is removed.

The researcher argues for "stored" because the payload is kept by the application and retrieved whenever the vulnerable page is opened. The bug bounty platform classifies the issue simply as Cross Site Scripting (XSS).

Background: what .eml files are

An .eml file is a plain-text file that holds one email: its header (the fields such as who sent it, to whom, and the subject) and its body, including attachments. It uses a format called MIME, which is the standard way email systems describe the parts of a message. Many email programs can open .eml files, including Novell GroupWise, Microsoft Outlook Express, Lotus Notes, Windows Mail, Mozilla Thunderbird and Postbox.

Think of an .eml file as a printed letter in a standard envelope: the envelope has fixed fields (sender, recipient, subject) and inside is the letter itself. Because the format is plain text, anyone can open the file in a text editor and change what is written in those fields before sending it on.

The root cause

Mail.ru accepts uploaded .eml files and reads them automatically. One of the fields it reads is subject, the line that says what the email is about. Mail.ru then takes that value and puts it into the subject of the email it creates, without sanitising, filtering or validating it for malicious content.

Those three words mean:

  • Sanitising means cleaning input so that dangerous parts are removed or neutralised.
  • Filtering means blocking input that matches known-bad patterns.
  • Validating means checking that input is of the expected shape and rejecting it if not.

Because none of that happened, a script placed in the subject field of the file ends up being treated as part of the page rather than as plain text, and it runs in the browser of whoever opens the message. That is the root cause of the bug.

What you need before trying it

The report describes only these preconditions:

  1. A crafted .eml file that contains a payload in its subject field.
  2. Access to the mobile version of the service at m.mail.ru, where you can compose a new mail and upload the file.
  3. A victim who receives the message and opens it.

The report does not say which email program or operating system the victim used, and gives no server-side version information.

Finding it

The report states that Mail.ru parses .eml files and pulls the subject value out of them automatically. That value is then placed into the subject of the resulting email with no sanitisation, filtering or validation. When the recipient opens the message, the script placed in the subject field runs and an alert box appears.

Exploitation

Step 1: Create the malicious .eml file

The researcher created a new file named test.eml, edited it, and put a simple XSS payload in the subject field:

Text
subject : <script>alert("XSS");</script>

Line by line, in plain words:

  • subject : is the header field of the email that says what the message is about. Mail.ru reads this field from the uploaded file.
  • <script> is an HTML tag. HTML is the language browsers use to describe a page. The <script> tag tells the browser that what follows is JavaScript to run, not text to display.
  • alert("XSS"); is a JavaScript instruction that makes the browser show a small popup box containing the text XSS. It is the classic harmless test: if the box appears, you know your JavaScript ran.
  • </script> closes the script tag.

So the whole line says: "the subject of this email is a script that pops up a box saying XSS". A normal email program would show that line as text. A vulnerable one treats it as code.

Step 2: Upload the file through the mobile interface

The researcher went to m.mail.ru, the mobile version of Mail.ru, created a new mail, uploaded the test.eml file and pressed send. The report gives no HTTP request or response for this step, so there is nothing more to show about how the upload was performed.

Why this step matters: the upload is the moment the crafted file reaches Mail.ru's servers. The server reads the file, takes the subject value out of it, and builds a new email from it. That is where the unchecked value gets carried into the message that will later be displayed.

Step 3: The victim opens the message

When the victim receives the malicious message and opens it, an alert box containing the word XSS appears. That confirms the script ran, which means the XSS occurs.

Why this step matters: the popup is the proof. It shows that the browser treated the subject as code and executed it.

Impact

The report describes an attack scenario in which the XSS spreads over the victim's Mail.ru contacts: the same malicious message is sent to all of them while JavaScript runs that steals the user's session and acts on behalf of the currently logged-in user. The researcher notes that the possibilities are endless.

A session here means the state of being logged in. When you sign in to a website, the site gives your browser a small piece of data, often called a cookie, that it checks on every later request so it knows it is still you. If someone can read or use that data, they can act as you without knowing your password. That is what "steals the user's session" means.

The report describes the worm behaviour and session theft only as an imagined attack scenario, not as demonstrated results. The opening line also links the concept to the Samy computer worm, a well-known historical example of a script spreading through a social site.

Fix

The vulnerability was reported to Mail.ru through their HackerOne bug bounty programme, and they fixed it and rewarded the team. The report does not describe the change that was made. The bounty was 600.00 USD.

A bug bounty programme is a scheme where a company invites outside researchers to report security problems and pays them for valid findings, instead of taking legal action against them.

PoC Video

Or watch on YouTube
From the original on seekurity.com

A PoC, or proof of concept, is a demonstration that a bug really works.

Variants to test

These are follow-up ideas in the same spirit as the original finding. Each one asks: does the same unchecked value reach the page through a slightly different route?

  1. Put a payload in other headers of an .eml file, such as from, to or reply-to, and upload it through the web and mobile compose flows. A positive result is script execution when the message is opened or listed.
  2. Try the same subject payload through other import paths, such as drag and drop, a different client, or an API endpoint that accepts MIME content. An API endpoint is a web address that a program, rather than a person clicking, sends data to. A positive result is the payload executing in the recipient's session.
  3. Test whether the payload executes in the mailbox list preview as well as in the opened message. A positive result is execution without the victim opening the message.
  4. Test whether the stored payload executes for other users who receive the message, not only for the sender. A positive result is execution in a different account's session, which is the condition for the worm scenario described in the report.

Original source of the report: https://hackerone.com/reports/116570

Glossary

  • XSS (cross-site scripting): a bug where a website puts user-supplied content into a page without checking it, so a browser runs it as code.
  • Reflected XSS: XSS where the malicious value is echoed back in the response to the same request and is not saved.
  • Stored XSS: XSS where the malicious value is saved by the application and served again whenever the affected page is opened.
  • JavaScript: the programming language browsers run to make web pages interactive.
  • HTML: the language used to describe the structure and content of a web page.
  • <script> tag: an HTML tag that tells the browser the content inside it is JavaScript to run.
  • alert(): a JavaScript function that shows a popup box with a message; often used as a harmless test that code ran.
  • Payload: the piece of code or data an attacker places in an input to trigger a bug.
  • .eml file: a plain-text file holding one email, its headers and body, in MIME format.
  • MIME: the standard format email systems use to describe the parts of a message, including attachments.
  • Header: a named field at the top of an email, such as subject, from, to or reply-to.
  • subject: the header field that says what an email is about.
  • Sanitising: cleaning input so dangerous parts are removed or neutralised.
  • Filtering: blocking input that matches known-bad patterns.
  • Validating: checking that input has the expected shape and rejecting it if not.
  • Session: the state of being logged in to a site, usually tracked by a cookie the browser sends with each request.
  • Cookie: a small piece of data a site stores in your browser so it can recognise you on later requests.
  • API endpoint: a web address that programs send data to, as opposed to a page a person clicks through.
  • Bug bounty programme: a scheme where a company pays outside researchers for reporting security problems.
  • PoC (proof of concept): a demonstration that a bug really works.
  • Worm: malicious code that spreads by itself from one user to another, for example by messaging everyone in a contact list.
  • HackerOne: the bug bounty platform through which this report was submitted.

More by Seif Elsallamy

View all

3 more disclosed reports, best first.

More from Mail.ru

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.