Stored XSS in *.myshopify.com
The Theme Editor's input fields would instantiate any HTML typed into them into the document's DOM due to creative sanitization code that used document.createElement('div').innerHTML to fix unclosed tags. An attacker could inject a payload that triggers stored XSS in the admin section.
Originally disclosed on HackerOne
- Triaged in 3 days
- Fixed in 10 days
- Paid in 10 days
- Disclosed after 10 days
Summary by the program
The researcher reported an issue where any html typed in a input field in the Theme Editor would be instantiated in the document's DOM. We traced the issue to some creative sanitization code that attempted to fix unclosed html tags by doing something like document.createElement('div').innerHTML = value any time a onblur or onchange event was triggered on a input field in the Theme Editor. We've changed the offending code to run in a sandboxed iframe without script execution privileges.
The report
Hello,
First of all in noticed that this is out of scope "Any issue related to the storefront area being displayed in a <iframe> element in the admin area, for example in the Theme Editor."
This is not in the store front and this will be set in an XSS payload.
- Go to https://(YOUR SHOP).myshopify.com/admin/themes/THEME id)/editor
- Select header and scroll down to "annoucement text".
- Fill there as payload: ">
- Click save and the XSS will be popped up.
I have checked it twice and it is not gonna reflect on the store front. This XSS is in the myshopify/admin section.
POC screen: https://snag.gy/FImTKd.jpg
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the sanitization code used document.createElement('div').innerHTML to fix unclosed HTML tags, which executed scripts when the value was inserted into the DOM.
Impact
An attacker could execute JavaScript in the admin section of a Shopify store.
What the attacker needed
Access to the Theme Editor; a Shopify store
The fix
The offending code was changed to run in a sandboxed iframe without script execution privileges.
How it was found
- Go to the Theme Editor for a shop.
- Select the header section and scroll to the announcement text field.
- Enter a payload that includes HTML and a media reference.
- Click save, which triggers the XSS.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
The Theme Editor is a tool for changing how an online shop looks. It took text typed into a field and inserted it into the page as code, so someone could type code that runs when the page loads.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.