Bypass predefined vars
A developer could bypass the project setting that restricts overriding predefined CI/CD variables by using the REST API to add variables to a pipeline schedule. This allowed the developer to set a predefined variable such as GITLAB_USER_LOGIN, which could cause jobs with rules based on that variable to run.
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 #2125189 by ali_shehab on 2023-08-27, assigned to @rshambhuni:
Report | How To Reproduce
Report
Summary
Hi team. An admin can set that only maintainer and owner can bypass predefined variables. If you put it to true, when a developer tries to override manually he will get an error, however, this is bypassable by rest API
Steps to reproduce
- Create a group and a project in the group.
- Add this .gitlab-ci.yaml file to the project and lock this file.
stages:
- build
- owner-only
build:
stage: build
image: ubuntu
script:
- echo "This is a normal job..."
owner-only:
stage: owner-only
image: ubuntu
script:
- echo "This should only run is the pipeline was triggered by ali_shehab"
rules:
- if: '$GITLAB_USER_LOGIN == "ali_shehab"'
- This means that owner-only job will only be triggered if the pipeline trigger is ali_shehab.
- Disable overriding variables:
curl -X PUT -H "PRIVATE-TOKEN: TOKEN" "https://gitlab-private.net/api/v4/projects/16?restrict_user_defined_variables=true"
- Now invite user B with a developer role.
- Now user B create a schedule pipeline.
- He send this api request to add variables to the schedule pipeline.
curl --request POST --header "PRIVATE-TOKEN: TOKEN" "https://gitlab.com/api/v4/projects/{project}/pipeline_schedules/{pipeline_scheduleus}/variables?key=GITLAB_USER_LOGIN&value=ali_shehab"
- Now he run the schedule and he overrides the prededined vars.
Impact
Able to bypass predefined variables even if only the maintainer and developers are allowed.
How To Reproduce
Please add reproducibility information to this section:
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 API endpoint for adding variables to a pipeline schedule did not enforce the project's restriction on user-defined variables.
Impact
A developer could bypass the restriction on overriding predefined variables, potentially causing jobs with rules based on those variables to run.
What the attacker needed
A GitLab account with developer role; a project with CI/CD and locked .gitlab-ci.yml; the setting to restrict variable override enabled
How it was found
- Create a group and a project in the group.
- Add a .gitlab-ci.yaml file to the project and lock this file.
- Disable overriding variables via the API.
- Invite user B with a developer role.
- User B creates a schedule pipeline.
- User B sends an API request to add variables to the schedule pipeline.
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, projects can be configured so that only maintainers and owners can override predefined variables used in CI/CD pipelines. A developer found that even when this restriction was enabled, they could still add variables to a pipeline schedule through the API, effectively overriding the predefined variables. This could let them trigger jobs that were supposed to run only under specific conditions.
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.