Skip to content
Info disclosure Disclosed report Intermediate

Commits API leaks sensitive commits

The Commits API of a public project returns commits from private merge requests that were fetched into the repository, exposing their SHA. An attacker could use the SHA to view the commit and its changes, which were meant to be protected by the randomness of the SHA.

GitLab

Originally disclosed on GitLab

  • Fixed in 8 days
  • Disclosed after 8 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 #1851858 by shells3c on 2023-01-30, assigned to @ameyadarshan:

Report | How To Reproduce

Report

Summary

Some Gitlab commits are meant to be sensitive and are only protected by the randomness of the SHA, such as commits of confidential merge requests (Merge Requests visibility set to Only Project Members) where commits are fetched from the source repository which can be private or internal, to the target repository which is public, thus makes them available publicly. Therefore, those commits' SHA should not be exposed anywhere to unauthorized users, however, I found that I can find them through the Commits API, as it gives me all commits that were fetched into the repository.

Steps to reproduce
  1. Create a public project, set Merge Requests visibility to Only Project Members, invite your other account to the project.
  2. Using the other account, fork the project, set the fork's visibility to Private.
  3. Make a commit to the fork and create a merge request to the parent fork.
  4. The merge request in this case is expected to be private, even though the commit has been fetched into the target repository and can be accessed publicly (due to project visibility), but the SHA is what protect the change/fix from being exposed.
  5. Visit https://gitlab.com/api/v4/projects/<id>/repository/commits?all=1 and you can find the merge request commit there.
  6. You can now view the commit: https://gitlab.com/<user>/<project>/-/commit/<sha>
Output of checks

This bug happens on GitLab.com

Impact

Access to commits of private merge requests, I also found this blog post and think it should affect repositories using similar development workflows (not https://gitlab.com/gitlab-org/* itself as they ended up implementing a fix by pausing mirroring as soon as security merges, mentioned in the blog post), but yet I haven't been able to reproduce the situation described in the blog post, new git objects from remote aren't fetched into my repository and I don't know why.

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 Commits API does not filter out commits that belong to private merge requests but were fetched into the public repository.

Impact

An attacker could access commits of private merge requests, potentially exposing sensitive changes.

What the attacker needed

A public project with MRs visible to members only; a second account to fork and create MR; the fork must be private

How it was found

  1. Create a public project and set Merge Requests visibility to Only Project Members, then invite a second account.
  2. Using the second account, fork the project and set the fork's visibility to Private.
  3. Make a commit to the fork and create a merge request to the parent project.
  4. Visit the Commits API endpoint with all=1 to list all commits and find the merge request commit.
  5. View the commit using its SHA in the project's commit URL.

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 make a merge request from a private fork to a public project, the commits are copied into the public project's storage. Normally, you can only find them if you know their long random ID (SHA). The Commits API lists all commits in the project, including those copied ones, so anyone can see the private merge request's changes.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.