Skip to content
Access control Disclosed report Beginner

Revoked User can still view the Merge Request created by him via API

muthu_prakash Follow

Originally disclosed on HackerOne

Bounty$1,500 Medium View original
  • Triaged in 12 days
  • Fixed in 6 months
  • Paid in 12 days
  • Disclosed after 7 months

Summary

In Gitlab when a user is demoted to Guest role, the Guest user will not be able to view and edit the Merge requests in a project even if the merge request is created by him. But this check is not implemented in API so the Guest user will be able to the following actions for the Merge request which he don't have a permission.

Allowed Actions in API

  • Able to view the title and Description of the Merge Request via /projects/:id/merge_requests/:merge_request_iid endpoint
  • Get a list of merge request participants via /projects/:id/merge_requests/:merge_request_iid/participants
  • Get a list of merge request commits via /projects/:id/merge_requests/:merge_request_iid/commits
  • Get information about the merge request including its files and changes via /projects/:id/merge_requests/:merge_request_iid/changes
  • Get a list of merge request pipelines via /projects/:id/merge_requests/:merge_request_iid/pipelines
  • Create a TODO for that Merge Request via POST /projects/:id/merge_requests/:merge_request_iid/todo
  • Get a list of merge request diff versions via /projects/:id/merge_requests/:merge_request_iid/versions
  • Get Merge Request approvals status via /projects/:id/merge_requests/:merge_request_iid/approvals

Steps to reproduce

  1. Add a user a to a project with developer role.
  2. From the Added user account create a Merge Request
  3. From Admin account demote to the user to Guest Role
  4. From the Guest user account try to access the Merge request created by that user. (Merge Request tab will not be available for that user)
  5. Now Create an access token from the Guest user account and try to access the Merge Request created by the user by the above mentioned any one of the endpoints (Notice you will be able to view the Merge Request)

Impact

Guest Role users have access to Merge Request data that he's not authorised to view and Edit

What is the current bug behavior?

Guest Roles users have access to Merge Request data that he's not authorised to view and Edit via API

What is the expected correct behavior?

Guest Roles users should be restricted access to Merge Request to view and Edit via API

Output of checks

This bug happens on GitLab.com

Impact

Guest Role users have access to Merge Request data that he's not authorised to view and Edit

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

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

GitLab projects have a role model in which a user can be a Developer, a Guest and so on. A Developer can create merge requests, and a merge request carries a title, a description, commits, diffs, pipelines, approvals and participants. When a user is demoted to the Guest role, the web interface removes the Merge Request tab: the Guest can no longer view or edit merge requests in the project, even the ones that user created. The report is about the same restriction not being enforced by the API.

The researcher's summary is that the check exists in the UI but not in the API, so a Guest can still reach merge request data through API endpoints for a merge request they no longer have permission to see.

Setup

The preconditions are simple and need no special tooling beyond an API client and a personal access token:

  1. A project with at least one user holding the Developer role.
  2. An administrator account that can change that user's role.
  3. The ability to create an access token from the demoted user's account.

The report does not name a GitLab version. It states that the bug happens on GitLab.com.

Finding it

The researcher compared two surfaces that should enforce the same permission: the web UI and the API. In the UI, once the user is demoted to Guest, the Merge Request tab is not available, so the merge request created by that user can no longer be opened. The same merge request, addressed through the API with the Guest's own token, was still readable. That mismatch between the UI behaviour and the API behaviour is the finding: the authorisation check is applied in one place and missing in the other.

Exploitation

Step 1: give the user the Developer role

Add the user to the project with the Developer role. This is the role that lets them create a merge request in the first place.

Step 2: create a merge request

From the added user's account, create a merge request in the project. This merge request is the object the rest of the attack targets.

Step 3: demote the user to Guest

From the admin account, demote the user to the Guest role. In the UI this removes their access to the merge request, including the one they created.

Step 4: confirm the UI blocks access

From the Guest account, try to access the merge request created by that user. The Merge Request tab is not available for that user, so the UI path is closed.

Step 5: create an access token and call the API

