Skip to content
XSS Disclosed report Intermediate

App messaging can be hijacked by third-party websites

The Shopify admin interface's origin check for messages from installed apps incorrectly accepts domains that merely end with the app's domain, such as 'badexample.com' for 'example.com'. An attacker could register such a domain and send messages to the admin interface, allowing them to overlay the admin with a fake login page and potentially abuse privileged app messages.

palant Follow

Originally disclosed on HackerOne

  • Triaged in 2 hours
  • Fixed in 27 hours
  • Paid in 20 hours
  • Disclosed after 3 months

The JavaScript code at https://cdn.shopify.com/s/assets/admin/index-c6e72fa910cd0182ab1d1e67ff823fb2e6ca61745c00797769410ce01aafc4d8.js installs a message event listener to receive messages from installed apps when these apps are displayed in a frame. The following check rejects invalid event origins:

i.origin!==this.applicationOrigin&&!e(this.applicationOriginUri,Shopify.UrlMangler.getURL(i.origin))

Here function e is defined above as follows:

e = function (e,t){
  return e.protocol === t.protocol &&
         e.port===t.port &&
         t.hostname.slice(-e.hostname.length) === e.hostname &&
         "" !== e.hostname;
}

This logic is meant to accept messages from subdomains of the app's domain. It is flawed however: if the app is running from example.com, messages from badexample.com will be accepted as well.

Recommendation: Changing the condition into t.hostname.slice(-e.hostname.length-1) === "." + e.hostname will do the right thing.

To demonstrate this issue, my proof of concept exploits the app Trust Badge - it runs from "https://hektorcommerce.com", so anybody could register a domain name like dehektorcommerce.com and send messages to the admin interface which will then be accepted. This is not a flaw in the app however, any app not running from a subdomain can be exploited in the same way.

Steps to reproduce

  1. Make sure to install Trust Badge app in your shop.
  2. Download the attached ssl_server.py script and exploit_app_comm.html page to the same directory on your computer.
  3. Edit /etc/hosts file (that's %Windir%\Sysnative\drivers\etc\hosts on Windows) and add the following entry: 127.0.0.1 dehektorcommerce.com. The real attackers would register dehektorcommerce.com domain instead.
  4. Start ssl_server.py script (requires Python 3) to run a local SSL-protected web server. On Linux and macOS this script needs to be run with administrator privileges.
  5. Open https://dehektorcommerce.com/exploit_app_comm.html in your browser and accept the invalid certificate (real attacker would actually own dehektorcommerce.com, so they would be able to get a valid certificate for it).
  6. Enter the host name of your shop into the input field and click "Do it!" button.
  7. A new browser tab opens and the admin interface of your shop loads, only to be immediately replaced by a login form. You can enter something into the login form and click "Log in" - the page will respond with the message "Gotcha".

The fake login page is being displayed by sending a Shopify.API.Modal.open message in the name of the Trust Badge app, this allows overlaying the admin interface with an arbitrary web page. I didn't spend any time faking this login page look similar to the real one, but that would be trivial. Unlike with phishing pages, checking the address bar doesn't help - the URL really belongs to the Shopify admin interface.

Impact

This issue allows attacking admins of a specific, e.g. by abusing support channels to send them a malicious link. Social engineering could be used to convince admins to enter their credentials into fake login page - the URL of the page won't tip them off that this page has been manipulated.

Displaying overlays on top of the Shopify admin interface is something that any app can do by itself of course. So it might be a good idea to disallow removing all hints showing that the content displaying there doesn't belong to Shopify (the hideHeader parameter is particularly problematic here).

However, abusing special privileges granted to some apps might be even more problematic. For example, messages like Shopify.API.Cart.discount.add are restricted to apps that received the necessary privilege. I'm not sure how much harm these messages could do, but this vulnerability allows third-party websites to send them.

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

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

The origin validation uses a suffix match on the hostname without ensuring the match occurs at a dot boundary, so a domain like 'badexample.com' passes the check for 'example.com'.

Impact

An attacker could overlay the Shopify admin interface with a fake login page to phish admin credentials, and could also send privileged messages such as adding cart discounts, though the full harm of those messages is uncertain.

What the attacker needed

A Shopify shop with the Trust Badge app installed; attacker registers a look-alike domain; victim clicks a link to the attacker's domain

The fix

The origin check should be changed to require a dot before the app's domain, ensuring only true subdomains are accepted.

How it was found

  1. Install the Trust Badge app in a Shopify shop.
  2. Download the provided server script and exploit page to the same directory.
  3. Add a hosts file entry mapping a look-alike domain to localhost.
  4. Run the local SSL server script.
  5. Open the exploit page in a browser and accept the invalid certificate.
  6. Enter the shop's hostname and click the button to trigger the attack.

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.

When an app is shown inside the Shopify admin, it can send messages to the admin page. The admin checks where the message comes from, but the check is too loose: it only looks at the end of the domain name. So a malicious site with a similar name, like 'badexample.com' instead of 'example.com', can pretend to be the app and send messages. This lets an attacker show a fake login page on top of the real admin page.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by palant

View all

12 more disclosed reports, best first.

More from Shopify

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.