# Email templates XSS by filterXSS bypass

js-xss filter bypass via parser differential on `<![` tags yields XSS in email template preview, chained with HMAC auto-login and clickjacking to steal API token and take over shop accounts.

- Payout: $1,250
- Severity: high
- Program: Judge.me
- Found by: caue
- Disclosed: 2022-05-25
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/1404804
- Library page: https://bugbountylibrary.com/r/h1%3A1404804
- Tags: area:web domain:web impact:ato impact:data-leak kind:bounty platform:hackerone sev:high tech:nodejs technique:chained technique:parser-differential vuln:account-takeover vuln:auth-bypass vuln:clickjacking vuln:xss

**Target:** Email template preview editor (js-xss sanitizer) on judge.me
**Root cause:** Custom onIgnoreTag in js-xss returns raw tag text for `<![if`/`<![endif]--`/`<!-->` sequences, and js-xss parses `<![` differently than browsers, letting attribute-injection payloads survive sanitization.
**Steps:**
1. Inject payload into HTML email template: `<![endif]-- onerror="<![endif]-->" onload="<img src=1 onerror='alert(1)' />">`
2. Preview template to confirm XSS fires in the sanitized output.
3. Craft HMAC auto-login URL: `https://www.judge.me/shop/emails/<id>/edit?no_iframe=1&shop_domain=<attacker>&platform=woocommerce&hmac=<sig>` where sig = HMAC-SHA256 of `no_iframe=1&platform=woocommerce&shop_domain=<domain>` with attacker's API token.
4. Trigger XSS on `www.judge.me` subdomain so attacker session is isolated from victim iframe.
5. From XSS, load iframe of victim's authenticated page (same-origin) and read `parent.frames[0]` HTML.
6. Bypass `frame-ancestors` CSP by having the XSS itself create the iframes.
7. To get API token: iframe `https://judge.me/settings` (Referer check passes) and clickjack the token-retrieval button.
**How found:** Reviewed the custom onIgnoreTag callback in js-xss config, noticed it whitelists `<![if`/`<![endif]--`/`<!-->` raw, hypothesized a parser differential between js-xss and browser on `<![`-prefixed tags, and tested attribute-injection payloads.
**Exploitation:** Attacker hosts malicious email template, builds HMAC-signed URL that logs victim into attacker's shop account, then XSS on www.judge.me reads same-origin iframes of victim's authenticated pages. CSP frame-ancestors bypassed by spawning iframes from the XSS context. API private token (HMAC key) obtained via clickjacking the settings page button, enabling full shop account takeover; FreshChat token leaked without click for support impersonation.
**Escalation:** Self-XSS escalated to 1-click ATO by chaining HMAC auto-login (forces victim into attacker session), same-origin iframe HTML leak, CSP bypass via XSS-spawned iframes, and clickjacking to exfiltrate the API token.
**Insight:** When a sanitizer has a custom onIgnoreTag/allowlist returning raw text, diff its tokenizer against the browser on edge prefixes like `<![`, `<!-->`, and conditional-comment syntax; then look for HMAC/auto-login URLs in the same app to convert Self-XSS into cross-user XSS.

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

**HMAC-authenticated preview URL forcing victim login**

```
https://www.judge.me/shop/emails/2243518/edit?no_iframe=1&shop_domain=wordpress.caueo.me&platform=woocommerce&hmac=████
```

**PHP HMAC generation for auth bypass**

```
$hmac       = hash_hmac( 'sha256', "no_iframe=1&platform=woocommerce&shop_domain={$domain}", $token, false );
```

