Skip to content
IDOR Disclosed report Intermediate

IDOR in securityPolicyProjectAssign Mutation Allows Guest User to Read Security Policy YAML

The securityPolicyProjectAssign mutation did not properly authorise the securityPolicyProjectId parameter, allowing a guest user to assign another project's security policy project to their own project and read the policy YAML. This bypassed the intended fix for CVE-2023-4002 and let an unauthorised user view sensitive policy data.

GitLab

Originally disclosed on GitLab

  • Fixed in 4 months
  • Disclosed after 4 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 #2818270 by yuki_osaki on 2024-11-03, assigned to @kmorrison1:

Report | Attachments | How To Reproduce

Report

Summary

The securityPolicyProjectAssign mutation does not properly authorize the securityPolicyProjectId parameter, bypassing the intended fix of CVE-2023-4002 (https://about.gitlab.com/releases/2023/08/01/security-release-gitlab-16-2-2-released/) and reintroducing the vulnerability. Although CVE-2023-4002 originally added authorization checks to prevent unauthorized access, this check is insufficient, resulting in incomplete access restriction.

In private project, guest users are restricted from reading code which mean that cannot read the contents of security policies. However, by directly calling the securityPolicyProjectAssign mutation, a guest user can access the YAML content of the security policy. This leads to an IDOR , allowing unauthorized users to view sensitive policy data.

Details of the Bypass

The patch for CVE-2023-4002 introduced the following authorization check:
https://gitlab.com/gitlab-org/gitlab/-/commit/080914bd656e154d079b7c7aa1463942c7f4e81a

ee/app/graphql/mutations/security_policy/assign_security_policy_project.rb

Ruby
def can_access_security_policy?(policy_project)  
   Ability.allowed?(current_user, :read_security_orchestration_policy_project, policy_project)  
end  

ee/app/policies/ee/project_policy.rb

Ruby
rule { security_orchestration_policies_enabled & can?(:guest_access) }.policy do  
   enable :read_security_orchestration_policy_project  
end  

This patch aimed to prevent unauthorized users from assigning and accessing the security policy project by checking if they had access permissions to the security policy project. However, even within private projects, guest users can still call the securityPolicyProjectAssign mutation and gain access to the security policy YAML, which they would normally be restricted from viewing.

Note

The previous CVE recognized unauthorized access to security policy YAML as a vulnerability. In GitLab’s issue tracker for https://gitlab.com/gitlab-org/gitlab/-/issues/416647#note_1452019550, comments specify that the security policy YAML could contain sensitive variables, which should be considered a vulnerability. Dominic Bauer explains:

“I believe we could consider it as a vulnerability, as potential variables could be stored in these policies and leaked as a result.”

Therefore, this report should also be treated as a vulnerability.

Here are the steps to reproduce this vulnerability:

  1. Set Up Victim User.

    • The victim user creates a group (e.g., victim-corp).

    • Within this group, they create a new project (e.g., victim-security-policy-project).

    • The victim user sets up a security policy in this project with the following YAML configuration:

YAML
approval_policy:  
- name: test  
  description: test  
  enabled: true  
  rules:  
  - type: any_merge_request  
    branch_type: protected  
    commits: any  
  actions:  
  - type: require_approval  
    approvals_required: 1  
    role_approvers:  
    - owner  
  - type: send_bot_message  
    enabled: true  
  approval_settings:  
    block_branch_modification: true  
    prevent_pushing_and_force_pushing: true  
    prevent_approval_by_author: true  
    prevent_approval_by_commit_author: true  
    remove_approvals_with_new_commit: true  
    require_password_to_approve: false  
  fallback_behavior:  
    fail: closed  
2.	Invite Attacker as Guest. 

  •	The victim user invites the attacker (e.g., User B) to the victim-security-policy-project with guest permissions.  

3.	Attacker Creates Their Own Group and Project. 

  •	The attacker creates a new group (e.g., attacker-corp) and a new project within this group.  

  •	Attempting to assign the victim’s security policy project to their project through the UI will fail due to access restrictions.  

4.	Exploiting the Vulnerability via GraphQL. 

  •	The attacker uses the GraphQL Explorer (e.g., https://gitlab.com/-/graphql-explorer) to obtain the ID of the victim’s security policy    

project.

 query {  
   project(fullPath: "victim-corp/victim-security-policy-project") {  
     id  
   }  
 }  
  •	With the acquired ID (e.g., gid://gitlab/Project/64192849), the attacker executes the following securityPolicyProjectAssign mutation to assign the victim’s security policy project to their own project:  
mutation {  
  securityPolicyProjectAssign(input: { fullPath: "attacker-corp/attacker-project", securityPolicyProjectId: "gid://gitlab/Project/64192849" }) {  
    errors  
  }  
}
  1. Verification

• The attacker navigates to Secure > Policies in their project (attacker-project) and verifies that the security policy from the victim project is visible.

Example policy displayed in the attacker’s project:

Using this vulnerability, an attacker with only guest permissions can directly call the securityPolicyProjectAssign mutation to view the YAML contents of another project’s security policy, bypassing typical access controls.

Impact

Guest user can Read Security Policy YAML

Results of GitLab environment info

This issue occurs in GitLab.

Impact

Guest user can Read Security Policy YAML

Attachments

Warning: Attachments received through HackerOne, please exercise caution!

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 authorisation check for the securityPolicyProjectAssign mutation only verified that the user could read the security policy project, but did not ensure the user had permission to assign that project to their own project, so a guest could still perform the assignment.

Impact

A guest user could read the security policy YAML of another project, which may contain sensitive variables.

What the attacker needed

Victim has a private project with a security policy; attacker is a guest in that project; attacker has their own project

How it was found

  1. Victim creates a group and a project, and sets up a security policy in that project.
  2. Victim invites the attacker as a guest to the security policy project.
  3. Attacker creates their own group and project.
  4. Attacker uses GraphQL to obtain the ID of the victim's security policy project.
  5. Attacker executes the securityPolicyProjectAssign mutation with the victim's project ID and their own project path.
  6. Attacker navigates to Secure > Policies in their project and sees the victim's security policy YAML.

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.

A guest user is someone with limited access to a private project, usually unable to read its code. The security policy project holds configuration files that may contain sensitive variables. A flaw in a GraphQL operation let a guest attach someone else's policy project to their own project and then read the policy file, which they should not have been able to see.

What is IDOR?

One user can read or change another user's data, usually by changing an identifier the server trusts without checking who is asking. One of the most paid bug classes on web programs.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Insecure direct object reference (IDOR)

The lesson behind this report.

One user can read or change another user's data, usually by changing an identifier the server trusts without checking who is asking. One of the most paid bug classes on web programs.