Skip to content
XSS Disclosed report Intermediate

Unfiltered `class` attribute in markdown code

GitLab's markdown renderer allowed unfiltered class attributes on HTML elements, so an attacker could inject arbitrary CSS classes into issue and merge request comments. This could be used to forge page content, hide other users' comments, or trigger pre-existing JavaScript event handlers bound by class name.

chalker Follow

Originally disclosed on HackerOne

Medium 5.4 View original
  • Triaged in under an hour
  • Fixed in 9 days
  • Disclosed after 17 days

This affects merge request/issue comments and probably other parts of the user interface.

I am demonstrating PoCs on GitLab.com itself, as they don't affect anything outside of my test repo, which is private. It could be used to execute some js actions by contructing content that uses the pre-existing attached event handlers (for example, onclick), but I am not sure how far could that go — I have not reviewed that, the mentioned issues are already pretty bad.

This could be used to make some issue/merge request pages inaccessible, to forge page content and potentially forge or hide other users comments in the thread.

PoC 1 — full-size message

Demo: https://gitlab.com/ChALkeR/my-private-test-project/issues/2

HTML
<pre class="zen-backdrop fullscreen sherlock-line-samples-table center">
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
{{media:0}}
<h2>Hello there! Something has gone wrong, we are working on it.</h2>
<h3>In the meantime, play a game with us at <a href="http://example.com/">example.com</a>.</h3>
</pre>

PoC 2 — basic JavaScript

Demo: https://gitlab.com/ChALkeR/my-private-test-project/issues/3

HTML
<pre class="js-details-expand">click me</pre>
<pre class="js-details-content hide">foo</pre>

There is a significant amout of onlick event listeners that are bound using just the classname, so it is possible to do some basic stuff with just classes and might be possible to execute more complex actions.

I have not reviewed all instances in the JS where the classnames are used, that is irrelevant to fixing this issue.

Suggested fix

Both of the following should be applied:

  • Filter class attributes (higher priority).
  • Make sure that user content couldn't be displayed outside of the bounding box, e.g. by applying oveflow:hidden (lower priority).

Attachments

Spectacle.F20349.png
Spectacle.F20349.png From the original on HackerOne

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

The markdown renderer did not filter the class attribute on HTML elements, allowing user-supplied class names to be applied to the page.

Impact

An attacker could forge page content, hide or impersonate other users' comments, make pages inaccessible, and potentially trigger existing JavaScript actions bound to class names, though the full extent was not reviewed.

What the attacker needed

Ability to post a comment on an issue or merge request

The fix

The class attribute should be filtered from user-supplied HTML, and user content should be prevented from displaying outside its bounding box, for example with overflow hidden.

How it was found

  1. Create a comment containing HTML with a pre element and a class attribute.
  2. Submit the comment on an issue or merge request.
  3. Observe that the class is applied and changes the page appearance or behaviour.

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 you write a comment on GitLab, you can use simple formatting like bold or code blocks. The system converts that into HTML, the language web pages are made of. The bug is that it let people add a 'class' attribute, which is a label used to style or control parts of the page. By choosing special labels, an attacker could make the page look broken, fake messages, or trigger existing buttons and actions on 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 chalker

View all

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