Skip to content
Access control Disclosed report Beginner

ESCALATED: Unauthorized access to private repositories via DeployToken

Deploy tokens are bound only to a project, not to the user who created them, so a removed maintainer can still clone the private repository using a token they created earlier. An attacker with a previously created deploy token could retain code access after being removed from the project.

GitLab

Originally disclosed on GitLab

  • Fixed in 13 months
  • Disclosed after 13 months

HackerOne report #686359 by xanbanx on 2019-09-02, assigned to jmatos_bgtvf:

Hi GitLab security team

Summary

I found a quite severe problem in your implementation of deploy tokens. Deploy tokens can have the read_repository scope or read_package scope. For now on, consider theread_repository scope, but keep in mind the vulnerability also applies to the read_package scope.

So deploy tokens can be created per repository. However, as it should, these tokens are only displayed once upon creation to the user who is creating the token. So only the user who created the token actually gets it.

However, this token is only bound to the project. There is no relationship between the token and the user who created it. This means, if the user is removed from the project, he still has access to the repository via the deploy token. Furthermore, there is no log who created the deploy token and who used the deploy token at what time. So although the user was removed from the project he still can get all code updates from the repo.

Steps to reproduce

This was tested on a local installation of GitLab Enterprise Edition 12.3.0-pre gitlab-ce@33da820c3a0b3be6440ef1e9a1308a603d2b8869

  1. Create a private repository and push some code
  2. Add another maintainer to this project, denoted as User_B
  3. Let User_B create a deploy token at http://gitlab.example.com/<namespace>/<project>/-/settings/repository with read_repository scope. Now the new deploy token is presented only once to User_B. He is the only person, which is in possession of token
  4. Remove User_B from the project.
  5. Let User_b to perform a git clone http://<deploy-token-user>:<deploy-token>@gitlab.example.com/<namespace>/<project>.git operation using the previously created deploy token

Now, User_b has again access to the code, although he was removed from the project.

Impact

Unauthorized users can gain code access to a private project. Actually, this situation is actually quite common. Let's consider an IT admin, who is responsible for the CI setup. He is maintainer of the project and thus adds a deploy token, which only he is in possession of (because it was presented only to him). Now, this person gets offboarded and thus gets removed from the project. However, because he still has the deploy token he still can access the code.

What is the current bug behavior?

Removed users still have code access to the repository via deploy tokens.

What is the expected correct behavior?

Deploy tokens must have an owner. As soon as the owner of the deploy token is removed from the project, the deploy token is revoked, thus also disables the code access to the project for the person who received the token.

Relevant logs and/or screenshots

Output of checks

This bug happens on GitLab.com

Best,
Xanbanx

Impact

See above.

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 deploy tokens have no owner relationship, so removing a user from a project does not revoke tokens that user created.

Impact

A removed user could still read and clone private repository code using a deploy token they created, and the report notes this also applies to the read_package scope.

What the attacker needed

A private repository; maintainer access to create a deploy token; the token is kept after removal

The fix

Deploy tokens should have an owner and be revoked when that owner is removed from the project.

How it was found

  1. Create a private repository and push code.
  2. Add another maintainer to the project.
  3. Have that maintainer create a deploy token with read_repository scope.
  4. Remove that maintainer from the project.
  5. Use the previously created deploy token to clone the repository.

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 password-like string that lets automated tools read a repository. The report says the token is tied to the project, not to the person who made it, so removing that person from the project does not cancel the token. That person can keep downloading the private 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.

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.