Skip to content
Open redirect Disclosed report Beginner

Gitlab.com wrong process with the directory that has "#"

GitLab.com did not URL-encode the '#' character in directory names when generating links, so a directory named with a '#' would link to a truncated path. An attacker could create a fake directory to trick a contributor into editing a file in the wrong location.

GitLab

Originally disclosed on GitLab

  • Fixed in 21 hours
  • Disclosed after 21 hours

HackerOne report #789394 by cccaaasser on 2020-02-05, assigned to @dcouture:

Summary

Gitlab.com misunderstand about # symbol. If anyone create a directory with #, it will not process any character behide it. With this issue attacker can create a fake directory to trick other contributor to edit file with misunderstanding.

Steps to reproduce

  1. Create a new project
2020-02-05-22-15-44.png
2020-02-05-22-15-44.png From the original on GitLab
2020-02-05-22-16-23.png
2020-02-05-22-16-23.png
  1. Create a new file and directory. In this case we the directory named FirstDirectory
2020-02-05-22-16-59.png
2020-02-05-22-16-59.png From the original on GitLab
2020-02-05-22-19-36.png
2020-02-05-22-19-36.png
2020-02-05-22-22-20.png
2020-02-05-22-22-20.png
  1. Back to root path and create a new directory with the name same as previous but add `# behind
2020-02-05-22-24-34.png
2020-02-05-22-24-34.png From the original on GitLab
2020-02-05-22-27-25.png
2020-02-05-22-27-25.png
  1. Back to root path
2020-02-05-22-27-56.png
2020-02-05-22-27-56.png From the original on GitLab
  1. Check the file in FirstDirectory you will see it has only test.md
2020-02-05-22-32-26.png
2020-02-05-22-32-26.png From the original on GitLab
  1. Now access to FirstDirectory# by click on root path
2020-02-05-22-34-41.png
2020-02-05-22-34-41.png From the original on GitLab
  1. You will see it redirected to FirstDirectory
2020-02-05-22-36-38.png
2020-02-05-22-36-38.png From the original on GitLab

Examples

You can see the example at: https://gitlab.com/cccaaasser/test-sharp

What is the current bug behavior?

Click FirstDirectoty# directory and it browse to https://gitlab.com/cccaaasser/test-sharp/-/tree/master/FirstDirectory#

What is the expected correct behavior?

Click FirstDirectoty# directory it must browse to https://gitlab.com/cccaaasser/test-sharp/-/tree/master/FirstDirectory%23

Output of checks

This bug happens on Gitlab create project

Tested On

Google Chrome Version 80.0.3987.87

Note: this bug may out-of-scope, but this issue can trick any user on internet by redirected to other directory

Impact

Attacker can create fake directory to redirected other contributor to edit file with misunderstanding.

Attachments

Warning: Attachments received through HackerOne, please exercise caution!

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 application did not URL-encode the '#' character when constructing links to directories, causing the browser to interpret it as a fragment identifier.

Impact

An attacker could create a fake directory to redirect other contributors to edit a file with misunderstanding.

What the attacker needed

Ability to create projects and directories

The fix

The application should URL-encode the '#' character as %23 when generating links to directories.

How it was found

  1. Create a new project.
  2. Create a new file and a directory named FirstDirectory.
  3. Back at the root path, create a new directory with the same name but add '#' behind it.
  4. Back at the root path, check the file in FirstDirectory and see it has only test.md.
  5. Access FirstDirectory# by clicking on the root path.
  6. Observe that it redirects to FirstDirectory.

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.

GitLab did not encode '#' in directory links, so clicking a link to a directory with '#' took users to a different directory.

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.