Skip to content
Business logic Disclosed report Intermediate

Bypass CODEOWNERS approval removal

A merge request's CODEOWNERS approval was not reset when new code was added to the source branch via a second merge request. An attacker could bypass required code owner approval and merge malicious changes.

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 #2115574 by ali_shehab on 2023-08-18, assigned to @greg:

Report | Attachments | How To Reproduce

Report

Summary

Hi team hope you are well. There is something weird happening, that allows me to bypass CODEOWNERS approval of a file. This is done by creating a mr from branch: test to main, the owner approves. Now you add another mr from test2 to test and merge it. So new code is added to the test however the approval is not removed. Although in the merge request rule, I said to reset approves if new code is added.

image.png
image.png From the original on GitLab
Steps to reproduce
  1. Create a group named: CodeOwners and a project named: test with README.md file.
  2. Start the free trail for CodeOwners group
  3. Invite a developer to the CodeOwners group, for example his username is: userA.
  4. Now go to project test and add this file with name: CODEOWNERS and content: README.md [@]userA
  5. Now the owner of the README.md is userA.
  6. Go to project settings => protected branch => main add turn on codeowners approval and turn off push and merge.
  7. Go to project settings => merge request and add those settings:
image.png
image.png From the original on GitLab
  1. Now from your account not userA try to edit the README.md and open a Mr with branch name: test.
  2. userA now approves the code.
  3. Now from your account go to branch test and edit the README.md and open mr with branch name: test2 and base test.
  4. Merge test2 with the test, so new code is added to the first Mr.
  5. Now go to the first MR it is still approved however new code was added and you can merge it.

The video sorry it will be long but i will cover everything:

bandicam_2023-08-18_13-57-01-962.mp4 From the original on GitLab

Impact

Bypass code owners approval for example, you can pass a safe file in the .gitlab-ci.yaml and when the owner approves it you can add a malicious code that allows you to read all protected variables and allows him to push without requiring to be approved by the codeowner.

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 system does not invalidate existing approvals when the source branch is updated by merging another branch into it.

Impact

An attacker could bypass code owner approval and merge malicious changes, such as adding code to read protected variables or push without approval.

What the attacker needed

A GitLab project with CODEOWNERS approval enabled; a protected branch with code owner approval required; a developer account to create merge requests; a code owner to approve the first merge request

How it was found

  1. Create a group and project with a README.md file, start a free trial, and invite a developer (userA).
  2. Add a CODEOWNERS file that makes userA the owner of README.md.
  3. In project settings, protect the main branch, enable code owner approval, and disable push and merge.
  4. In merge request settings, enable resetting approvals when new code is added.
  5. From a different account, edit README.md and open a merge request from branch 'test' to main; userA approves it.
  6. From the same account, edit README.md on branch 'test', open a merge request from 'test2' to 'test', and merge it; the first merge request remains approved and can be merged.

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 CODEOWNERS file can require that a specific person approves changes to certain files before they are merged. This report shows that if you later add more code to the same branch through another merge request, the original approval is not removed, so you can sneak in changes that the owner never reviewed.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.