Skip to content
Access control Disclosed report Beginner

Unauthenticated users can access private PyPI packages that belong to a public group using /api/v4/groups/{id}/-/packages/pypi/simple

A private project's PyPI packages could be downloaded by unauthenticated users if the project belonged to a public group, even after the package registry was disabled. An attacker could access and download private packages without any authentication.

GitLab

Originally disclosed on GitLab

  • Fixed in 4 months
  • Disclosed after 4 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 #2035173 by js_noob on 2023-06-22, assigned to @ottilia_westerlund:

Report | Attachments | How To Reproduce

Report

Summary

Hello team, as known when a package registry belongs to a private group it and Package registry is turned off in the project settings, this should block EVERY SINGLE user from accessing this project's package registries. However, if this project belonged to a public group, ANY UNAUTHENTICATED user can access and download those packages.

Steps to reproduce

As an owner:

  1. Create a new public group
  2. Create a private project in that group, with the content in the following zip file
  3. After the project creation change the content of pyproject.toml and add your name and email
image.png
image.png From the original on GitLab
  1. Verify that a pipeline is triggered
  2. Wait a couple of minutes, then navigate to https://gitlab.com/GROUP/PROJECT/-/packages, and verify that a new package is created -- Now you can directly jump to step 9, or if you wanted to add another layer of security you can continue in order. But at this point, no external users should be able to access this package

.png)

  1. Navigate to the project settings https://gitlab.com/GROUP/PROJECT/edit and disable Package registry
image.png
image.png From the original on GitLab
  1. Let's try to fetch the package as the owner, on your PC terminal run (you can create PAT here https://gitlab.com/-/profile/personal_access_tokens)
pip install mypypipackage --index-url https://__token__:[email protected]/api/v4/projects/PROJECT_ID/packages/pypi/simple  
  1. Verify that the owner can't access it. Ideally, if the owner can't no one should be able to, right?

As an unauthenticated user:

  1. Navigate to https://gitlab.com/groups/GROUP/-/packages and verify that there are no packages you have access to
  2. Run the following command in your terminal
pip install mypypipackage --index-url https://__token__:[email protected]/api/v4/groups/GROUP_ID/-/packages/pypi/simple  
  1. Verify that you can access that private package without using an access token, i.e. without being logged in

As a double check:

You can check my private packages at https://gitlab.com/groups/my-nice-group-new-version/-/packages, verify that you can't see any packages.
Run the following command and verify that you can download my private package

pip install mypypipackage --index-url https://__token__:[email protected]/api/v4/groups/68082643/-/packages/pypi/simple  
Video/POC
bandicam_2023-06-22_20-40-23-327.mp4 From the original on GitLab

Impact

Unauthenticated users can access private PyPI packages.

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

Impact

Unauthenticated users can access private PyPI packages.

What the attacker needed

Public group; private project with package registry; package published

How it was found

  1. Create a new public group.
  2. Create a private project in that group with a Python package.
  3. Trigger a pipeline to publish the package.
  4. Disable the package registry in the project settings.
  5. As the owner, try to install the package using the project-level API and verify it fails.
  6. As an unauthenticated user, install the package using the group-level API and verify it succeeds.

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 package registry is a place where software packages are stored. The report shows that even when a project is private and its package registry is turned off, anyone on the internet can still download the packages if the project is inside a public group. This means private code could be exposed.

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.