Skip to content
Open redirect Disclosed report Beginner

Internal Open Redirection Due to Improper handling of "../" characters

The GitLab refs/switch endpoint did not properly sanitise the 'path' parameter, allowing an attacker to include '../' sequences and manipulate the Location header. This could redirect users to a different project, potentially leading to data theft.

GitLab

Originally disclosed on GitLab

  • Fixed in 6 months
  • Disclosed after 6 months

⚠️ 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 #1889230 by akadrian on 2023-02-28, assigned to GitLab Team:

Report | Attachments | How To Reproduce

Report

Summary

Following endpoint takes multiple parameters as input.
/<namespace>/<project>/-/refs/switch
It was discovered that using at least "ref" and "path" parameters its possible to influence "Location" header value in response in such way that may lead to redirection to other projects.

Steps to reproduce

(Step-by-step guide to reproduce the issue, including:)

  1. Create Victim Project called "victim-project" under "victim" user namespace
  2. Open following URL: http://gitlab.example.com/victim/victim-project/-/refs/switch?ref=main/../&path=../../../../../attackproj
  3. You will notice that project was redirected to http://gitlab.example.com/attackproj
  4. It works on gitlab.com as well
Impact

It can be used to create malicious links to direct other users to other projects. It could lead to data theft for example. Imagine scenario where attacker creates Issue with the link stating that JIRA integration has incorrect password. Link is correct at the first sight yet it is redirecting to other projects.

What is the current bug behavior?

Special characters are not properly sanitized. It is possible to create "../" sequence and influence Location header with custom path leading to internal redirection.

What is the expected correct behavior?

"../" characters should be encoded so that browser would not interpret the sequence as valid pathname.

Impact

It can be used to create malicious links to direct other users to other projects. It could lead to data theft for example. Imagine scenario where attacker creates Issue with the link stating that JIRA integration has incorrect password. Link is correct at the first sight yet it is redirecting to other projects.

Attachments

Warning: Attachments received through HackerOne, please exercise caution!

How To Reproduce

Please add reproducibility information to this section:

Proposal

  1. Disallow ../ in path parameter for /-/refs/switch endpoint. We have utils we can use https://docs.gitlab.com/ee/development/secure_coding_guidelines.html#gitlab-specific-validations
  2. Check that path parameter for other endpoints that uses extract_ref_path https://gitlab.com/gitlab-org/gitlab/-/issues/395437#note_1373513270

Alternatively, we check that the path does not result in path expansion beyond the root directory of the repository.

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 application failed to sanitise the 'path' parameter, allowing directory traversal sequences to alter the redirect target.

Impact

An attacker could create malicious links that redirect users to other projects, potentially leading to data theft.

What the attacker needed

Victim clicks a crafted link

The fix

The 'path' parameter should be validated to disallow '../' sequences, and other endpoints using extract_ref_path should be checked.

How it was found

  1. Create a victim project under a user namespace.
  2. Open a crafted URL with the refs/switch endpoint and parameters containing '../' sequences.
  3. Observe that the response redirects to a different project.

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 click a link, the server can send you to another page using a 'Location' header. This report shows that by putting special characters like '../' in a parameter, an attacker could make the server send you to a different project than the one in the link. That could trick you into visiting a malicious page.

What is Open redirect?

A trusted site forwards users to any address an attacker picks; rarely paid alone, often the missing link in a chain.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Open redirect

The lesson behind this report.

A trusted site forwards users to any address an attacker picks; rarely paid alone, often the missing link in a chain.