Create an access token from the Guest account and use it against any of the endpoints below, addressing the merge request by its project id and its internal iid. The report lists these as the actions the Guest can still perform:

  • View the title and description of the merge request via /projects/:id/merge_requests/:merge_request_iid
  • Get a list of merge request participants via /projects/:id/merge_requests/:merge_request_iid/participants
  • Get a list of merge request commits via /projects/:id/merge_requests/:merge_request_iid/commits
  • Get information about the merge request including its files and changes via /projects/:id/merge_requests/:merge_request_iid/changes
  • Get a list of merge request pipelines via /projects/:id/merge_requests/:merge_request_iid/pipelines
  • Create a TODO for that merge request via POST /projects/:id/merge_requests/:merge_request_iid/todo
  • Get a list of merge request diff versions via /projects/:id/merge_requests/:merge_request_iid/versions
  • Get merge request approvals status via /projects/:id/merge_requests/:merge_request_iid/approvals

In each case the Guest is able to view the merge request, which the UI says they are not permitted to do. The report does not include the raw requests, responses or status codes, only the endpoint list and the observation that the data comes back.

The endpoints fall into two groups. The first is read access to the merge request itself and its surrounding data: metadata, participants, commits, the full set of files and changes, pipelines, diff versions and approval status. The second is a write action, POST /projects/:id/merge_requests/:merge_request_iid/todo, which lets the Guest create a to-do item on a merge request they should not be able to see. The report describes the overall result as being able to view and edit merge request data, and the to-do endpoint is the concrete write shown.

Root cause

The report's own explanation is that the permission check is implemented for the UI but not for the API. In other words, the merge request endpoints do not verify that the caller's role on the project still grants access to merge requests before returning data or accepting the to-do write. The UI hides the feature, but hiding a tab is not an authorisation control; the API is a separate entry point and has to enforce the same rule. Because the check is missing there, a token belonging to a Guest is treated as sufficient for merge request operations. The report does not show the code path, so the exact location of the missing check is not stated.

Impact

A user demoted to Guest keeps access, through the API, to merge request data they are not authorised to view or edit. That includes the title and description, participants, commits, the files and changes in the diff, pipelines, diff versions and approval status, plus the ability to create a to-do on the merge request. The report rates the issue as medium severity and it was rewarded with a bounty.

Fix

Apply the same merge request permission check in the API that the UI already applies, so that a Guest's token is rejected on these endpoints just as the Merge Request tab is hidden from them.

Variants to test

  • A positive result is any endpoint returning merge request data instead of an authorisation error.
  • If the UI hides them but the corresponding API endpoints still return them, the same class of bug is present.
  • A positive result is data or a successful write on an object the UI no longer shows.
  • A positive result is a successful change rather than a permission error.

Hunting notes

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 10 min read.

What happened, in plain words

GitLab is a website where teams keep their software projects and work on them together. Inside a project, each person has a role, and the role decides what they are allowed to do. A Developer is a fairly trusted role: they can write code and propose changes. A Guest is a very limited role: they can look around but not do much.

One of the main things people do in GitLab is propose a change to the code, called a merge request. A merge request carries a title, a description, the list of code changes, comments from other people, automated test results and approval decisions. When someone creates a merge request, it belongs to the project, and the project's rules decide who may see it.

The researcher found that when a user is demoted from Developer to Guest, the website correctly hides the Merge Request tab, so the person can no longer open merge requests in the browser, not even the ones they created themselves. But GitLab also offers a second way to reach the same data, called an API, and that second way did not apply the same rule. Using the API with a token belonging to the demoted Guest, the researcher could still read the merge request and even create a to-do item on it.

This kind of mistake is called a broken access control problem: the product checks who you are and what role you have in one place, but forgets to check it in another place that leads to the same information.

Background you need first

What a role is

In GitLab, a project has members, and every member has a role. The report mentions two of them: Developer and Guest. A Developer can create merge requests. A Guest is much more restricted. The role is stored on the server, and the server is supposed to consult it every time someone asks for something.

What a merge request is

