Access Token with read_user Scope Can Read Private Repo's Events
A token with only the read_user scope could retrieve a user's events feed, which included details of private projects such as issue titles and comments. An attacker holding such a low-privilege token could therefore read information that the projects endpoint correctly refused to show.
GitLab
Originally disclosed on GitLab
- Fixed in 22 hours
- Disclosed after 22 hours
HackerOne report #718159 by ngalog on 2019-10-20, assigned to @cmaxim:
Summary
The description for read_user scope is as follow:
Grants read-only access to the authenticated user's profile through the /user API endpoint, which includes username, public email, and full name. Also grants access to read-only API endpoints under /users.
And I found that there is an indirect way to steal escape out of the /users API endpoints, and it is in users/:userid/events to collect user's private projects/groups events information
Steps to reproduce
- Generate a read_user access token in https://gitlab.com/profile/personal_access_tokens, or use mine `[REDACTED]'
- Make below request
GET /api/v4/users/2820780/events HTTP/1.1
Host: gitlab.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:69.0) Gecko/20100101 Firefox/69.0
content-type:application/json
Accept: */*
Accept-Language: en-US,en;q=0.5
Private-Token: [REDACTED]-
- You should see the endpoint contains information about my private project's event, project id --
14827629. Including the private issue's title and comment and etc - But if you use the same token to make below request
GET /api/v4/projects/14827629/events HTTP/1.1
Host: gitlab.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:69.0) Gecko/20100101 Firefox/69.0
content-type:application/json
Accept: */*
Accept-Language: en-US,en;q=0.5
Private-Token: [REDACTED]-
-
You will see the 403 forbidden error, meaning your access token is not privileged enough to see that information.
-
Now we have a self-contradicting siutation, although you can't see the event information in
GET /api/v4/projects/14827629/events HTTP/1.1, you can see the event information inGET /api/v4/users/2820780/events HTTP/1.1 -
So this is what I meant by escaping the
/usersAPI endpoints and see information inprojectsendpoints
Impact
Read_user API access token can escalate to /projects or /groups
Examples
Given above
What is the current bug behavior?
Given above
What is the expected correct behavior?
should not return such private project's info in /users/:userid/events, just the same way gitlab didn't disclose the private project's information in /projects with just read_user scope access token
Relevant logs and/or screenshots
NA
Output of checks
gitlab.com
Impact
See above
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 user events endpoint did not apply the same project-level permission checks as the projects events endpoint, so it returned events for private projects to a token with only read_user scope.
Impact
A read_user token could expose private project and group event data, effectively escalating to information normally reserved for the projects or groups endpoints.
What the attacker needed
A personal access token with read_user scope; knowledge of a target user id
How it was found
- Create a personal access token with only the read_user scope.
- Request the events endpoint for a user id using that token.
- Observe that events from a private project, including issue titles and comments, are returned.
- Request the events endpoint for that private project id with the same token and note it is refused with a forbidden error.
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.
An access token is like a limited key that lets a program act for a user. This key was only meant to read basic public profile details, but the events feed for a user also leaked activity from private projects. So a key that should be weak could reveal things it was never meant to show.
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.