Skip to content
Access control Disclosed report Intermediate

Bypassing tags protection in GitLab

A user without permission to create protected tags could create a tag with a name that includes the refs/tags/ prefix, bypassing the protection rule. The tag then appears as protected, and downloading the source code for that tag may fall back to the content of a branch with the same name, potentially delivering malicious code.

GitLab

Originally disclosed on GitLab

  • Fixed in 54 days
  • Disclosed after 54 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 #1908423 by inspector-ambitious on 2023-03-15, assigned to @ottilia_westerlund:

Report | Attachments | How To Reproduce

Report

Summary

I believe I discovered a bug that allows an attacker to spoof protected tags, that could potentially lead a victim to download malicious code.

Steps to reproduce

We will distinguish 2 users to reproduce this vulnerability:

  • victim01 the victim
  • inspector-ambitious the attacker

In victim context (root): The initial setup

  1. Create a new private repository called tag-protection-bypass
image.png
image.png From the original on GitLab
  1. Invite inspector-ambitious as a member of the project in Project Information > Members
image.png
image.png From the original on GitLab
  1. Go to Settings > Repository, expand the Protected tags and create a new rule

Tag: v*
Allowed to create: Maintainers

image.png
image.png From the original on GitLab
image.png
image.png

So at this stage inspector-ambitious should not be able to create tags since they are protected.

In attacker context (inspector-ambitious): The attack

  1. Create a branch called v1 containing an empty malicious file (for demonstration)
image.png
image.png From the original on GitLab
  1. Click repository Tags links
image.png
image.png From the original on GitLab

(there is no tags created yet)

  1. Click on New Tag

  2. Set the tag name to refs/tags/v1 and the Create from to v1, create the tag

image.png
image.png From the original on GitLab
  1. a 404 appears but the tag is created
image.png
image.png From the original on GitLab
  1. Go back to the repo tags list, the tag now appears as protected !
image.png
image.png From the original on GitLab

Please note that clicking the tag does not work because a 404 is thrown, but the download
Source code feature will still work.

What I believe is happening in the background is that since the tag v1 reference cannot be resolved the download of the source code fallback to the content of the branch v1.

Impact

A victim can end up downloading malicious source code.

Output of checks

This bug happens on GitLab.com

Attachments

Warning: Attachments received through HackerOne, please exercise caution!

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 tag creation logic did not properly normalise or validate the tag name, allowing a user to bypass the protected tag pattern check by including the 'refs/tags/' prefix.

Impact

A victim could download malicious source code if they download the source for the spoofed tag, as the download may fall back to the branch content.

What the attacker needed

Attacker is a project member; protected tag rule exists; victim downloads source of spoofed tag

How it was found

  1. As an admin, create a private repository and invite the attacker as a member.
  2. As an admin, create a protected tag rule for 'v*' allowing only Maintainers to create.
  3. As the attacker, create a branch named 'v1' with a malicious file.
  4. As the attacker, go to the Tags page and click New Tag.
  5. Set the tag name to 'refs/tags/v1' and create from branch 'v1', then submit.
  6. Observe a 404 error but the tag is created and appears as protected.

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, protected tags prevent unauthorised users from creating tags that match certain patterns, like 'v*'. The attacker found that by entering a tag name with 'refs/tags/' in front, they could create a tag that looked protected but wasn't properly checked. This could let them trick someone into downloading harmful code.

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.