Enforced group MFA can be bypassed with OAuth token with all the scopes
A group owner can enforce two-factor authentication for all members, but a member can bypass this by creating an OAuth token that still grants access to the group's resources. An attacker with a valid account could use such a token to access confidential information and modify resources without enabling 2FA.
GitLab
Originally disclosed on GitLab
- Fixed in 5 months
- Disclosed after 5 months
HackerOne report #1498133 by albatraoz on 2022-03-02, assigned to @kmorrison1:
Report | How To Reproduce
Report
Summary
A group owner can enforce the members of a group to enabled 2FA. This makes sure that the members of the group enable 2FA or else they are not able to access group or make any changes in the group & it's projects. But a member of the group can bypass this restriction by creating an OAuth token which still has access to the group's resources.
Steps to reproduce
- As User A create a private group.
- Invite User B as a developer in this private group.
- Go to Settings -> General -> Permissions and group features -> Enable Require all users in this group to set up two-factor authentication
- Change time before enforced as 0 hours.
- Now login as User B & you will see that you are enforced to enable the 2FA or leave the group. Without leaving the group you are not allowed to access anything on gitlab UI.
- Now open a terminal & run the following command with credentials of user B.
echo 'grant_type=password&username=<userB_username>&password=<userB_password>' > auth.txt
curl --data "[@]auth.txt" --request POST "https://gitlab.com/oauth/token"
The response would contain the access token.
7. Now use the access token we got from step 6 in the following command & replace the group id with the group created in step 1.
curl --header "Authorization: Bearer [OAUTH_TOKEN]" "https://gitlab.com/api/v4/groups/[GROUP_ID]"
You will see that you are able to access the group details without enabling 2FA.
Impact
An attacker would be able to bypass the 2FA enforcement of a group & access confidential information & alter objects/resources using different OAuth scopes available for the token like writing to repository.
Proposal
Solution is proposed here.
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 OAuth token issuance and API authentication do not check whether the user has satisfied the group's 2FA enforcement policy.
Impact
An attacker could bypass the group's 2FA enforcement and access confidential information or alter resources using the token's scopes, such as writing to a repository.
What the attacker needed
A GitLab account; membership in a group with enforced 2FA; valid credentials for that account
The fix
The text proposes a solution in a linked issue, but does not describe the fix itself.
How it was found
- As User A, create a private group.
- Invite User B as a developer in this private group.
- Enable the setting 'Require all users in this group to set up two-factor authentication' and set the grace period to 0 hours.
- Log in as User B; the UI enforces 2FA and blocks access.
- Using User B's credentials, request an OAuth token via the password grant.
- Use the obtained token to call the API and access the group details without enabling 2FA.
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.
Two-factor authentication (2FA) is an extra security step, like a code from your phone, that you must provide when logging in. A group owner can require all members to use 2FA, but the report shows that a member can skip this by creating a special access token (OAuth token) that still works for the group. This means the 2FA rule can be bypassed, letting someone access private group data without the extra step.
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.