Transferred group to new owner / namespace - Allowing unauthorized SSO and SCIM token misused
When a GitLab group with SAML SSO is transferred to a new namespace as a child group, the SAML SSO settings become invisible, but the previous SSO configuration and SCIM token remain active. An attacker with the old SCIM token can create users, and a previous owner can regain owner access to the new private group via SSO.
GitLab
Originally disclosed on GitLab
- Fixed in 3 months
- Disclosed after 3 months
HackerOne report #1791518 by vaib25vicky on 2022-12-03, assigned to @cmaxim:
Report | Attachments | How To Reproduce
Report
Hi,
In the past I've submitted same issues(https://hackerone.com/reports/1258092) affecting Gitlab.com but those bugs become ineffective because of new unrelated changes are deployed. Gitlab.com is saved and instances don't allow Group saml sso at that time.
However, after 1 year, Gitlab self-hosted instances allow Group saml sso and same bugs resurfaced. Gitlab self-hosted instances are vulnerable now and not Gitlab.com
Summary:
Group with SAML SSO when transferred to new namespace as a child group then group SAML SSO setting options become invisible.
But all the previous config still works such as SSO and SCIM token
This bug can be exploited for three things
- Previous owner transferred the group to private namespace, he got kicked out of the new group but he can again SSO into the group with owner permission.
New owner can't stop him because SSO settings are invisible
2. Billing is associated with the parent group so when the group with SAML SSO transfer to the parent group on free plan, SSO still works and allows paid feature group SAML SSO and SCIM to use as free
3. Since, group SAML SSO becomes invisible SCIM token can longer be reset so in case when SCIM token is known to previous users or got leaked
then token can be used to create new users in the group with higher permissions
Steps-to-reproduce:
You can also try my POC given below where most of the things are already configured and you just have to exploit. This is much simple poc and suggested to use for quick triage!
SCIM Token
- set-up group sso and creates SCIM token
- transfer the group to a new namespace/group as child group
- child group saml sso setting becomes invisible
- use the token to creates a new user (https://docs.gitlab.com/ee/development/internal_api/index.html#create-a-scim-provisioned-user) in the child group
curl --request POST "https://gdk.test:3443/api/scim/v2/groups/lakita-group%2Fmadie-group/Users" \
--data '{"externalId":"test_uid","active":null,"userName":"username","emails":[{"primary":true,"type":"work","value":"[email protected]"}],"name":{"formatted":"Test User","familyName":"User","givenName":"Test"},"schemas":["urn:ietf:params:scim:schemas:core:2.0:User"],"meta":{"resourceType":"User"}}' \
--header "Authorization: Bearer <SCIM_TOKEN>" --header "Content-Type: application/scim+json"
User will be successfully created
SSO into new private group
- set up group sso and generate scim token
- transfer the group as a child group in different namespace (private group)
- remove previous owner, they can't access the private group
- change your idP config of the saml and replace old group path to the new one
- go the saml auth url directly and intercept the request
- change the path parameter with the new namespace
- continue the authorization process
On success, previous owner will again gain owner permission in the new private group where he didn't have any access initially
POC:
My Gitlab Instance [REDACTED]
Group named test was a top-level group with saml sso configured. It was later transferred to group named group-two. Previous user kicked out and since, test group is now a sub-group, new owner can't access saml sso settings in test sub-group and can't disable it.
Previous user log-in to their idP dashboard and initiate login to gain access to new private project privv inside group test
- Okta user credentials:
Okta dashboard url - [REDACTED]
username - [REDACTED] password - [REDACTED]
- After login, click gitlab-group app to initiate sso. You will be redirected to login to gitlab instance.
Gitlab instance user credentials
username - [REDACTED]
password - [REDACTED]
-
You will be redirected and gets an authorization screen, don't authorize yet
-
Open burp and keep intercept ON
-
Now, click on authorize and change the parameter
?group_path=testto?group_path=group-two%2ftest
and forward it.
6. Continue the saml flow without any more changes. After sso flow is completed you will gain access to the group test and also private project inside it named test/privv
Impact
Old SAML SSO still active so users part of the idP can still SSO into new private group which belongs to different owners
Previous kicked out owner can again become owner and new owner can't stop because saml settings are invisible
Billing is associated with the parent group so when the group with SAML SSO transfer to the parent group on free plan, SSO still works and allows paid feature group SAML SSO and SCIM to use as free
Since, group SAML SSO becomes invisible SCIM token can longer be reset so in case when SCIM token is known to previous users or got leaked
then token can be used to create new users in the group with higher permissions
Thanks!
Attachments
Warning: Attachments received through HackerOne, please exercise caution!
How To Reproduce
Please add reproducibility information to this section:
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 application hides the SAML SSO settings when a group becomes a child group but does not disable the underlying SSO and SCIM configurations.
Impact
A previous owner can regain owner access to a private group, and a leaked SCIM token can be used to create users with higher permissions; also, paid SSO features may be used for free.
What the attacker needed
Group with SAML SSO configured; Group transferred to new namespace as child; SCIM token known or leaked; Previous owner has IdP access
How it was found
- Set up group SAML SSO and create a SCIM token.
- Transfer the group to a new namespace as a child group.
- Observe that the child group's SAML SSO settings become invisible.
- Use the SCIM token to create a new user in the child group.
- For SSO: after transfer, remove the previous owner, then change the IdP config to the new group path.
- Intercept the SAML auth request and change the group path parameter to the new namespace, then continue the flow to regain owner access.
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.
SAML SSO is a way to log in using an external identity provider. SCIM is a system for automatically creating user accounts. When a group is moved, the settings to manage these features disappear, but the old connections still work, so someone who should have lost access can still get in or create accounts.
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.