Skip to content
XSS Disclosed report Intermediate

XSS on the blob viewer of notebooks

The notebook blob viewer used DOMPurify to sanitise HTML but allowed data-* attributes, which combined with rails-ujs could execute JavaScript when a victim clicked anywhere on the page. An attacker could perform arbitrary actions on behalf of the victim, such as escalating permissions or accessing private objects.

GitLab

Originally disclosed on GitLab

  • Fixed in 6 months
  • Disclosed after 6 months

HackerOne report #1060114 by yvvdwf on 2020-12-16, assigned to @ankelly:

Report | How To Reproduce

Report

Hello,

Gitlab recently uses Dompurify to sanitize data. Dompurify allows data-* attributes by default. When using data-* attributes with the presence of rails-ujs, attackers might trick victims to execute any javascript.

The following attack scenario triggers an alert when you click anywhere on the blob viewer screen of notebooks. Since gitlab allows sending API requests via Javascript in Web browsers, attackers may perform arbitrary actions on behalf of victims, such as, escalate permissions, access to private objects, etc.

Steps to reproduce
  1. In a project, create a file xss.ipynb with the following content (note edited with a known safe payload):
JSON
{
 "cells": [  
  {  
   "cell_type": "markdown",  
   "source": [  
        "<a data-type=script data-remote=true href='https://gitlab.com/ankelly/pipeline_payload/-/jobs/[REDACTED]/artifacts/raw/data/alert.js' style='position:fixed;z-index:9999;top:0;left:0;right:0;bottom:0'></a>CLICK ANYWHERE TO SHOW POPUP"  
   ]  
  }]  
}
  1. When viewing this file, you might notice that there exists a transparent layer that is on the topmost. This layer intercepts any event clicks. Once you click anywhere you should see a popup.
Impact

Once victims click anywhere on the screen of notebook viewer, attackers might execute their javascript. Since gitlab allows sending API requests via Javascript in Web browsers, attackers may perform arbitrary actions on behalf of victims, such as, escalate permissions, access to private objects, etc.

Examples

https://gitlab.com/yvvdwf/notebook/-/blob/master/xss.ipynb

What is the current bug behavior?

data-* attributes are not removed when sanitizing.

What is the expected correct behavior?

data-* attributes should be removed when sanitizing.

Output of checks

This bug happens on GitLab.com

Impact

Once victims click anywhere on the screen of notebook viewer, attackers might execute their javascript. Since gitlab allows sending API requests via Javascript in Web browsers, attackers may perform arbitrary actions on behalf of victims, such as, escalate permissions, access to private objects, etc.

How To Reproduce

Please add reproducibility information to this section:

The original report as published on GitLab. Images and videos are our own copies; raw HTML is shown as text. View it on GitLab.

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

Likely the sanitiser allowed data-* attributes, and the rails-ujs library interpreted data-remote and data-type attributes to fetch and execute JavaScript.

Impact

An attacker could execute JavaScript in the victim's browser and perform arbitrary actions on their behalf, such as escalating permissions or accessing private objects.

What the attacker needed

Victim views a malicious notebook; victim clicks anywhere on the page

The fix

The sanitiser should remove data-* attributes when sanitising notebook output.

How it was found

  1. Create a file named xss.ipynb in a project with a markdown cell containing an anchor element with data-type, data-remote, href, and style attributes.
  2. View the file; a transparent layer covers the page and intercepts clicks.
  3. Click anywhere on the page to trigger the popup.

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.

A notebook file can contain HTML that is cleaned before display. The cleaner left some special attributes that a JavaScript library used to run code. So clicking anywhere on the page could run the attacker's code.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

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.