Skip to content
XSS Write-up Intermediate

Reflected XSS on Microsoft subdomains

Reflected cross-site scripting (XSS) vulnerabilities were found on several Microsoft subdomains due to unencoded 'cookieless' session identifiers in URLs. An attacker could craft a malicious link that, when clicked, would execute arbitrary JavaScript in the victim's browser, potentially compromising the user's account and data.

Raimonds Liepins Follow

Published on medium.com

{{media:0}}

Raimonds Liepins, 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. 5 min read.

Context

This is a write-up about reflected cross-site scripting on several microsoft.com subdomains. The affected hosts listed in the report are:

  • activateuat.microsoft.com
  • gallery.technet.microsoft.com
  • ppe.gallery.technet.microsoft.com
  • ppe.code.msdn.microsoft.com

The feature at the centre of it is the ASP.NET cookieless session identifier: the (A(ABCD)) style segment that a .NET application can place in the URL path when session state is configured to be cookieless. The report explains that the technique works when developers resolve resources with a tilde symbol, for example:

HTML
<script src=”<%= ResolveUrl(“~/Script.js”) %>”></script>

In that case the resolved path includes the cookieless segment, and the segment is not HTML-encoded by design.

Setup

The researcher used three command-line tools, all linked in the report:

  • assetfinder, for subdomain enumeration
  • httprobe, for checking which hosts respond over HTTP
  • cookieless, a tool the researcher wrote to automate the manual testing process

No accounts, roles or specific versions are described. The precondition for the bug is a .NET site that uses cookieless session identifiers and resolves resources with ResolveUrl on a tilde path.

Finding it

The discovery step was a single pipeline over the microsoft.com domain:

Bash
assetfinder -subs-only microsoft.com | httprobe | cookieless

assetfinder produces the subdomain list, httprobe keeps the ones that answer, and cookieless probes them for the cookieless identifier behaviour. The researcher notes that finding vulnerabilities like these is not hard.

Exploitation

Step 1: understand the reflection point

The cookieless part of the URL, shown in the report as (A(ABCD)), is not HTML-encoded by design. That lets an attacker escape the context of the HTML tag. The report gives this URL as the example:

Text
https://gallery.technet.microsoft.com/(A(ABCD))/

which, according to the report, translates to:

HTML
<script src=”/(A(ABCD))/Script.js”>

So the identifier lands inside the src attribute of a script tag, and the characters of the identifier are reflected without encoding.

Step 2: break out of the attribute

Not all characters are supported in the cookieless identifier, but the report says that with enough tinkering you can find a way to get an alert to pop up. The payload given is:

Text
https://gallery.technet.microsoft.com/(A(%22onerror='alert%601%60'testabcd))/

Here %22 is a double quote, which closes the src attribute, and the rest injects an onerror handler with alert calls written with %60 (backtick) delimiters. The trailing testabcd fills out the identifier. The report notes that an attacker can do much more than an alert, as described in the impact section.

Step 3: bypass length and character limits with a third-party script

Some of these domains do not have a Content-Security-Policy at all. In that situation you can include scripts from third-party locations, which bypasses the restrictions that would otherwise apply within the scope of URL length and the characters allowed by the cookieless identifier.

For a deeper explanation the report points to an article at https://blog.isec.pl/all-is-xss-that-comes-to-the-net/ and to Microsoft's documentation for SessionStateSection.Cookieless at https://docs.microsoft.com/en-us/dotnet/api/system.web.configuration.sessionstatesection.cookieless?view=netframework-4.8.

Root cause

The cookieless session identifier is placed into the URL path and then reflected into the page inside a script src attribute without HTML encoding. Because the identifier is not encoded, characters such as the double quote can terminate the attribute and introduce new attributes, including event handlers. The report says the cookieless part of the URL is in no way HTML-encoded by design.

Some of the affected domains have no Content-Security-Policy, so scripts from third-party locations can be included.

Impact

