Skip to content
Business logic Disclosed report Intermediate

Bypassing tag check and branch check through imports

GitLab added a check to stop branches or tags being named like a commit SHA, but importing a repository from another Git provider bypasses that check. An attacker could then create a tag whose name matches a commit, potentially substituting different code where a commit reference is trusted.

GitLab

Originally disclosed on GitLab

  • Fixed in 7 months
  • Disclosed after 7 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 #2299337 by aaron_dewes on 2023-12-29, assigned to GitLab Team:

Report | How To Reproduce

Report

NOTE! Thanks for submitting a report! Please note that initial triage is handled by HackerOne staff. They are identified with a HackerOne triage badge and will escalate to the GitLab team any. Please replace all the (parenthesized) sections below with the pertinent details. Remember, the more detail you provide, the easier it is for us to triage and respond quickly, so be sure to take your time filling out the report!

Summary

GitLab recently implemented a check for security purposes that prevents tags or branches to be named with a SHA1 or SHA256 tag name (https://gitlab.com/gitlab-org/gitlab/-/commit/5146cc013520a950b16bdf71e7849970dc0e3e07).

Steps to reproduce
  1. Create a repository with a branch or tag name that is also a commit name (SHA1 or SHA256) and upload it on any external Git provider
  2. Import it to GitLab.
Impact

I am not sure what impacts you estimated with the original bug fix, but it was security related. Some things I can imagine:

Examples

Not sure if necessary, if you need it, please let me know.

What is the current bug behavior?

Branch or tag with the 40-character hex name gets created.

What is the expected correct behavior?

Branch or tag can not be created.

Relevant logs and/or screenshots
Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

Impact

This field is duplicated in the "create report" form for some reason, so please check above.

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 SHA-name validation was only applied when creating refs through GitLab's own interface, not during repository import.

Impact

The reporter suggests this could let an attacker replace a pinned commit with a tag of the same name containing different code, though the impact is described only as speculation.

What the attacker needed

Ability to import a repository; external Git provider account

How it was found

  1. Create a repository on an external Git provider with a branch or tag named like a commit SHA.
  2. Import that repository into GitLab.
  3. Observe that the branch or tag with the SHA-like name is created.

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.

Git lets you label a point in history with a branch or tag name. GitLab tried to stop people naming a branch or tag with the same long code (a SHA) that identifies a commit, because the two could be confused. The reporter found that bringing a repository in from another service skips that check, so the confusing name still gets created.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.