Skip to content
Access control Disclosed report Intermediate

Private job artifacts can be accessed by any user

Private job artifacts in a public project could be accessed by anonymous users through the `needs` keyword in another pipeline. An attacker could read confidential variables stored in private artifacts.

GitLab

Originally disclosed on GitLab

  • Fixed in 2 months
  • Disclosed after 2 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 #2456845 by js_noob on 2024-04-09, assigned to GitLab Team:

Report | Attachments | How To Reproduce

Report

Summary

Hello team, a user in a project can set the artifacts of a job to be private so they're not accessible by any unauthorized user, from the docs:

To deny read access to artifacts in public pipelines for anonymous, guest, and reporter users, set artifacts:public to false

This is working as expected in the UI and the API, however, anonymous unauthorized users can still access those private artifacts using the needs keyword, in another pipeline.

NB: The following POC just shows a simple example of a static value, however, artifacts especially the env one usually contain confidential variables/info.

Steps to reproduce

As the victim:

  1. Create a new group and apply the ultimate trial to it
  2. Create a public project in that group
  3. Create a .gitlab-ci.yml file in that project, this job creates an ENV artifact, that's private and isn't accessible by unauthorized
build_vars:  
  stage: build  
  script:  
    - echo "BUILD_VERSION=hello" >> build.env  
  artifacts:  
    reports:  
      dotenv: build.env  
    public: false  
  1. When the pipeline finishes, verify the creation of a new artifact
Screenshot_2024-04-10_at_12.38.24_AM.png
Screenshot_2024-04-10_at_12.38.24_AM.png From the original on GitLab

As the attacker:

  1. Navigate to that project's artifacts page and verify that you can't download the .env artifact
  2. Create a new group, and apply the ultimate trial to it
  3. Create a project in that group, with the following .gitlab-ci.yml file
my_job:    
  script:    
    - echo "$BUILD_VERSION"  
  needs:  
    - project: VICTIM/PROJECT  
      job: build_vars  
      ref: main  
      artifacts: true  
  1. Notice the triggered pipeline, it should contain the value of the BUILD_VERSION variable that's saved in a private artifact
Example
What is the current bug behavior?

Private artifacts are accessible using the needs keyword.

What is the expected correct behavior?

Private artifacts shouldn't be accessible using the needs keyword.

Output of checks

This bug happens on GitLab.com

Impact

Disclosure of private job artifacts to unauthorized users.

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 access control check for private artifacts was not applied when artifacts are fetched via the `needs` keyword from another pipeline.

Impact

Disclosure of private job artifacts to unauthorized users.

What the attacker needed

Victim has a public project with private artifacts; attacker can create a group and project and run pipelines

How it was found

  1. As the victim, create a group and apply the ultimate trial to it.
  2. Create a public project in that group.
  3. Add a `.gitlab-ci.yml` file that creates a private ENV artifact.
  4. Run the pipeline and verify the artifact is created.
  5. As the attacker, navigate to the project's artifacts page and confirm you cannot download the `.env` artifact.
  6. Create a new group and project, and add a `.gitlab-ci.yml` that uses `needs` to fetch the victim's artifact.

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, a job can produce files called artifacts, and you can mark them private so only certain people can see them. The report shows that even if an artifact is private, someone outside the project can still get it by referencing it from a different pipeline using a special keyword. This means private data could leak.

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.