A merge request is a proposal to change the code in a project. It has a title and a description written by its author, a set of commits (saved snapshots of code changes), a diff (the actual lines added and removed), pipelines (automated checks that run on the change), approvals (sign-offs from other people) and participants (everyone involved in the discussion). All of that is data attached to one merge request, and all of it can be sensitive: it can reveal unreleased code, internal plans and who is working on what.

What the web interface and the API are

The web interface is what you see in a browser: pages, tabs, buttons. The API (Application Programming Interface) is a second front door to the same building, meant for programs rather than people. Instead of clicking a tab, a program sends a request to a web address and gets data back, usually in a machine-readable format. A useful comparison: the web interface is the shop counter with a shop assistant, and the API is the loading bay at the back. Both lead to the same stockroom, so both need the same lock.

What an endpoint is

An endpoint is one specific address on the API that does one specific job. In the report, endpoints look like /projects/:id/merge_requests/:merge_request_iid. The parts starting with a colon are placeholders: :id is the project's number and :merge_request_iid is the merge request's number inside that project. When you actually call the endpoint, you replace the placeholders with real numbers.

What an access token is

When you log in to a website in a browser, the site gives your browser a small piece of data so it remembers you on the next page. That is often called a cookie. For programs, GitLab offers access tokens: a long secret string that you create from your account and that you attach to each API request instead of typing a password. A token is like a key card: whoever holds it is treated as the account it belongs to. That is why the researcher could act as the demoted Guest: they created a token from that account and used it.

What the vulnerability class means

Improper access control means the product does not properly check whether the person asking is allowed to get what they are asking for. Here the check exists in the browser-facing part but not in the API part. Hiding a tab is not a security control: it only stops honest clicking. The real control has to sit on the server, on every door.

The setup needed before testing

The researcher needed three things, and none of them require special tools beyond something that can send API requests and a token:

  1. A project with at least one user holding the Developer role.
  2. An administrator account that can change that user's role.
  3. The ability to create an access token from the demoted user's account.

The report does not name a GitLab version. It states that the bug happens on GitLab.com.

How the researcher found it

The researcher compared two surfaces that should enforce the same permission: the web interface and the API. In the web interface, once the user is demoted to Guest, the Merge Request tab is not available, so the merge request created by that user can no longer be opened. The same merge request, addressed through the API with the Guest's own token, was still readable. That mismatch between the interface and the API is the finding: the authorisation check is applied in one place and missing in the other.

Step by step, and why each step was taken

Step 1: give the user the Developer role

Add the user to the project with the Developer role. This is the role that lets them create a merge request in the first place. Without this step there would be no merge request to test against.

Step 2: create a merge request

From the added user's account, create a merge request in the project. This merge request is the object the rest of the test targets. It is created while the user still has permission, which is exactly the situation the researcher wants to test later: what happens to that object after the permission is taken away.

Step 3: demote the user to Guest

From the administrator account, demote the user to the Guest role. In the web interface this removes their access to the merge request, including the one they created. This is the moment the permission changes, and the question is whether every part of GitLab notices.

Step 4: confirm the web interface blocks access

From the Guest account, try to access the merge request created by that user. The Merge Request tab is not available for that user, so the browser path is closed. This step matters because it establishes the intended behaviour: the product itself says this person should not see this merge request.

Step 5: create an access token and call the API

Create an access token from the Guest account and use it against any of the endpoints below, addressing the merge request by its project id and its internal iid. The report lists these as the actions the Guest can still perform:

  • View the title and description of the merge request via /projects/:id/merge_requests/:merge_request_iid
  • Get a list of merge request participants via /projects/:id/merge_requests/:merge_request_iid/participants
  • Get a list of merge request commits via /projects/:id/merge_requests/:merge_request_iid/commits
  • Get information about the merge request including its files and changes via /projects/:id/merge_requests/:merge_request_iid/changes
  • Get a list of merge request pipelines via /projects/:id/merge_requests/:merge_request_iid/pipelines
  • Create a TODO for that merge request via POST /projects/:id/merge_requests/:merge_request_iid/todo
  • Get a list of merge request diff versions via /projects/:id/merge_requests/:merge_request_iid/versions
  • Get merge request approvals status via /projects/:id/merge_requests/:merge_request_iid/approvals