The report describes the general consequences of a reflected XSS where an attacker controls a script executed in the victim's browser. The attacker can typically fully compromise that user, and among other things can:

  • perform any action within the application that the user can perform;
  • view any information that the user is able to view;
  • modify any information that the user is able to modify;
  • initiate interactions with other application users, including malicious attacks, that will appear to originate from the initial victim user.

The report does not describe a specific victim population or a concrete attack chain beyond this general list.

Fix

The report states that the issues have been addressed, without describing the code change. The report states only that the issues have been addressed and does not describe the code change.

Variants to test

  • Run the same pipeline against other large domains and look for hosts that answer with a cookieless identifier in the path. A positive result is a URL such as https://host/(A(ABCD))/ that still resolves resources correctly.
  • On any host that shows the identifier, try to close the surrounding attribute with %22 and add an event handler, as in the payload above. A positive result is an alert firing from the reflected value.
  • Check whether the host sends a Content-Security-Policy. If it does not, try loading a script from a third-party location to work around the length and character limits of the identifier.
  • Test the same technique on other .NET applications that use ResolveUrl with tilde paths, since the reflection depends on that pattern.

Disclosure timeline

  • March 17, 2020: vulnerability submitted to Microsoft MSRC.
  • March 19, 2020: public disclosure, as Microsoft MSRC deemed it not a vulnerability.
  • March 23, 2020: public disclosure hidden, since Microsoft MSRC reassessed the vulnerabilities and they do in fact meet their bar for service.
  • Issues have been addressed.

Microsoft's original reply was that the report was out of scope of their security program and not deemed a security vulnerability at all:

This does not meet the bar for security servicing as it requires a user copy and paste malicious code into a text field or modify user-side code/traffic. Self targeting attacks like this are not considered a security vulnerability as it requires social engineering to target another user.

On 24 March 2020 the researcher added an update: Microsoft re-assessed the rejected vulnerabilities on 23 March and these issues do meet their bar for service, so the details were removed until they were patched. Microsoft's reassessment reads:

This submission was incorrectly assessed as self-XSS instead of reflected XSS. It was later informed to us that these do meet the bar for service.

The researcher notes that they got into Microsoft's newbie hall of fame in the March 2020 section, and that the lesson learned is to never submit reflected XSS to Microsoft without a proper escalation.

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

What happened, in plain words

A security researcher found reflected cross-site scripting on several Microsoft websites. This kind of bug is called reflected cross-site scripting, usually shortened to XSS. The researcher reported it to Microsoft, and Microsoft first said it was not a security problem at all. The researcher then published a write-up. A few days later Microsoft looked again, changed its mind, and the researcher took the details down until they were patched.

This article walks through the same story from the beginning, assuming you have never done security testing before. You only need to know how to use a browser and a computer. Every tool and term is explained where it first appears.

Raimonds Liepins
Raimonds Liepins From the original on medium.com

The author is Raimonds Liepins, and the write-up was published on 19 March 2020.

Image for post
Image for post From the original on medium.com

The reply that started it

Microsoft's security team, called MSRC (Microsoft Security Response Center), is the group that receives reports of possible security bugs in Microsoft products. When the researcher sent them this finding, MSRC replied that it was out of scope of their security program, meaning outside the set of things they agree to investigate, and that they did not consider it a security vulnerability at all. Their reply was:

This does not meet the bar for security servicing as it requires a user copy and paste malicious code into a text field or modify user-side code/traffic. Self targeting attacks like this are not considered a security vulnerability as it requires social engineering to target another user.

In plain words, Microsoft thought the only way to trigger the bug was for the victim to paste malicious code into a text box themselves, or to tamper with their own browser traffic. An attack where the victim has to harm themselves is often called self-XSS. Social engineering means tricking a person into doing something, for example convincing them to paste text they do not understand. Microsoft's position was that this required tricking the victim, so it was not a real vulnerability.

Because of that reply, the researcher decided to publish a write-up describing the finding.

The correction

