Skip to content
Access control Disclosed report Beginner

Guests can disclose project templates using the REST API

Guests in a private project could access project templates (such as merge request templates) through the REST API, even though they are not allowed to read the project's code. This allowed them to disclose the content of those templates.

GitLab

Originally disclosed on GitLab

  • Fixed in 5 months
  • Disclosed after 5 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 #2501461 by js_noob on 2024-05-11, assigned to @ottilia_westerlund:

Report | Attachments | How To Reproduce

Report

Summary

Hello team, project members can create templates in that project for easier accessibility, these templates are just code saved in "special" file paths in the project, i.e. they are part of the source code of a project. On the other hand, guests aren't allowed to read the code of a private project, so they shouldn't be able to access project templates. However, this is false, as guests can disclose all project templates using the REST API.

I understand that guests might still need access to issues templates, as guests are allowed to create issues, but they shouldn't have access to other types of templates, for example, merge request templates.

Steps to reproduce

As an owner:

  1. Create a new group and apply the ultimate trial to it
  2. Create a new private project in that group
  3. Create a new file having the path .gitlab/merge_request_templates/mytemplate.md, and any content in that file
  4. Invite a guest to the group

As the guest:

  1. Verify that you can't access the templates/code
  2. Send the following API calls:
curl --header "PRIVATE-TOKEN: PAT" "https://gitlab.com/api/v4/projects/PROJECT_ID/templates/merge_requests"  
curl --header "PRIVATE-TOKEN: PAT" "https://gitlab.com/api/v4/projects/PROJECT_ID/templates/merge_requests/TEMPLATE_NAME"  
  1. Verify the disclosure of the content of the template
What is the current bug behavior?

Guests can access project templates through REST API.

What is the expected correct behavior?

Guests shouldn't be able to access project templates through REST API.

Output of checks

This bug happens on GitLab.com

Impact

Disclosure of project template to unauthorized users (guests).

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

Root cause

Likely the API endpoint for project templates did not check whether the user had permission to read the repository, only whether they were a project member.

Impact

A guest could read the content of project templates, which are part of the source code, leading to information disclosure to unauthorised users.

What the attacker needed

A private project; a guest member in the project; a personal access token for the guest

How it was found

  1. As an owner, create a new group and apply the ultimate trial to it.
  2. Create a new private project in that group.
  3. Create a file at the path .gitlab/merge_request_templates/mytemplate.md with any content.
  4. Invite a guest to the group.
  5. As the guest, verify that you cannot access the templates or code.
  6. Send API requests to the project templates endpoints and observe the disclosure of the template content.

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.

In GitLab, a guest is a user with limited permissions who normally cannot see the source code of a private project. Templates are files stored in the project that help create issues or merge requests, and they are part of the code. The bug meant that a guest could still download these template files using the API, even though they should not have been able to see any 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.