Skip to content
Access control Disclosed report Intermediate

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
  1. Create a group and a project in the group.
  2. 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"'  
  1. This means that owner-only job will only be triggered if the pipeline trigger is ali_shehab.
  2. Disable overriding variables:
curl -X PUT -H "PRIVATE-TOKEN: TOKEN" "https://gitlab-private.net/api/v4/projects/16?restrict_user_defined_variables=true"  
  1. Now invite user B with a developer role.
  2. Now user B create a schedule pipeline.
  3. 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"  
  1. 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:

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 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

  1. Create a group and a project in the group.
  2. Add a .gitlab-ci.yaml file to the project and lock this file.
  3. Disable overriding variables via the API.
  4. Invite user B with a developer role.
  5. User B creates a schedule pipeline.
  6. 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.

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.