Private job artifacts can be accessed by any user
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
tofalse
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:
- Create a new group and apply the ultimate trial to it
- Create a public project in that group
- 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
- When the pipeline finishes, verify the creation of a new artifact
As the attacker:
- Navigate to that project's artifacts page and verify that you can't download the
.env
artifact - Create a new group, and apply the ultimate trial to it
- 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
- Notice the triggered pipeline, it should contain the value of the
BUILD_VERSION
variable that's saved in a private artifact
Example
Screen_Recording_2024-04-10_at_12.48.55_AM.mov
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: