XSS on $shop$.myshopify.com/admin/ and partners.shopify.com via whitelist bypass in SVG icon for sales channel applications
A whitelist bypass in SVG icon uploads for sales channel applications allowed developers to include an onload attribute, leading to cross-site scripting on partners.shopify.com and any shop's admin panel that authorised the app. An attacker could execute JavaScript in the context of an administrator's session after the admin authorised the malicious app.
Originally disclosed on HackerOne
- Triaged in 5 hours
- Fixed in 32 days
- Paid in 33 days
- Disclosed after 33 days
Description
Shopify allows developers to create a special type of application called a "Sales Channel". Developers are allowed to upload a 16x16 SVG "Navigation Icon" for their app provided the SVG follows the design guidelines which limits the allowed elements and attributes. For some reason when the SVG contains an XML entity this whitelist is no longer enforced allowing the developer to include malicious attributes such as onload. By uploading a malicious SVG a developer can obtain XSS on both partners.shopify.com, as well as any the admin panel of any shop which has authorized the sales channel.
Proof of Concept
This is relatively easy to reproduce, first create a new application within the Partners dashboard then navigate to "Extensions" -> "Sales channel" to convert the application. After saving those changes a new field within the "App info" section titled "Navigation icon". Upload the following SVG:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE svg [
<!ENTITY elem "">
]>
<svg onload="alert(document.domain);" height="16" width="16">
&elem;
</svg>
After saving changes the XSS payload will fire on partners.shopify.com. To fire the payload on $shop$.myshopify.com/admin/ you'll need to authorize the application on your shop:
I've created an example malicious application associated with my partner account [email protected] to help demonstrate the issue, you can authorize it by opening the following URL on $your-shop$.myshopify.com:
/admin/oauth/authorize?client_id=672a937d5eb24e10c756ea256c73bb8c&scope=read_products&redirect_uri=https://attackerdoma.in/93ba4bef-cff1-43b1-922d-0631bd387e2e.html&state=nonce
Immediately after authorizing the application (and all future admin panel loads) an alert should appear on the /admin window containing document.domain.
Exploitability
This seems like a really odd issue, so it may good to see if there are other places this icon could surface (ex. the app store or internal admin panels) to full understand the impact. For the known exploitable use-case via OAuth authorization you do need to convince an administrator to authorize your malicious application, however the exploit does not require any specific permissions to trigger so an admin may be more willing to authorize the application. Once the administrator has loaded the application it will immediately fire without additional user-interaction.
Remediation
The application should not allow XML entities in uploaded SVGs (or at least fix the parsing so it handles them correctly).
Context
Shopify lets developers build a special class of application called a Sales Channel. A sales channel application can be given a 16x16 SVG "Navigation Icon", which is displayed in the Shopify surfaces where the app appears. The icon is not accepted blindly: it must follow the design guidelines, which restrict the allowed SVG elements and attributes. That restriction is the security control the report is about.
The researcher found that the whitelist could be bypassed, and that the bypass gave stored cross-site scripting on two surfaces: partners.shopify.com and the admin panel of any shop that had authorised the sales channel, at $shop$.myshopify.com/admin/.
Setup
To reproduce, you need a Shopify Partners account, because the malicious application is created and configured from the Partners dashboard. The researcher created an example application associated with the partner account [redacted] to demonstrate the issue. No other tooling is described.
Finding it
The starting observation is that the SVG navigation icon is validated against a whitelist of elements and attributes, but that this whitelist stops being enforced when the SVG contains an XML entity. With the whitelist out of the way, a developer can include attributes that the guidelines would otherwise reject, such as onload. The researcher describes this as an odd issue and suggests checking whether the same icon surfaces elsewhere, for example the app store or internal admin panels, to understand the full impact.
Exploitation
Step 1: create the application and convert it to a sales channel
Create a new application within the Partners dashboard, then navigate to "Extensions" -> "Sales channel" to convert the application. Saving those changes adds a new field within the "App info" section titled "Navigation icon".
Step 2: upload the malicious SVG as the navigation icon
The following SVG is uploaded in the "Navigation icon" field:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE svg [
<!ENTITY elem "">
]>
<svg onload="alert(document.domain);" height="16" width="16">
&elem;
</svg>
The document declares a DOCTYPE with an internal entity elem whose value is the empty string, and references it as &elem; inside the svg element. The svg element carries an onload attribute that runs alert(document.domain);. The entity is what causes the whitelist to be skipped, so the onload attribute survives validation.
Step 3: the payload fires on partners.shopify.com
After saving the changes, the XSS payload fires on partners.shopify.com.
Step 4: authorise the application on a shop
To fire the payload on $shop$.myshopify.com/admin/, the application has to be authorised on the shop. The researcher's example malicious application can be authorised by opening the following URL on $your-shop$.myshopify.com:
/admin/oauth/authorize?client_id=[redacted]&scope=read_products&redirect_uri=https://attackerdoma.in/93ba4bef-cff1-43b1-922d-0631bd387e2e.html&state=nonce
The URL points at the OAuth authorisation endpoint on the shop's admin host. It names the application by client_id, requests the read_products scope, sets a redirect_uri on an attacker-controlled domain and passes a state value. The exploit does not require any specific permissions to trigger.
Step 5: the payload fires in the admin panel
Immediately after authorising the application, and on all future admin panel loads, an alert appears on the /admin window containing document.domain. No further user interaction is needed once the administrator has loaded the application.
Root cause
The navigation icon is validated against a whitelist of allowed SVG elements and attributes, but that whitelist is not applied when the SVG contains an XML entity. The whitelist is not applied when the SVG contains an XML entity, so attributes such as onload are accepted. The report frames the fix as either rejecting XML entities in uploaded SVGs or correcting the parsing so entities are handled properly. The exact implementation mistake is not shown in the report; the behaviour is described from the outside.
Impact
A developer can obtain stored XSS on partners.shopify.com and on the admin panel of any shop that has authorised the sales channel. For the admin panel case, the attacker must convince an administrator to authorise the malicious application. Because the exploit needs no specific permissions, an administrator may be more willing to authorise it, and once the application has been loaded the payload fires immediately without additional user interaction. The report also notes that other places where the icon could surface, such as the app store or internal admin panels, were worth checking to fully understand the impact.
Fix
The report's remediation is that the application should not allow XML entities in uploaded SVGs, or at least should fix the parsing so it handles them correctly. The report does not state which change was made.
Variants to test
- Upload an SVG whose DOCTYPE declares an internal entity and reference it inside the root element, with an event handler attribute on the root. A positive result is that the icon is accepted and the handler runs when the icon is rendered.
- Try the same entity trick with other attributes the guidelines reject, not just
onload. A positive result is any rejected attribute surviving validation once an entity is present. - Check every surface where the uploaded icon is rendered, including the app store and internal admin panels as the report suggests. A positive result is the payload firing on a surface beyond the two named in the report.
- Test other upload fields that are validated by a whitelist and parsed as XML. A positive result is the same divergence between the validating parser and the rendering parser.
Hunting notes
This kind of bug hides in features that accept user-supplied markup and validate it with a whitelist before storing or rendering it: icons, avatars, logos, theme assets and any XML or SVG upload. The signal during recon is a documented design guideline or checklist that enumerates allowed elements and attributes, which tells you a filter exists and is worth probing. The report's own method is to look for parser features, here XML entities, that change how the document is interpreted between validation and rendering. Impact was shown by demonstrating the payload on two distinct origins, the Partners dashboard and a shop admin panel, with an exploit that needs no specific permissions.
Difficulty: intermediate. The payload is small, but finding it requires understanding how XML entity handling can diverge from a whitelist validator and then chaining the stored icon into an OAuth authorisation flow.
What happened, in plain words
Shopify is a platform that lets people run online shops. Around it, developers build extra applications that plug into those shops. One special kind of application is called a Sales Channel: it is an app that can add a new place where a shop's products can be sold or listed.
When a developer creates a Sales Channel app, Shopify lets them upload a small picture, a 16 by 16 pixel icon, that represents the app. This is called the "Navigation Icon". Because a tiny picture is still a file that a browser has to read, Shopify does not accept any file at all. It checks the file against a list of allowed ingredients, called a whitelist, and rejects anything that is not on the list. The list is published as design guidelines.
The researcher found that this check can be fooled. If the icon file contains a particular XML feature called an entity, the whitelist is simply not applied. That means a developer can sneak in an ingredient the guidelines would normally reject, in this case an onload attribute, which is a small instruction that tells the browser to run some code as soon as the picture loads.
The result is a stored cross-site scripting vulnerability, usually shortened to XSS. "Stored" means the malicious file is saved on Shopify's servers and served to every visitor afterwards, rather than being a one-off trick in a single link. The code then runs inside two places: the Partners dashboard at partners.shopify.com, and the admin panel of any shop that has installed the app, at $shop$.myshopify.com/admin/.
Background you need first
Before walking through the steps, here are the ideas the report relies on, explained from scratch.
What an application (app) is here
An app is a piece of software built by a third party that connects to Shopify. A shop owner chooses to install it, and after that the app can appear inside the shop's admin panel and do things on the shop's behalf. Think of it like a browser extension: it is not part of the browser, but once you install it, it shows up in the browser's interface and can act for you.
What a Sales Channel is
A Sales Channel is a specific type of Shopify app. Its job is to represent a place where products can be sold, for example a marketplace or a social platform. A Sales Channel app can be given a small 16 by 16 SVG icon called the Navigation Icon.
What an SVG is
SVG stands for Scalable Vector Graphics. It is a way of describing a picture using text rather than pixels. A simple SVG file is just a text document that says "draw a shape here, with this colour". Because it is text, a browser has to read and interpret it, and that interpretation is where trouble can hide.
What XML and an entity are
XML is a text format for structured documents, built from tags in angle brackets, like <svg>. An entity is a named placeholder inside an XML document. You declare it once, giving it a value, and then you can write its name anywhere in the document to have that value inserted. It is like a find-and-replace shortcut: you define &company; to mean "Example Ltd" and then write &company; wherever you want the full name to appear.
What a whitelist is
A whitelist (also called an allowlist) is a list of things that are permitted. Anything not on the list is refused. A bouncer with a guest list works the same way: if your name is not on it, you do not get in. Shopify uses a whitelist to decide which SVG elements and attributes are acceptable in a navigation icon.
What an attribute is
In a tag like <svg onload="...">, the word onload is an attribute. Attributes are extra pieces of information attached to an element. Some attributes are harmless, like height and width, which set the size. Others are instructions to the browser, and those are the dangerous ones.
What onload does
onload is an event handler attribute. It tells the browser: when this element finishes loading, run the code written inside the quotes. It is a legitimate feature used for ordinary things, but if an attacker can put their own code there, the browser will run it as if the site itself had written it.
What cross-site scripting (XSS) is
XSS is a class of vulnerability where an attacker manages to get their own code running inside a page belonging to someone else's website. The browser cannot tell the difference between code the site meant to run and code that was smuggled in, so it trusts both. The consequence is that the attacker's code runs with the same privileges as the site: it can read what the page can read and act as the logged-in user.
What document.domain is
document.domain is a property a browser exposes to code running on a page. It holds the domain name of the page, for example partners.shopify.com. Showing it in an alert is a common, harmless way to prove that code is really running on the target site: if the alert appears while you are on Shopify's page, the code is executing there.
What OAuth authorisation is
OAuth is a standard way for one website to ask a user for permission to access something on another website, without handing over the password. When you click "Log in with..." or "Allow this app to access your account", that is usually OAuth. The user is shown a consent screen, and if they agree, the app receives a token, a short string that acts like a temporary key proving the permission was granted.
What client_id, scope, redirect_uri and state mean
These are the parts of an OAuth authorisation request:
client_ididentifies which application is asking for permission.scopesays what the application wants to be allowed to do. A smaller scope means fewer permissions.redirect_uriis where the user is sent after they approve.stateis a value the requesting application supplies and gets back, used to keep track of the request.
What the Partners dashboard is
partners.shopify.com is the website where developers manage the apps they build for Shopify. It is a separate site from any individual shop, and it is where the malicious app in this report was created.
Setting up
To follow the reproduction you need a Shopify Partners account, because the malicious application is created and configured from the Partners dashboard. No other tools are described.
Finding the problem
The starting point is the observation that the navigation icon is checked against a whitelist of allowed SVG elements and attributes, but that this whitelist stops being enforced when the SVG contains an XML entity. With the whitelist out of the way, a developer can include attributes the guidelines would otherwise reject, such as onload.
The researcher calls this an odd issue and suggests checking whether the same icon appears anywhere else, for example in the app store or in internal admin panels, to understand the full impact.
Reproducing it step by step
Step 1: create the application and turn it into a sales channel
Create a new application in the Partners dashboard, then go to "Extensions" and then "Sales channel" to convert the application. Saving those changes adds a new field in the "App info" section called "Navigation icon".
Why this step: saving the conversion adds the Navigation icon field in the App info section.
Step 2: upload the malicious SVG as the navigation icon
The following SVG is uploaded in the "Navigation icon" field:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE svg [
<!ENTITY elem "">
]>
<svg onload="alert(document.domain);" height="16" width="16">
&elem;
</svg>
Line by line:
<?xml version="1.0" encoding="ISO-8859-1"?>is the XML declaration. It says this is an XML document, version 1.0, and that the text is encoded in ISO-8859-1. It is the standard opening line of an XML file.<!DOCTYPE svg [opens a document type declaration for ansvgdocument and starts an internal block of definitions.<!ENTITY elem "">declares an entity namedelemwhose value is the empty string. In other words, it defines a shortcut that expands to nothing at all.]>closes the internal block.<svg onload="alert(document.domain);" height="16" width="16">opens the actual picture. It sets the height and width to 16 pixels each, and it carries theonloadattribute, which tells the browser to runalert(document.domain);when the picture loads. That code pops up a box showing the page's domain name.&elem;uses the entity declared above. Because its value is empty, it inserts nothing visible.</svg>closes the picture element.
The entity is the trick. Its presence is what causes the whitelist to be skipped, so the onload attribute survives validation even though the guidelines would normally reject it.
Step 3: the payload fires on partners.shopify.com
After saving the changes, the XSS payload fires on partners.shopify.com.
Why this matters: the smuggled code runs on Shopify's developer site, partners.shopify.com. The alert proves the code is executing in that page's context.
Step 4: authorise the application on a shop
To make the payload fire on $shop$.myshopify.com/admin/, the application has to be authorised on the shop. The researcher's example malicious application can be authorised by opening the following URL on $your-shop$.myshopify.com:
/admin/oauth/authorize?client_id=[redacted]&scope=read_products&redirect_uri=https://attackerdoma.in/93ba4bef-cff1-43b1-922d-0631bd387e2e.html&state=nonce
What each part does:
/admin/oauth/authorizeis the standard OAuth authorisation endpoint on the shop's admin host. It is the page that shows the consent screen.client_id=[redacted]names the application that is asking for permission. This is the identifier of the researcher's example app.scope=read_productsrequests permission to read product information. This is deliberately minimal: the exploit does not need any specific permissions to trigger.redirect_uri=https://attackerdoma.in/93ba4bef-cff1-43b1-922d-0631bd387e2e.htmlis where the user is sent after approving. It points at a domain controlled by the attacker.state=nonceis a value the requesting application supplies and gets back, used to keep track of the request.
Why this step: the payload fires in the admin panel only after the application has been authorised on the shop.
Step 5: the payload fires in the admin panel
Immediately after authorising the application, and on every future load of the admin panel, an alert appears in the /admin window showing document.domain. No further interaction is needed once the administrator has loaded the application.
Why this matters: the code is now stored and runs automatically. The administrator does not have to click anything else; simply visiting the admin panel is enough.
Why it works
The navigation icon is checked against a whitelist of allowed SVG elements and attributes, but that whitelist is not applied when the SVG contains an XML entity. The whitelist is not applied when the SVG contains an XML entity, so attributes such as onload are accepted. The report frames the fix as either rejecting XML entities in uploaded SVGs or correcting the parsing so entities are handled properly. The exact implementation mistake is not shown in the report; the behaviour is described from the outside.
A useful comparison: imagine a security guard who checks every bag at the door against a list of banned items. If someone hands over a bag with a special compartment, the guard does not open that compartment, so whatever is inside gets through unchecked. The entity is that special compartment.
What an attacker could do with it
A developer can obtain stored XSS on partners.shopify.com and on the admin panel of any shop that has authorised the sales channel. For the admin panel case, the attacker must convince an administrator to authorise the malicious application. Because the exploit needs no specific permissions, an administrator may be more willing to authorise it, and once the application has been loaded the payload fires immediately without additional user interaction.
The report also notes that other places where the icon could surface, such as the app store or internal admin panels, were worth checking to fully understand the impact.
The fix
The report's remediation is that the application should not allow XML entities in uploaded SVGs, or at least should fix the parsing so it handles them correctly. The report does not state which change was made.
Other things worth testing
- Upload an SVG whose DOCTYPE declares an internal entity and reference it inside the root element, with an event handler attribute on the root. A positive result is that the icon is accepted and the handler runs when the icon is rendered.
- Try the same entity trick with other attributes the guidelines reject, not just
onload. A positive result is any rejected attribute surviving validation once an entity is present. - Check every surface where the uploaded icon is rendered, including the app store and internal admin panels as the report suggests. A positive result is the payload firing on a surface beyond the two named in the report.
- Test other upload fields that are validated by a whitelist and parsed as XML. A positive result is the same divergence between the validating parser and the rendering parser.
How to look for this kind of bug
This kind of bug hides in features that accept user-supplied markup and validate it with a whitelist before storing or rendering it: icons, avatars, logos, theme assets and any XML or SVG upload. The signal during recon is a documented design guideline or checklist that enumerates allowed elements and attributes, which tells you a filter exists and is worth probing. The report's own method is to look for parser features, here XML entities, that change how the document is interpreted between validation and rendering. Impact was shown by demonstrating the payload on two distinct origins, the Partners dashboard and a shop admin panel, with an exploit that needs no specific permissions.
Difficulty: intermediate. The payload is small, but finding it requires understanding how XML entity handling can diverge from a whitelist validator and then chaining the stored icon into an OAuth authorisation flow.
Glossary
- API: a defined way for one piece of software to talk to another, like a menu of requests a service will accept.
- Attribute: extra information attached to an element in a markup document, written inside the opening tag, such as
heightoronload. - Authorisation (OAuth): the process where a user grants an application permission to access their account on another service, usually through a consent screen.
- Client ID: the identifier an application uses to tell a service which app is making a request.
- Cross-site scripting (XSS): a vulnerability where an attacker gets their own code to run inside another website's page, with that site's privileges.
- DOCTYPE: a declaration at the top of an XML document that describes the document type and can contain internal definitions.
- Document.domain: a browser property holding the domain name of the current page.
- Entity (XML): a named placeholder declared in an XML document that is replaced by its value wherever it is referenced.
- Event handler: an attribute that tells the browser to run code when something happens, such as an element loading.
- ISO-8859-1: a character encoding, a rule for how text characters are stored as bytes.
- Navigation Icon: the small 16 by 16 pixel picture a Sales Channel app uses to represent itself in Shopify's interface.
- OAuth: a standard protocol for granting an application limited access to an account without sharing the password.
- onload: an event handler attribute that runs code when an element finishes loading.
- Partners dashboard: the website at
partners.shopify.comwhere developers manage the apps they build for Shopify. - Payload: the piece of code an attacker wants to get executed.
- Redirect URI: the address a user is sent to after approving an OAuth request.
- Sales Channel: a type of Shopify app that represents a place where a shop's products can be sold.
- Scope: in OAuth, the set of permissions an application is requesting.
- State: a value an application supplies in an OAuth request and gets back afterwards, used to track the request.
- Stored XSS: XSS where the malicious content is saved on the server and served to visitors later, rather than being carried in a single link.
- SVG: a text-based format for describing pictures using shapes and coordinates rather than pixels.
- Token: a short string that acts like a temporary key, proving a permission was granted.
- Whitelist (allowlist): a list of things that are permitted, where anything not on the list is refused.
- XML: a text format for structured documents built from tags in angle brackets.