On 24 March 2020 the researcher added an update to the article. Microsoft had re-assessed the rejected vulnerabilities on 23 March, and this time concluded that the issues did meet their bar for service, meaning they were serious enough for Microsoft to fix. The researcher, who believes in responsible disclosure (telling the vendor and giving them time to fix before publishing details), removed the technical details until the sites were patched. Microsoft's new statement was:

This submission was incorrectly assessed as self-XSS instead of reflected XSS. It was later informed to us that these do meet the bar for service.

So Microsoft admitted the first assessment was wrong: the bug was not self-XSS, where the victim attacks themselves, but reflected XSS, where an attacker sends a crafted link and the victim's browser runs the attacker's code.

The researcher notes that they got into Microsoft's newbie hall of fame, a recognition list for people new to reporting bugs to Microsoft, in the March 2020 section. The lesson they draw is that you should never ever submit reflected XSS to Microsoft without a proper escalation, meaning a clear explanation of how an attacker could realistically use it against another person. They say there was a lot of possibility for such an escalation, as the rest of the article describes.

Image for post
Image for post From the original on medium.com

The affected websites

The bug was present on these Microsoft subdomains:

  • activateuat.microsoft.com
  • gallery.technet.microsoft.com
  • ppe.gallery.technet.microsoft.com
  • ppe.code.msdn.microsoft.com

A subdomain is a smaller address inside a larger one. If microsoft.com is a big building, each subdomain is a named office inside it, such as gallery.technet.microsoft.com. Each one can be a separate website run by a separate team, which is why one bug pattern can appear on several of them at once.

What a reflected XSS actually lets an attacker do

Before the technical part, it helps to understand why anyone cares. A website sends a page to your browser, and your browser runs any scripts (small programs) that page contains. Normally those scripts come from the website and do harmless things like making buttons work. If an attacker can control a script that runs in the victim's browser, they can typically fully compromise that user. Among other things, the attacker can:

  • Perform any action within the application that the user can perform.
  • View any information that the user is able to view.
  • Modify any information that the user is able to modify.
  • Initiate interactions with other application users, including malicious attacks, that will appear to originate from the initial victim user.

A useful comparison: your browser session on a website is like being logged in at a bank counter with the clerk already knowing who you are. If someone else can stand at that counter and speak as you, they can move your money, read your statements and send messages in your name. That is what running attacker-controlled script in your browser means.

The report links to an external explainer on cross-site scripting for readers who want the general background.

How the researcher found the bug

Finding vulnerabilities like these is not hard, according to the report. The researcher ran one command:

Bash
assetfinder -subs-only microsoft.com | httprobe | cookieless

