Skip to content
Access control Disclosed report Intermediate

Unauthorized Access to Job Data via GraphQL Parent Authorization `getJobTraceHtmlSummary` query

The GitLab GraphQL API allowed a user with a custom guest role to retrieve job trace summaries and CI/CD variables via the terraformStates field, because authorization was only checked on the parent project rather than the job itself. An attacker with minimal permissions could access sensitive job data and traverse pipeline stages.

GitLab

Originally disclosed on GitLab

  • Fixed in 3 months
  • Disclosed after 3 months

⚠️ Please read the process on how to fix security issues before starting to work on the issue. Vulnerabilities must be fixed in a security mirror.

HackerOne report #2972576 by pwnie on 2025-02-04, assigned to @ameyadarshan:

Report | How To Reproduce

Report

Vulnerability Report: Unauthorized Access to Terraform Job Data via GraphQL Parent Authorization

Summary

A critical flaw in the GitLab GraphQL API allows unauthorized users to retrieve sensitive Terraform state job details. Instead of enforcing authorization at the job level, the endpoint relies solely on parent type checks. This misconfiguration lets users with minimal (custom guest) permissions access confidential job traces, manual CI/CD variables, and even traverse through previous job stages—potentially exposing the entire pipeline's sensitive data.

Steps to Reproduce

  1. Create a GitLab Group with Ultimate License:

    • Sign up for an Ultimate license trial at GitLab Free Trial.
    • Create a new group under this trial.
  2. Establish a Custom Role:

    • Within the group, define a custom role based on the Guest level.
    • Grant the additional permission admin_terraform to this custom role.
  3. Set Up a New Project:

    • Create a new project under the group.

    • Add the following .gitlab-ci.yml to configure a Terraform state upload job:

      YAML
      stages:  
        - upload
      
      upload_terraform_state:  
        stage: upload  
        image: curlimages/curl:latest  
        script:  
          - 'echo "{\"version\": 4, \"terraform_version\": \"1.0.0\", \"resources\": []}" > state.tfstate'  
          - >  
            curl --fail --user "gitlab-ci-token:$CI_JOB_TOKEN" \  
              -X POST "https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/terraform/state/example?serial=1" \  
              --data-binary "[@]state.tfstate"  
        only:  
          - main  
      
  4. Trigger the Pipeline:

    • Commit the changes to start the pipeline.
    • Wait for the job to finish executing.
  5. Invite an Attacker Account:

    • Add a second GitLab account to the project, assigning it the newly created custom role.
  6. Restrict Pipeline Visibility:

    • Before proceeding, ensure that the project's pipeline visibility is set to private so that pipelines aren’t displayed to unauthorized users.
  7. Confirm Limited Pipeline Access:

    • Log in with the second (attacker) account and verify that the pipelines list is not visible in the UI.
  8. Access the GraphQL Explorer:

    • Open the GitLab GraphQL Explorer.
  9. Execute the Vulnerable Query:

    • Paste the following GraphQL query into the explorer:

      GraphQL
      query getJobTraceHtmlSummary(  
        $projectPath: ID!  
        $first: Int  
        $last: Int  
        $before: String  
        $after: String  
      ) {  
        project(fullPath: $projectPath) {  
          terraformStates(first: $first, last: $last, before: $before, after: $after) {  
            nodes {  
              latestVersion {  
                job {  
                  trace {  
                    htmlSummary  
                  }  
                }  
              }  
            }  
          }  
        }  
      }  
      
    • In the variables section, provide appropriate values (for example):

      JSON
      {  
        "projectPath": "ultimate_0001/need_dos",  
        "first": 25,  
        "after": null,  
        "last": null,  
        "before": null  
      }  
      
  10. Observe the Exploit:

    • Execute the query. Notice that the job trace (htmlSummary) is returned despite the attacker's limited access.
    • Additionally, be aware that manual CI/CD variables and jobs from previous stages (accessible via fields like previous_stage_jobs) can also be retrieved. This enables both backward and forward traversal through the pipeline, significantly expanding the potential attack surface.

Impact

  • Unauthorized Data Exposure: Attackers with minimal permissions can access sensitive job traces and CI/CD variables, including details from Terraform state uploads.
  • Pipeline Traversal: The ability to traverse previous and potentially future job stages means that attackers might extract confidential data from multiple jobs within the pipeline.
  • Broader Security Risks: This flaw can expose sensitive infrastructure details, secrets, and internal operational data, which could be used to further compromise systems or perform targeted attacks.

Components Affected

  • GraphQL API Authorization: The authorization mechanism on the job-level entities in the GraphQL API is insufficient, relying entirely on parent object checks.
  • Terraform State Upload Endpoint: Sensitive job data related to Terraform state uploads is exposed.
  • Related Job Fields: Fields such as previous_stage_jobs and potentially those related to needs allow unauthorized traversal across the entire pipeline.

Recommendation

  • Implement Independent Authorization Checks: Modify the GraphQL API to enforce granular authorization on the job-level entities. Each job should verify the requester's permissions independently, regardless of parent type authorization.
  • Restrict Field Exposure: Limit the exposure of sensitive fields such as htmlSummary, manual variables, and job traversal fields (previous_stage_jobs and similar) to only those users with explicit permissions.
  • Adopt a Defense-in-Depth Approach: Review and enhance the authorization model across the API to ensure that sensitive data remains protected even if higher-level access controls are bypassed.

By addressing these issues, GitLab can significantly reduce the risk of unauthorized data exposure and ensure that only appropriately privileged users can access sensitive CI/CD and Terraform state job information.

Impact

  • Unauthorized Data Exposure: Attackers with minimal permissions can access sensitive job traces and CI/CD variables, including details from Terraform state uploads.
  • Pipeline Traversal: The ability to traverse previous and potentially future job stages means that attackers might extract confidential data from multiple jobs within the pipeline.
  • Broader Security Risks: This flaw can expose sensitive infrastructure details, secrets, and internal operational data, which could be used to further compromise systems or perform targeted attacks.

How To Reproduce

Please add reproducibility information to this section:

The original report as published on GitLab. Images and videos are our own copies; raw HTML is shown as text. View it on GitLab.

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 API only performed authorization on the parent project object and did not independently verify permissions on the job-level entities, allowing access to job traces and variables.

Impact

Attackers with minimal permissions could access sensitive job traces and CI/CD variables, and potentially traverse previous and future job stages to extract confidential data from multiple jobs.

What the attacker needed

Ultimate license trial; Custom role with admin_terraform; Project with Terraform state job; Attacker account with custom role

The fix

The GraphQL API should enforce independent authorization checks on job-level entities and restrict exposure of sensitive fields to users with explicit permissions.

How it was found

  1. Create a GitLab group with an Ultimate trial license.
  2. Create a custom role based on Guest and grant the admin_terraform permission.
  3. Create a project and add a CI job that uploads a Terraform state file.
  4. Run the pipeline and wait for the job to finish.
  5. Invite a second account with the custom role and set pipeline visibility to private.
  6. Log in as the second account, open GraphQL Explorer, and run a query on terraformStates to retrieve job trace htmlSummary.

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.

In GitLab, a user with a low-privilege custom role could use a GraphQL query to see job logs and variables that should have been hidden. The system checked if the user could see the project, but forgot to check if they could see the specific job. This let them read sensitive data like Terraform state details.

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.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

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.