Backend: Pipelines will not have access to protected variables and will likely fail when using tags
A developer could create a tag named like the main branch, causing pipelines on the main branch to lose access to protected CI/CD variables and likely fail. This could also cause a denial of service by blocking owners from deleting the malicious tag.
GitLab
Originally disclosed on GitLab
- Fixed in 3 months
- Disclosed after 3 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 #2055158 by js_noob on 2023-07-07, assigned to GitLab Team:
Report | Attachments | How To Reproduce
Report
Summary
This seems to be a bypass of https://gitlab.com/gitlab-org/gitlab/-/issues/406843
Hello team, a developer can force all pipelines from the main branch to not have access to protected CI/CD variables and will likely force them to fail. This is similar to #1932805, I believe this is a different root cause, as the original is fixed.
Note: I reported this earlier in #1932805 but it was closed as duplicate on the above report, GitLab team mentioned that I re-open that report if the original was fixed and the issue persists, obviously I can't re-open reports so I am reporting it as a new report.
Steps to reproduce
As an owner:
- Create a new project
- Add a protected CI/CD variable
- Add a
.gitlab-ci.ymlwith the following content
image: node:latest
stages:
- build
build-job:
stage: build
script:
- echo $VAR
- Watch the pipeline logs and verify that the variables is printed
- Add a developer to the project
As the developer:
- Clone the project locally
- Delete the
.gitlab-ci.ymlfile - Commit the changes
git add .
git commit -m 'delete ci-cd'
- Grab the hash of the final commit using the following command
git rev-parse HEAD
- Create a tag with the name of
refs/heads/mainpointing to the latest commit
git tag 'refs/heads/main' HASH_FROM_STEP_9
- Push the tags to the remote
git push origin --tags
As the owner:
- Run a new pipeline and verify that the var is not printed
Video/POC
Deleted as video does not work
Impact
Pipelines on main will not have access to protected variables leading them to fail, this will also cause DOS which blocks owners from deleting this malicious tag.
Attachments
Warning: Attachments received through HackerOne, please exercise caution!
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 did not properly distinguish between a branch and a tag with the same name when determining if a pipeline runs on a protected branch.
Impact
Pipelines on main will not have access to protected variables, likely causing them to fail, and this could also cause a denial of service by blocking owners from deleting the malicious tag.
What the attacker needed
Developer role in project; ability to push tags
How it was found
- As owner, create a project and add a protected CI/CD variable.
- Add a .gitlab-ci.yml that echoes the variable and verify it prints in pipeline logs.
- Add a developer to the project.
- As developer, clone the project, delete .gitlab-ci.yml, and commit.
- Create a tag named refs/heads/main pointing to the latest commit and push tags.
- As owner, run a new pipeline and verify the variable is not printed.
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.
A developer could create a tag named like the main branch, after which pipelines on main no longer had the protected variables and likely failed.
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.