In each case the Guest is able to view the merge request, which the web interface says they are not permitted to do. The report does not include the raw requests, responses or status codes, only the endpoint list and the observation that the data comes back.

The endpoints fall into two groups. The first is read access to the merge request itself and its surrounding data: metadata, participants, commits, the full set of files and changes, pipelines, diff versions and approval status. The second is a write action, POST /projects/:id/merge_requests/:merge_request_iid/todo, which lets the Guest create a to-do item on a merge request they should not be able to see. The report describes the overall result as being able to view and edit merge request data, and the to-do endpoint is the concrete write shown.

Why it works

The report's own explanation is that the permission check is implemented for the web interface but not for the API. In other words, the merge request endpoints do not verify that the caller's role on the project still grants access to merge requests before returning data or accepting the to-do write. The interface hides the feature, but hiding a tab is not an authorisation control; the API is a separate entry point and has to enforce the same rule. Because the check is missing there, a token belonging to a Guest is treated as sufficient for merge request operations. The report does not show the code path, so the exact location of the missing check is not stated.

What the impact is

A user demoted to Guest keeps access, through the API, to merge request data they are not authorised to view or edit. That includes the title and description, participants, commits, the files and changes in the diff, pipelines, diff versions and approval status, plus the ability to create a to-do on the merge request. The report rates the issue as medium severity and it was rewarded with a bounty.

How it should be fixed

Apply the same merge request permission check in the API that the web interface already applies, so that a Guest's token is rejected on these endpoints just as the Merge Request tab is hidden from them.

Other places to look for the same mistake

  • A positive result is any endpoint returning merge request data instead of an authorisation error.
  • If the interface hides them but the corresponding API endpoints still return them, the same class of bug is present.
  • A positive result is data or a successful write on an object the interface no longer shows.
  • A positive result is a successful change rather than a permission error.

Notes for anyone hunting this kind of bug

Glossary

  • API: a second way to talk to a website, designed for programs rather than people, where you send a request to an address and get data back.
  • Access token: a long secret string created from an account that a program attaches to each request instead of a password; whoever holds it acts as that account.
  • Authorisation: the check of whether a person is allowed to do a particular thing, as opposed to authentication, which is the check of who they are.
  • Broken access control / improper access control: a class of bug where the product fails to check properly whether the requester is allowed to get what they asked for.
  • Commit: a saved snapshot of code changes in a project.
  • Cookie: a small piece of data a website gives your browser so it remembers you between pages.
  • Demote: to lower a user's role, for example from Developer to Guest.
  • Developer: a GitLab project role that allows a user to write code and create merge requests.
  • Diff: the actual lines of code added and removed by a change.
  • Endpoint: one specific address on an API that performs one specific job.
  • Epic: a GitLab object that groups related work at a higher level than an issue.
  • Guest: a very limited GitLab project role with little or no access to code and merge requests.
  • iid: the internal number of an object inside a project, used together with the project id to address it.
  • Issue: a GitLab object used to track a task, bug or idea.
  • Maintainer: a GitLab project role with broad administrative rights over the project.
  • Merge request: a proposal to change code in a project, carrying a title, description, commits, diff, pipelines, approvals and participants.
  • Participant: a person involved in a merge request's discussion.
  • Personal access token: an access token created from a user's own account.
  • Pipeline: an automated set of checks that runs on a code change.
  • Project access token: an access token that belongs to a project rather than to a person.
  • Role: the level of permission a user has in a project, such as Developer or Guest.
  • Snippet: a small piece of shared code stored in GitLab.
  • Sub-resource: data attached to a larger object, such as notes or discussions on a merge request.
  • To-do: a personal reminder item in GitLab that a user can create on an object such as a merge request.
  • Web interface (UI): the pages, tabs and buttons you see and click in a browser.
  • Wiki page: a documentation page stored inside a GitLab project.

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.