Group SSO enforcement bypass when using Trigger or Personal Access Tokens
GitLab group SSO enforcement did not block pipeline trigger tokens or personal access tokens, even though these tokens are tied to a user. An attacker with such a token could trigger pipelines with arbitrary variables without an active SSO session.
GitLab
Originally disclosed on GitLab
- Fixed in 23 hours
- Disclosed after 23 hours
HackerOne report #1592653 by joaxcar on 2022-06-06, assigned to @nmalcolm:
TL;DR - personal access tokens and CI trigger tokens continue to work even when SSO is enforced at a group level. This runs counter to the documentation which implies that credentials which are tied to a regular user will have the SSO check enforced:
Credentials that are not tied to regular users (for example, project and group access tokens, and deploy keys) do not have the SSO check enforced.
https://docs.gitlab.com/ee/user/group/saml_sso/index.html#sso-enforcement
SSO Config
Web-based experience
Trigger Tokens still work
(Ignore that they fail - the issue is I can trigger them. Pipeline failure is due to billing).
Project API still works
Report | How To Reproduce
Original Report
Summary
An owner/maintainer of a (premium +) top group can configure SAML SSO requirements for access to the group. See documentation link. If the group activate the setting "Enforce SSO-only authentication for web activity for this group" no user that does not have an active SSO session with the configured provider is restricted from accessing the group (and private projects in the group)
In the docs for "SSO enforcement" link this is stated
Credentials that are not tied to regular users (for example, project and group access tokens, and deploy keys) do not have the SSO check enforced.
As far as I can read in the docs Trigger tokens link should not fall in this category as they are tied to the user that creates the token. And any jobs are run as the user that created the token.
As it turns out, trigger tokens are not blocked by SSO enforcement. And the user can thus trigger tokens with arbitrary variables without having an active SSO session.
Steps to reproduce
- Create a user
user01 - Create a group with at least
Premiumsubscription (create an ultimate trail if needed), lets call itgroup01 - Create a
privateproject in the group, lets call itproject01 - In the project create the file
.gitlab-ci.yml
build-job:
stage: build
script:
- echo "just doing something"
- Go to https://gitlab.com/joaxcarultimate3/test3/-/settings/ci_cd and expand
Pipeline triggers - Create a pipeline trigger token, take a note of it
- Now go to group settings https://gitlab.com/groups/group01/-/saml and configure a SAML provider (you can fake the provider, use any URL and use a valid fingerprint. use mine
D0:E8:0F:EA:ED:40:9E:7E:D2:54:4E:25:39:7C:4F:1B:12:A5:EF:DFif you dont have one.) - Check the boxes
- Enable SAML authentication for this group
- Enforce SSO-only authentication for web activity for this group
- Click save.
- Try to go to https://gitlab.com/joaxcarultimate3/test3/-/pipelines this will ask you to SSO authenticate
- Now send this request in a terminal (replace TOKEN and PROJECTID
curl -X POST \
--fail \
-F token=TOKEN \
-F ref=main \
https://gitlab.com/api/v4/projects/PROJECTID/trigger/pipeline
- You will get a response that a pipeline have run
- If you now uncheck the SSO requirement and go to https://gitlab.com/joaxcarultimate3/test3/-/pipelines you will see that it has run
Impact
Pipeline trigger tokens can be used to trigger pipelines with arbitrary variables by a user that should not have access to the project due to missing SSO session
What is the current bug behavior?
Trigger tokens work without SSO session if it is enforced
What is the expected correct behavior?
Trigger tokens should not work without SSO session if it is enforced
Output of checks
This bug happens on GitLab.com
CVSS. This CVSS mimics the once from the latest patch concerning IP block https://about.gitlab.com/releases/2022/06/01/critical-security-release-gitlab-15-0-1-released/#ip-allowlist-bypass-when-using-trigger-tokens
Impact
Pipeline trigger tokens can be used to trigger pipelines with arbitrary variables by a user that should not have access to the project due to missing SSO session
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
Impact
Pipeline trigger tokens could be used to trigger pipelines with arbitrary variables by a user who should not have access to the project due to a missing SSO session.
What the attacker needed
A GitLab account; a Premium or Ultimate group; a private project in the group; a pipeline trigger token
How it was found
- Create a user and a group with a Premium subscription.
- Create a private project in the group and add a CI configuration file.
- Create a pipeline trigger token in the project settings.
- Configure a SAML provider for the group and enable SSO enforcement.
- Try to access the project pipelines page; it asks for SSO authentication.
- Send a request to the pipeline trigger API with the token and observe that a pipeline runs.
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.
Single sign-on (SSO) is a way to log in once and access many services. When a group enforces SSO, users must prove they logged in through the company's identity provider before accessing group resources. This report found that special tokens used to start automated jobs (pipelines) still worked even when the user had not done that SSO login, so someone with a token could still make the system run jobs.
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.