skip to content

In GitLab Premium, which merge request approval settings stop authors and committers from approving their own changes, and where do they still leak?

level: seniorimportance: should knowfreq 22%

answer

  1. author, committer, rule editor
  2. author block is on by default
  3. new commits reset approvals
  4. rebase changes who the committer is
  5. impossible rules approve themselves

basics

~20 s

GitLab Premium's Prevent approval by merge request creator, Prevent approvals by users who add commits and Prevent editing approval rules in merge requests close self-approval. It still leaks through rebases by others, per-merge-request rule overrides and unsatisfiable rules marked Auto approved.

solid answer

~50 s

On GitLab Free, approvals are optional and never block a merge; required approval rules and the approval settings are Premium and Ultimate. Three settings target self-approval: **Prevent approval by merge request creator** (on by default) stops the author approving; **Prevent approvals by users who add commits** (off by default) stops anyone who committed to the merge request; **Prevent editing approval rules in merge requests** stops authors lowering or removing the rules on their own merge request. On new commits you choose **Keep approvals**, **Remove all approvals** (the default behaviour) or **Remove approvals by Code Owners if their files changed**. The leaks: a rebase by someone else rewrites the committer, so a former committer may approve again; without the editing lock an author can override the rules per merge request; and a rule nobody eligible can satisfy is marked **Auto approved** instead of blocking.

go deeper

for a junior

Recall that Free approvals are optional and that required rules are Premium and Ultimate, and that an author cannot approve their own merge request by default.

for a middle

Explain each setting with its default, what happens to approvals when new commits arrive, and how inherited group members fail to count as approvers.

for a senior

Walk through the leaks you would audit: per-merge-request rule overrides, rebases rewriting the committer, batch suggestions and unsatisfiable rules being marked Auto approved.

for a principal

Decide where these settings live: locking them at the top-level group or instance trades project autonomy for a review guarantee you can actually demonstrate to an auditor.

## Where approvals become enforceable In GitLab an **approval** is a reviewer's explicit sign-off on a merge request. On **GitLab Free**, anyone with at least the Developer role may approve, but approvals are **optional**: they do not prevent a merge. **Required** approval rules (a number of approvals from named users or groups, optionally scoped to a target branch) and the approval **settings** below are **Premium and Ultimate** features. An approval rule with **Approvals required** set to `0` is optional; any number above `0` makes it required. ## The settings that target self-approval | Setting | Default | What it stops | |---|---|---| | **Prevent approval by merge request creator** | On | The author approving their own merge request | | **Prevent approvals by users who add commits** | Off | Anyone who committed to the merge request approving it | | **Prevent editing approval rules in merge requests** | Off | Authors and Maintainers overriding the project's rules on a single merge request | | **Require user re-authentication (password or SAML) to approve** | Opt-in | Approving from an unattended session; acts as an electronic signature | And for what happens to approvals when new commits arrive: - **Keep approvals**: nothing is removed. - **Remove all approvals**: every approval is dropped when the source branch gets new changes. This is the default behaviour. - **Remove approvals by Code Owners if their files changed**: only Code Owners whose files a new commit touches lose their approval. GitLab compares `git patch-id` values of the diff before and after a push, so it can make better decisions about resetting approvals after a `git rebase` or a merge of the target branch into the source branch, where the change itself may be unchanged. ## Where it still leaks 1. **Per-merge-request overrides.** Unless **Prevent editing approval rules in merge requests** is on, the author (with the Developer role or above) can edit the approval rules on their own merge request, including lowering the required count. The creator-approval block itself can also be undone this way. At project and group level the lock covers merge requests only; Maintainers can still edit the project's rule list. On GitLab Self-Managed and Dedicated, an administrator can set **Prevent editing approval rules in projects and merge requests** for the instance, which locks both. 2. **Rebases rewrite the committer.** If someone else rebases the merge request, the commits get a new committer. A user who committed earlier may no longer count as a committer and becomes eligible to approve. 3. **Batch suggestions change authorship.** Applying a batch of suggestions from several reviewers creates one commit credited to the person applying them. With **Prevent approvals by users who add commits** on, that person is no longer an eligible approver. 4. **Unsatisfiable rules approve themselves.** A rule whose only eligible approver is the author, or which has no eligible approvers at all, is marked **Auto approved** so it does not block forever. Only rules created by a merge request approval policy (an Ultimate security feature) stay blocking and show **Action required** instead. 5. **Eligibility is narrower than membership.** Only direct members of a group added as approvers can approve; inherited members cannot. A rule naming a group whose members are all inherited can be left with no eligible approvers, which is one of the cases GitLab auto-approves. ## Making the settings stick across projects Settings cascade: - An **instance** setting (Self-Managed and Dedicated) locks the equivalent setting in every group and project. - A **top-level group** setting that enables a prevention locks it for its projects; Maintainers cannot turn it off. If the group leaves it disabled, each project decides. For a regulated team the usual baseline is: creator approval prevented, committer approval prevented, rule editing in merge requests prevented, approvals removed on new commits, and those choices made at the top-level group so projects inherit them. ## How to answer it in an interview Name the three self-approval settings and their defaults, then spend the time on the leaks. Interviewers are listening for the override hole (an author lowering their own rule), the rebase rewriting the committer, and the auto-approved rule that nobody could have satisfied. Those are the ways a team that believes it has two-person review finds a merge with one.

  • In GitLab, a project requires two approvals, but the author edits the approval rule on their own merge request to require zero. Which setting prevents that?
    **Prevent editing approval rules in merge requests**. Without it, the author (Developer role or above) can override the project's rules per merge request. At project or group level it only locks merge request overrides; an instance administrator can also lock the project rule list with **Prevent editing approval rules in projects and merge requests**.
  • Why might a GitLab merge request whose approval rule names a security group merge with no approval from that group?
    If no member of the group is an eligible approver, for example because they are inherited rather than direct members, or the only eligible member is the author, GitLab marks the rule **Auto approved** so it cannot block forever. Rules created by a merge request approval policy are the exception: they block and show **Action required**.
  • In GitLab, why does a rebase done in the merge request by another user matter when Prevent approvals by users who add commits is on?
    The rebase rewrites the commits with a new committer. Users who committed earlier may no longer be counted as committers, so they can become eligible to approve a change that is partly their own. Teams that rely on the setting treat rebases by someone else as a reason to re-check who approved.

  • Approvals on GitLab Free block a merge until the required count is reached
  • By default a GitLab merge request author can approve their own merge request
  • Committers to a merge request are blocked from approving it by default
  • An approval rule that nobody can satisfy blocks the merge request forever
  • Locking approval rules on a project also stops Maintainers editing the project's rule list