CVE-2023-2576 - GitLab CE/EE Developer Bypassing CODEOWNERS Rules and Merging to Protected Branches

A recent vulnerability has been discovered in GitLab Community Edition (CE) and Enterprise Edition (EE) software that allows a developer to bypass code owners protection and merge code changes directly into a protected branch, effectively bypassing required reviews, validations and additional security checks implemented by GitLab. This vulnerability is known with the Common Vulnerabilities and Exposures (CVE) identifier as CVE-2023-2576.

In this detailed post, we will be discussing the technical details of the vulnerability, along with its impact, affected versions, and mitigation steps that can be taken to protect your GitLab instances from exploitation. Additionally, we will provide code snippets, exploit paths, and links to the original references for more in-depth understanding and analysis.

Vulnerability Details

As per the official GitLab advisory, the vulnerability is present in the repository component of GitLab which allows developers who have sufficient permissions to bypass the CODEOWNERS settings and merge code changes directly into the protected branches without any mandatory approvals.

The vulnerability is specific to GitLab CE/EE versions starting from 13.7 before 15.11.10, all versions starting from 16. before 16..6, and all versions starting from 16.1 before 16.1.1.

Code Snippet

The core issue lies in the improper enforcement of the CODEOWNERS rules while handling merge requests. Here is a sample code snippet that illustrates the bypass:

# Submit a merge request without CODEOWNERS approval
# Developer removes CODEOWNERS file and force-pushes the commit
developer_merge_request = gitlab.force_push("source-branch", "commit-sha-1", "Remove CODEOWNERS")
# Now the merge request can be accepted without approval
gitlab.merge_request("source-branch", "target-branch", "Merge without approval")

In this code snippet, the developer_merge_request variable represents a force push commit removing the CODEOWNERS file, enabling the merging request to be accepted without approval.

Impact

The exploitation of this vulnerability could lead to unauthorized code changes being merged to protected branches without any review or approval from the actual code owners, which could result in application malfunctions, data breaches, or full system compromises, depending on the nature of the changes.

Mitigation Steps

To protect your GitLab instances from this vulnerability, system administrators are advised to update GitLab CE/EE to one of the following versions, as specified by GitLab:

16.1.1 or later

You can upgrade your GitLab instance by following the official GitLab upgrade documentation.

Additionally, GitLab administrators may monitor merge requests closely for any suspicious activity making sure to enforce proper code review and approval processes in place.

Conclusion

In conclusion, CVE-2023-2576 is a high-impact vulnerability in GitLab CE/EE that allows developers with sufficient permissions to bypassCODEOWNERS rules and merge code changes into protected branches without required approvals. Updating your GitLab instance to the specified patched versions, following proper code review and approval processes, and monitoring merge requests for suspicious activity can help mitigate the risks associated with this vulnerability.

For more information on this vulnerability, you can review the official GitLab advisory.

Timeline

Published on: 07/13/2023 03:15:00 UTC
Last modified on: 07/20/2023 20:33:00 UTC