Skip to content
Access control Disclosed report Intermediate

Private project guests can leak source code using a fork

A guest user of a private project could read source code changes by using the compare API on a fork they had access to, bypassing the guest restriction on reading the repository. The attacker could view new commits made to the private project after the fork.

GitLab

Originally disclosed on GitLab

  • Fixed in 2 months
  • Disclosed after 2 months

HackerOne report #1837937 by shells3c on 2023-01-18, assigned to @fvpotvin:

Report | How To Reproduce

Report

Summary

Guests are not allowed to read the repository of private project, however, if they can have access to any fork of that project, they can read new code changes compared to the fork.

The exploit uses "Compare Git revisions" feature, even though the security checks are performed pretty well in the UI, the API lacks a bit.

Steps to reproduce
  1. As user A, create a private project, create file dummy.txt with the content: original content
  2. Invite user B to the private project as Reporter
  3. As user B, fork the private project
  4. Now user A downgrades user B permission to Guest, which means user B can't read the repository anymore
  5. User A edits dummy.txt content to edited content
  6. User B visits the following URL to see the recent change from user A: https://gitlab.com/api/v4/projects/<FORK ID>/repository/compare?from=main&to=main&straight=true&from_project_id=<PROJECT ID>

Note: It's not necessary that the fork must be yours, it can be anyone's fork as long as you have read_code access. For example, the private project was formally a public project and someone forked it, or a private fork changed the visibility to public, or you request access to a private fork, a lot of scenarios can happen

Output of checks

This bug happens on GitLab.com

Impact

Guests can read the repository of the private project through a fork

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 API endpoint for comparing revisions did not properly check the user's permission on the source project when a fork was involved.

Impact

Guests could read the repository of the private project through a fork.

What the attacker needed

A GitLab account; access to a fork of the private project; guest or higher permission on the private project

How it was found

  1. Create a private project and add a file with some content.
  2. Invite another user as Reporter.
  3. As the Reporter, fork the private project.
  4. Downgrade the Reporter to Guest, removing their ability to read the repository.
  5. Edit the file in the original project.
  6. As the Guest, visit the compare API URL using the fork ID and original project ID to see the change.

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.

In GitLab, a guest is a user with limited permissions who normally cannot see the code of a private project. However, if that guest has access to a copy (fork) of the project, they can use a special comparison feature to see changes made in the original project. This lets them read code they are not supposed to see.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.