Skip to content
XSS Disclosed report Intermediate

Stored XSS in blog comments through Shopify API

The Shopify comment API accepted an unsanitised body_html field, letting an app with comment permission inject HTML and JavaScript into a comment, which executed in the Shopify admin panel when viewing comments.

prakharprasad Follow

Originally disclosed on HackerOne

  • Triaged in 32 hours
  • Fixed in 3 months
  • Paid in 3 months
  • Disclosed after 3 months

Summary by the program

Though html content can be set through the API for many locations in the Shopify storefront, this report was a special case. We were also displaying the body_html of these comments in Shopify admin, leading to XSS in admin rather than the storefront.

The report

Hi there!

As far I understand the Shopify Shop have blogs which allow users to comment on blog posts, however the comments with HTML content automatically gets sanitised and then posted to avoid XSS issue. However using the API for comment modification, any application with comment permission can modify a comment and include arbitrary HTML leading to XSS.

Steps to Reproduce

  1. Open the Shopify Shop's blog and post a comment on a blogpost through a browser.
  2. Note the comment id, this can be easily grabbed by checking the HTML after the comment is posted:

Eg. <div id="comment-2929551246" class="comment border-bottom clearfix"> 3. Now setup an application with comment permission on the Shop 4. Send the following JSON to the API endpoint /admin/comments/<comment-id>.json

{ "comment": { "id": <comment-id>, "body": "blahblah", "body_html": "blah<img src=x onerror=alert(0);>" } } 5. Send request twice. 6. Visit the blog post, JS in the comment should execute.

I believe this is a valid bug as the comment should get stripped of HTML, which is not the case in case of the above request, however it does gets stripped when posted via web or modified through the comment API documentation at https://help.shopify.com/api/reference/comment#update. To insert arbitrary HTML I've purposely added body_html in the request, which is not mentioned in the API reference, the allows me to add HTML, in the comment. The HTML even executes in the Shop's Admin Panel when viewing comments for a particular blog.

PoC (see comment section for JS execution): https://derp-10.myshopify.com/blogs/news/43260355-first-post

Video: https://www.dropbox.com/s/7ie1tiex1eo4kk9/Comment%20XSS.mov?dl=0

Thanks, Prakhar Prasad

The original report as published on HackerOne, by prakharprasad. 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

Likely the comment update API did not sanitise the body_html field, unlike the web form and documented API fields.

Impact

An attacker with an app that has comment permission could store JavaScript that executes for anyone viewing the comment, including store administrators in the admin panel.

What the attacker needed

An app with comment permission on the shop; a blog post with comments enabled

How it was found

  1. Post a comment on a blog post through the browser.
  2. Note the comment id from the page HTML.
  3. Set up an application with comment permission on the shop.
  4. Send a JSON request to the comment API endpoint including a body_html field with HTML.
  5. Send the request twice.
  6. Visit the blog post or admin comments view and observe JavaScript execution.

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.

A blog comment normally has its HTML removed so that any JavaScript is harmless. Here, an extra field in an API request let an app sneak HTML back in, and that HTML ran as code when someone viewed the comment. This is called stored XSS because the malicious content is saved and later shown to other users.

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 prakharprasad

View all

17 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.