Skip to content
Access control Disclosed report Beginner

User can add project to job token scope allowlist without having any role in allowed project via POST /api/v4/projects/{id}/job_token_scope/allowlist

The job token scope allowlist endpoint did not check whether the requesting user had at least the Guest role in the target project. A user with Maintainer rights on their own project could add any public project to the allowlist, contrary to the documented prerequisite.

GitLab

Originally disclosed on GitLab

  • Fixed in 3 days
  • Disclosed after 3 days

⚠️ 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 #2076075 by ricardobrito on 2023-07-19, assigned to @cmaxim:

Report | How To Reproduce

Report

Hi team,

with the release of Gitlab 16.1, it is now possible to manage the CI-CD job token scope using the REST API. According to the documentation:

You can add projects to the allowlist for a project. Projects added to the allowlist can make API calls from running pipelines by using the CI/CD job token. Prerequisite:

  • You must have at least the Maintainer role in the current project and at least the Guest role in the allowed project.

I have found that the endpoint http://YOUR-GITLAB-INSTANCE/v4/projects/:id/job_token_scope/allowlist does not validate whether the user making the request has at least guest role in the allowed project. If this is the expected behavior then there should be a DOCUMENTATION UPDATE (THIS IS IN SCOPE HACKERONE TRIAGER) that specifies that if the allowed project is inside a public group, the user making the request does not need to have at least guest role in the allowed project. If this is not the expected behavior there should be some permission enforcement in the endpoint.

Steps to reproduce

(Step-by-step guide to reproduce the issue, including:)

  1. Create Project A with user A, make it public/private (doesn't matter) - keep track of the project-id
  2. Create Group B with user B and create project B inside Group B with user B (both project and group are public).
  3. As user A make the following POST request to the endpoint: http://YOUR-GITLAB-INSTANCE/v4/projects/:id/job_token_scope/allowlist
  • :id is the id of project A.

In the JSON body of the request place the following content:

{"target_project_id":SOME-ID}
where SOME-ID is the id of the project B
4. Send the request and you should get something like this:


{
    "source_project_id": PROJECT-A-ID,  
    "target_project_id": PROJECT-B-ID  
}

Which confirms that the request completed successfully.

Expected Behavior

User A does not have at least guest role in project B, so he should not be allowed to set it as the allowed project, or if this is the expected behavior then there should be a DOCUMENTATION UPDATE.

Impact

A user who does not have at least guest role in the allowed project is capable of setting it as an allowed project using the endpoint http://YOUR-GITLAB-INSTANCE/v4/projects/:id/job_token_scope/allowlist.

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

A user without a Guest role in a public project could add it to their project's job token scope allowlist.

What the attacker needed

Maintainer role on source project; target project is public; no role needed on target project

The fix

The endpoint should enforce the documented Guest role requirement on the target project before adding it to the allowlist.

How it was found

  1. Create Project A with user A and note its id.
  2. Create a public Group B and a public Project B inside it with user B.
  3. As user A, send a POST request to the job token scope allowlist endpoint for Project A with the target project id set to Project B.
  4. Observe the response confirming the target project was added.

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 CI/CD job token lets one project's pipeline call another project's API. GitLab's documentation says you need at least the Guest role in the target project to add it to the allowlist. The endpoint skipped that check, so a user could add a public project they had no role in.

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.