This is a pipeline: three small programs run one after another, and the output of each is fed into the next. The vertical bar | is the pipe symbol that connects them.

  • assetfinder -subs-only microsoft.com asks assetfinder to list subdomains of microsoft.com only. A subdomain is a name like gallery.technet.microsoft.com. This step produces a long list of names.
  • httprobe takes that list and checks which names actually answer over HTTP, the protocol browsers use to fetch web pages. Many subdomains exist in DNS (the internet's name directory) but no longer serve anything, so this step throws away the dead ones.
  • cookieless is a tool the researcher wrote to automate part of the manual testing process. It looks at the surviving sites for a particular behaviour, described in the next section.

The three tools are linked in the report: assetfinder and httprobe are by tomnomnom, and cookieless is by the researcher. The point of the pipeline is scale: instead of opening sites by hand, you let the computer narrow thousands of names down to the few worth looking at.

The feature at the centre: cookieless sessions

To understand the bug you need to know what a cookie is. When you log in to a website, the server needs a way to recognise you on your next request. It gives your browser a small piece of text called a session cookie, and your browser sends it back with every request. The cookie is like a cloakroom ticket: the number on the ticket tells the attendant which coat is yours, without you carrying the coat around.

Some older .NET web applications (ASP.NET is Microsoft's framework for building websites) can be configured to work without cookies. In that mode, the same ticket is put into the URL itself, in a segment that looks like (A(ABCD)). This is called the cookieless session identifier. The report explains that the technique works when developers resolve resources with a tilde symbol, for example:

HTML
<script src=”<%= ResolveUrl(“~/Script.js”) %>”></script>

Line by line:

  • <script src=”...”></script> is an HTML tag that tells the browser to load and run a script file. The src attribute holds the address of that file.
  • <%= ... %> is a server-side instruction in ASP.NET: the server replaces it with a value before sending the page to the browser.
  • ResolveUrl(“~/Script.js”) is a helper that turns a path starting with ~ (meaning the root of the application) into a full path. If the application is using cookieless sessions, that resolved path includes the cookieless segment.

The key sentence from the report is that the cookieless part of the URL is in no way HTML-encoded by design. HTML encoding means replacing special characters such as " and < with safe stand-ins so the browser treats them as text rather than as instructions. Because the identifier is not encoded, an attacker can escape the context of the HTML tag, meaning they can break out of the place where their text was supposed to sit and start writing new HTML of their own.

Step 1: see where the value lands

The report gives this URL as the example:

Text
https://gallery.technet.microsoft.com/(A(ABCD))/

Here gallery.technet.microsoft.com is the site, and (A(ABCD)) is the cookieless identifier. According to the report, this URL translates to:

HTML
<script src=”/(A(ABCD))/Script.js”>

So the identifier ends up inside the src attribute of a script tag. Whatever characters you put in the identifier appear in that attribute. If you can put a double quote there, you can close the attribute early and add your own attributes after it. That is the whole trick.

Step 2: break out of the attribute

Not all characters are supported in the cookieless identifier, but the report says that with enough tinkering you can find a way to get the alert to pop up. An alert is the small pop-up box a browser shows when a script calls alert(). It is the standard harmless proof that you can run script on a page. The payload given is:

Text
https://gallery.technet.microsoft.com/(A(%22onerror='alert%601%60'testabcd))/

Breaking it down:

  • %22 is the URL encoding of a double quote ". URLs cannot contain raw quotes, so special characters are written as a percent sign and two hex digits. When the server decodes it, the quote appears in the page.
  • That quote closes the src attribute early, so the browser thinks the address of the script has ended.
  • onerror='alert%601%60' adds a new attribute called onerror. onerror is an event handler: a piece of script the browser runs if loading the script fails. Since the address was cut short, loading fails, and the handler runs.
  • %60 is the URL encoding of a backtick character. The report writes the alert calls with backticks as delimiters, so alert%601%60 becomes alert followed by the value 1 in backticks.
  • testabcd fills out the rest of the identifier so the URL stays well formed.

The result is that the browser runs the attacker's script as part of the Microsoft page. The report notes that an attacker can do much more than an alert, as the impact section above describes.

Step 3: get around the length and character limits

Some of these domains do not have a Content-Security-Policy at all. A Content-Security-Policy, usually shortened to CSP, is a header a website can send to tell the browser which sources of script are allowed. It is like a guest list at a door: the browser refuses to run scripts from anywhere not on the list. Without a CSP, there is no guest list.

In that situation you can include scripts from third-party locations, meaning from servers the attacker controls. This bypasses the restrictions that would otherwise apply within the scope of URL length and the characters allowed by the cookieless identifier. In other words, the identifier is short and only accepts some characters, so writing a whole attack inside it is awkward. But if the page will happily load a script from anywhere, the attacker only needs to squeeze in a short reference to their own file, and the real code lives there.

For a deeper explanation the report points to an article at https://blog.isec.pl/all-is-xss-that-comes-to-the-net/ and to Microsoft's documentation for SessionStateSection.Cookieless at https://docs.microsoft.com/en-us/dotnet/api/system.web.configuration.sessionstatesection.cookieless?view=netframework-4.8.

Why it happens

The cookieless session identifier is placed into the URL path and then reflected into the page inside a script src attribute without HTML encoding. Reflected means the value you sent in the request comes back in the response. Because the identifier is not encoded, characters such as the double quote can terminate the attribute and introduce new attributes, including event handlers. The report says the cookieless part of the URL is in no way HTML-encoded by design.

Some of the affected domains have no Content-Security-Policy, so scripts from third-party locations can be included.

How it was fixed

The report states that the issues have been addressed, without describing the code change. The report states only that the issues have been addressed and does not describe the code change.

Things worth trying on other sites

  • Run the same pipeline against other large domains and look for hosts that answer with a cookieless identifier in the path. A positive result is a URL such as https://host/(A(ABCD))/ that still resolves resources correctly.
  • On any host that shows the identifier, try to close the surrounding attribute with %22 and add an event handler, as in the payload above. A positive result is an alert firing from the reflected value.
  • Check whether the host sends a Content-Security-Policy. If it does not, try loading a script from a third-party location to work around the length and character limits of the identifier.
  • Test the same technique on other .NET applications that use ResolveUrl with tilde paths, since the reflection depends on that pattern.

Timeline

  • March 17, 2020: vulnerability submitted to Microsoft MSRC.
  • March 19, 2020: public disclosure, as Microsoft MSRC deemed it not a vulnerability.
  • March 23, 2020: public disclosure hidden, since Microsoft MSRC reassessed the vulnerabilities and they do in fact meet their bar for service.
  • Issues have been addressed.

Glossary

  • XSS (cross-site scripting): a bug where an attacker gets their own script to run inside someone else's browser on a website the victim trusts.
  • Reflected XSS: XSS where the malicious value is sent in a request and immediately echoed back in the response page, usually via a crafted link.
  • Self-XSS: a fake attack where the victim is tricked into pasting malicious code into their own browser; it is not considered a real vulnerability because the victim harms themselves.
  • Subdomain: a named part of a larger domain, such as gallery.technet.microsoft.com inside microsoft.com.
  • MSRC: Microsoft Security Response Center, the team that receives and assesses security reports about Microsoft products.
  • Out of scope: outside the set of things a bug bounty or security program agrees to investigate.
  • Bar for service: the threshold a report must meet for the vendor to treat it as a real issue worth fixing.
  • Social engineering: tricking a person into doing something, such as pasting text or clicking a link.
  • Responsible disclosure: reporting a bug to the vendor and giving them time to fix it before publishing details.
  • Escalation: in a bug report, a clear explanation of how an attacker could realistically use the bug against another person.
  • Cookie: a small piece of text a website stores in your browser so it can recognise you on later requests.
  • Session: the period during which a website remembers who you are, usually tied to a cookie or an identifier.
  • Session identifier: the value that ties your requests to your session, like a cloakroom ticket number.
  • Cookieless session: a mode where the session identifier is carried in the URL instead of a cookie.
  • ASP.NET / .NET: Microsoft's framework for building web applications and programs.
  • HTML: the language that describes the structure of a web page, using tags such as <script>.
  • HTML encoding: replacing special characters with safe stand-ins so the browser treats them as text, not instructions.
  • Attribute: a setting inside an HTML tag, such as src on a script tag.
  • Event handler: script attached to an element that runs when something happens, such as onerror when loading fails.
  • ResolveUrl: an ASP.NET helper that turns a path starting with ~ into a full path, including the cookieless segment when that mode is on.
  • Tilde (~): in ASP.NET, a shorthand for the root of the application.
  • URL encoding: writing special characters in a URL as a percent sign and two hex digits, such as %22 for a double quote.
  • Content-Security-Policy (CSP): a header a site sends to tell the browser which sources of script it may run.
  • Pipeline: running several command-line programs in sequence, feeding each one's output into the next with |.
  • assetfinder: a tool that lists subdomains of a domain.
  • httprobe: a tool that checks which hostnames answer over HTTP.
  • cookieless: the researcher's tool that automates part of the manual testing for cookieless identifier behaviour.
  • DNS: the internet's name directory, which maps names like microsoft.com to servers.
  • HTTP: the protocol browsers use to request and receive web pages.
  • Alert: the small pop-up a browser shows when a script calls alert(), used as harmless proof that script can run.
  • Newbie hall of fame: a recognition list Microsoft keeps for people new to reporting bugs to them.

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.