Disabled Repository functionality - Still Able To Access The Project Files and Container Registry via Deploy Token
When a project's repository functionality was disabled, deploy tokens could still clone the repository and access the container registry, contrary to the documentation. An attacker holding a deploy token could therefore read project files and images even after the owner disabled the repository as a defence.
GitLab
Originally disclosed on GitLab
- Fixed in 3 months
- Disclosed after 3 months
HackerOne report #884174 by vaib25vicky on 2020-05-28, assigned to @vdesousa:
Security Issue https://gitlab.com/gitlab-org/security/gitlab/-/issues/228
Description
The doc https://docs.gitlab.com/ee/user/project/settings/#sharing-and-permissions states that
If you disable Repository functionality, GitLab also disables the following features for your project:
Merge Requests
Pipelines
Container Registry
Git Large File Storage
Packages
After disabling the repository functionality, none including owner of the project is allowed to git clone and access the repository files.
But this is not the case with the deploy tokens, it allows you to download (git clone) or push and pull packages and container registry images of a project without having a user and a password. So, one with deploy tokens of the project is able to access project files and container registry.
Assuming of a situation where owner project token got stole or he lost it, and owner decided to disable repository functionality instead of revoking token, then this can be problematic. And owner can decide disabling repository first as a defense against lost token because Gitlab doc states that it disable project files as well as container registry.
Steps to reproduce
As a quick PoC, I am going to use my public project whose repository functionality is disabled
[REDACTED]
- Going over above link, you can see repos is disabled.
- Use the below api with project deploy token
git clone https://[REDACTED]
- You will see one file into
lamefolder namedhackerone
Impact
Assuming of a situation where owner project token got stole or he lost it, and owner decided to disable repository functionality instead of revoking token, then this can be problematic. And owner can decide disabling repository first as a defense against lost token because Gitlab doc states that it disable project files as well as container registry.
What is the current bug behavior?
Able to clone repository even when owner disabled repository functionality via Deploy token.
What is the expected correct behavior?
If repository functionality is disabled then don't allow deploy tokens to clone repository as well as access container registry.
Output of checks
This bug happens on GitLab.com
Impact
Disabled Repository functionality - Still Able To Access The Project Files and Container Registry via Deploy Token
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 deploy token authentication path did not check whether repository functionality was disabled, so it bypassed the intended restriction.
Impact
If a deploy token is stolen or lost, disabling repository functionality does not prevent the token holder from accessing project files and the container registry, so the owner's intended defence fails.
What the attacker needed
A deploy token for the project; repository functionality disabled
The fix
Deploy tokens should be blocked from cloning the repository and accessing the container registry when repository functionality is disabled.
How it was found
- Visit the public project whose repository functionality is disabled.
- Use the project deploy token to clone the repository via the API.
- Observe that a file from the repository is downloaded.
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 deploy token is a special password for automated tools to access a project without a user account. The project owner turned off the repository feature, expecting all access to stop, but the token still worked. This means someone with the token could still download the code.
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.