# Stored XSS on issue comments and other pages which contain notes

Two sanitizer bypasses in GitLab's Banzai markdown pipeline and gl-emoji frontend let a commenter inject stored XSS against users viewing issues and snippets.

- Payout: $3,000
- Severity: high
- Program: GitLab
- Found by: jarij
- Disclosed: 2022-06-08
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/1398305
- Library page: https://bugbountylibrary.com/r/h1%3A1398305
- Tags: area:web domain:web impact:ato impact:integrity kind:bounty platform:hackerone sev:high tech:ruby technique:chained technique:source-review vuln:xss

**Target:** GitLab issue/snippet comments (Banzai SyntaxHighlightFilter + gl-emoji custom element)
**Root cause:** SyntaxHighlightFilter interpolates unsanitized data-sourcepos/lang attributes into generated HTML, and gl-emoji builds an img tag from an unescaped name attribute, bypassing v-safe-html.
**Steps:**
1. Launch self-managed GitLab 14.4.2-ee
2. Create an issue
3. Post comment payload: `<pre data-sourcepos="&#34; href=&#34;x&#34;></pre>` plus `<gl-emoji data-name='&#34;x=&#34y&#34 onload=&#34;alert(document.location.href)&#34;' data-unicode-version='x'>abc</gl-emoji>` plus `<pre x=&#34;"><code></code></pre>`
4. View the issue; onload fires, executing JS in victim context
**How found:** Code review of Banzai filters: noticed SyntaxHighlightFilter builds HTML via string interpolation of data-sourcepos without escaping, and gl-emoji's emojiImageTag interpolates name into an img tag, bypassing v-safe-html.
**Exploitation:** Any user able to comment posts the crafted markdown; when another user (or admin) views the issue/snippet, the injected attribute breaks out of the generated pre/img tag and executes JS in their session. SaaS blocked only by CSP, not by sanitization.
**Insight:** When a markdown pipeline emits HTML via string interpolation of node attributes, look for attributes (data-sourcepos, lang, name) that survive sanitization and can break out of quoted contexts; also audit custom elements that build innerHTML from attributes since v-safe-html only sanitizes the outer template.

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

**Stored XSS payload for issue comment**

```
<pre data-sourcepos="&#34; href=&#34;x&#34;></pre>
<gl-emoji data-name='&#34;x=&#34y&#34 onload=&#34;alert(document.location.href)&#34;' data-unicode-version='x'>
abc
</gl-emoji>
<pre x=&#34;">
<code></code></pre>
```

