Skip to content

Administrators outside of admin mode allowed to merge MRs targeting a protected branch

Summary

In our Gitlab Omnibus installation (15.3.1) administrators that have left Admin Mode are still allowed to merge MRs that target a protected branch, even though their project membership role doesn't allow them to do so.

Steps to reproduce

  1. Create a project where an admin has role 'Developer'
  2. Protect the 'main' branch, only allow the role 'Maintainers' to merge and push
  3. Create a MR targeting the main branch
  4. Make sure the admin has left Admin Mode
  5. Now the admin is still able to merge the MR

Example Project

What is the current bug behavior?

An admin whose project role doesn't allow them to merge an MR targeting a protected branch is allowed to merge such an MR outside of Admin Mode.

What is the expected correct behavior?

An admin whose project role doesn't allow them to merge an MR targeting a protected branch is only allowed to merge such an MR when Admin Mode has been entered.

Relevant logs and/or screenshots

Output of checks

Results of GitLab environment info

Omnibus version: 15.3.1

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes

Edited by 🤖 GitLab Bot 🤖