Skip to content
Access control Disclosed report Beginner

Every user can delete public deploy keys

A normal user could delete a public deploy key shared across projects by sending a DELETE request to the project's deploy keys API endpoint. This would stop other users from deploying code using that key.

jobert Follow

Originally disclosed on HackerOne

Medium 6.5 View original
  • Triaged in under an hour
  • Fixed in 22 days
  • Disclosed after 22 days

Vulnerability details

A GitLab instance can have public deploy keys that project admins can use for their project. An attacker can delete these public keys used by other users to deploy code.

Impact

Deleting these shared deploy keys may stop users to deploy their code.

Proof of concept

Make sure the GitLab instance has a public deploy key. Lets assume it has ID 1. Now sign in as a normal user and follow the steps below.

  1. Create a new project called test
  2. Go to http://gitlab-instance/user/test/deploy_keys
  3. Go to the Public deploy keys available to any project section and click the Enable button for the public deploy key
  4. Create an access token for the API for your own account
  5. Request /api/v3/projects, get the ID number for the project test
  6. Request /api/v3/projects/:project_id/deploy_keys, you'll see the public deploy key
  7. Send a DELETE request to `/api/v3/projects/:project_id/deploy_keys/:id - this will delete the public (shared) deploy key, not the relationship between the project and the key. Below is a copy of the request and response.

Request

curl -X DELETE -H "Private-Token: AAAA" http://gitlab-instance/api/v3/projects/1/deploy_keys/1

Response

{"id":1,"user_id":null,"created_at":"<removed>","updated_at":"<removed>","key":"<key>","title":"<title>","fingerprint":"72:bb:e9:cc:04:dc:64:b9:a3:e7:c2:26:8f:f2:ed:df","public":true}

The root cause of this problem lies in the following lines of code:

lib/api/deploy_keys.rb

Ruby
delete ":id/#{path}/:key_id" do
  key = user_project.deploy_keys.find(params[:key_id])
  key.destroy
end

The destroy method will be called on the shared deploy key instead of on the relationship.

Remediation advice

Instead of removing the entire object, remove the relationship instead when it's a public deploy key.

The original report as published on HackerOne, by jobert. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

The API endpoint called destroy on the shared deploy key object itself instead of removing only the link between the project and the key.

Impact

Deleting shared deploy keys could stop users from deploying their code.

What the attacker needed

A normal user account; a public deploy key exists; API access token

The fix

The endpoint should remove only the relationship between the project and a public deploy key, not the key itself.

How it was found

  1. Create a new project called test.
  2. Go to the project's deploy keys page.
  3. Enable the public deploy key for the project.
  4. Create an API access token for your own account.
  5. Find the project ID via the API.
  6. Send a DELETE request to the project's deploy keys endpoint for that key.

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 key lets a project deploy code. Public deploy keys are shared across projects. The bug let any logged-in user delete such a shared key, which could stop others deploying.

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 by jobert

View all

67 more disclosed reports, best first.

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.