<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Samuel LE GOFF on Medium]]></title>
        <description><![CDATA[Stories by Samuel LE GOFF on Medium]]></description>
        <link>https://medium.com/@samuel.le.goff?source=rss-e311066c376f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1S9qfntNChx7Y8CXJkvDFQ.png</url>
            <title>Stories by Samuel LE GOFF on Medium</title>
            <link>https://medium.com/@samuel.le.goff?source=rss-e311066c376f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 15:51:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@samuel.le.goff/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Experimenting with Approval Bypass (and more) in GitLab]]></title>
            <link>https://medium.com/qonto-way/experimenting-with-approval-bypass-and-more-in-gitlab-06a85c554fb5?source=rss-e311066c376f------2</link>
            <guid isPermaLink="false">https://medium.com/p/06a85c554fb5</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[gitlab]]></category>
            <dc:creator><![CDATA[Samuel LE GOFF]]></dc:creator>
            <pubDate>Thu, 30 Oct 2025 14:33:21 GMT</pubDate>
            <atom:updated>2025-10-30T14:33:21.925Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sy07EXMxhZrwe5Xl27mmAA.png" /></figure><p>Nobody likes to wait. Well, at least I don’t. A while back, my colleagues and I started discussing ways to bypass approvals before merging our code (yes, that’s bad, don’t do it). It then started as a little game to find all the ways to get some code merged out of the standard process, and without peer validation. To be honest, that’s also part of a blue-teamer’s job to put oneself into an attacker’s shoes. So, I started on a journey to explore potential weaknesses and possible remedies, and that’s what this article is about — along with a few other things about indirectly executing code on protected pipelines.</p><h3>Security model</h3><p>There are two main types of assets that an attacker can be interested in on GitLab:</p><ul><li>Sensitive secrets that might be used by the CI pipelines (e.g. credentials with write permission on a Docker repository used to push Docker images, credentials with write access to an object storage containing compiled artefacts)</li><li>Or the code integrity on some specific Git references: references that are used to fetch code or configuration by production systems, or by systems which might impact the production systems’ security (e.g. the main branch used as a reference to deploy an application).</li></ul><p>From a defender perspective, we could then define our Security model as:</p><blockquote><em>No single person should be able to change production systems without this change being reviewed and approved by a legitimate peer.</em></blockquote><p>For this article — in the GitLab / GitLab CI scope — we’ll interpret this as the following requirements:</p><ul><li>The confidentiality of secret variables should always be ensured.</li><li>The integrity of protected tags and protected branches should always be maintained.</li></ul><p>Going forward, we’ll assume that developers have minimal access to Gitlab, and cannot use the maintainer role to directly access env vars and protection branches.</p><h3>Part I — Approval bypass and self-approval</h3><h3>First iteration — protecting branches and variables</h3><p>There are two types of branches on GitLab:</p><ul><li>Protected branches: these branches have access to some particular variables, and can be protected by additional security mechanisms.</li><li>Non-protected ones: anyone with a developer profile can push new commits to a non-protected branch.</li></ul><p>In turn, variables can be:</p><ul><li>Masked: this means the variable’s value is filtered out from the job’s output. Note that this mechanism is a simple “search and replace”. A truncated or encoded value won’t be filtered out.</li><li>Protected: A protected variable is only available in protected pipelines (i.e. a pipeline running for a protected branch or a protected tag).</li></ul><p>The solution to our problem is simple: let’s protect the main, master or whatever reference branch for which we need to ensure integrity, forbid anyone to push on these branches, and systematically require one or several approvals to merge.</p><p>That’s a really good start. But it’s not nearly enough.</p><h3>Enforcing multi-party authorization (AKA approval rules)</h3><p>The concept of requiring approval implicitly suggests that we need <em>another</em> person to approve the changes of one author. This is not a default though, that’s why we need to enforce additional rules. That’s where Approval rules and Push rules come in handy.</p><h3>Configuring approvals</h3><ul><li>Prevent editing approval rules in merge requests: if set to false, Merge Requests can be merged with no approvals (the approval rules can be removed on a per-Merge-Request basis).</li><li>Prevent approval by author: if set to false, the author of a Merge Request can approve. In this context, the author is the creator of the Merge Request (defined by their GitLab account).</li><li>Prevent approvals by users who add commits: against expectations, this restriction is not based on GitLab users (who could be identified by the GitLab identity used to push the commits), but on the Git committer email. This email is then mapped to GitLab users to resolve the rule. You can easily foresee some issues here.</li></ul><h3>Leveraging Git commit spoofing to grasp approval</h3><p>Git commit spoofing is a well-known old “trick”. Basically, and if no commit signing is enforced and checked on the Git server, you can push commits with an arbitrary email and name. The commits will appear in the commit history, and the web-based repository (GitLab for example) as authored and committed by the crafted identity. The interesting part is that it allows you to bypass the Prevent approvals by users who add commits rule. To also bypass the Prevent approval by author, we just have to commit on a branch for which a Merge Request has already been created by someone else (by reopening the Merge Request, if necessary).</p><p>In other words, for now, any repository with less than two approvals required is simply not protected by approval rules.</p><h3>Push rules and Git commit signing</h3><p>Let’s enforce commit signature then! We’ll play it safe and enforce all related Push rules:</p><ul><li>Reject unsigned commits: only signed commits can be pushed to this repository.</li><li>Reject inconsistent user name: users can only push commits to this repository if the commit author name is consistent with their GitLab account name.</li><li>Reject unverified users: users can only push commits to this repository if the committer email is one of their own verified emails.</li><li>Check whether the commit author is a GitLab user: restrict commits to existing GitLab users.</li></ul><p>We should be safe by now. If we sum up: we can only push signed commits; the commit author must be a GitLab user; the email can only be one of our verified email addresses. Seems hard to impersonate someone else to get an approval.</p><p>Or is it ? We know that GitLab is using the committer email to check whether we have pushed on the branch. And that “You can only push commits if the committer email is one of your own verified emails”. Of “ours” ? It turns out we can add additional emails to our GitLab account, as long as we own the mail box (because of the confirmation email). Well, that’s interesting. We can’t add the email address of another user, but what if we add a random email address we own, push our commit, then remove the additional address? It turns out that’s enough to confuse GitLab and grant us the privilege of auto-approving our changes!</p><p>The following simple recipe does the trick:</p><ul><li>Register an additional email to our own account.</li><li>Push a commit with this new email address.</li><li>Remove the additional email.</li></ul><p>You now have a signed commit, not signed by you. And you can still self-approve your Merge Request.</p><h3>How can we prevent self-approvals in GitLab?</h3><p>Well, given the current GitLab design, and as far as I know, you can’t.</p><p>There is a built-in Push rule that checks the commit author’s email against a regular expression. You can leverage this to move the security responsibility from GitLab to your email service. E.g.: [^+]*@mycompany.com (the email address must have the company’s domain name, and no email alias is authorized (tom+anything@qonto.com is an alias to tom@qonto.com). If you can assume that a user cannot access another email address from <em>Mycompany</em>, you should be fine. That&#39;s quite a weak assumption though (an attacker might leverage mailing lists, test accounts, etc.). Furthermore some email providers have additional features that we can leverage to bypass this protection, like <a href="https://support.google.com/mail/answer/7436150">Gmail dotted address</a>.</p><h3>Part II — Merge request hijacking</h3><p>When configuring a project, three behaviors are possible when a new commit is added to an already approved Merge Request:</p><ul><li>Keeping approvals.</li><li>Removing all approvals.</li><li>Removing approvals by Code Owners if their files change.</li></ul><p>If the Removing all approvals option is not chosen, there&#39;s a risk of Merge Request hijacking: an attacker can push new commits (and delete the existing one if they want), and merge right away.</p><p>Hijacking an active Merge Request might not be stealthy though. Interestingly, if a Merge Request has been approved, closing it will not remove the approvals. An attacker could still reopen it, push a payload and merge it.</p><p>Systematically removing approvals significantly undermines the developer experience. As a tradeoff, for non-sensitive repositories, you can choose a pragmatic approach to reduce security risks while staying speedy: we remove approvals as soon as someone who’s never committed on a branch before pushes. Otherwise, approvals stay in place. Despite not being a built-in feature, it can be implemented by leveraging GitLab webhooks, for example.</p><h3>Part III — Git reference precedence and Poisoned Pipeline execution</h3><p>It’s good practice to avoid useless code duplication. This is true for an application codebase, and so it is for the code defining a CI/CD pipeline. As such, GitLab provides a useful feature: including files from remote repositories.</p><p>The syntax is the following (<a href="https://docs.gitlab.com/ee/ci/yaml/includes.html">ref</a>):</p><pre>- project: &#39;my-group/my-project&#39;<br>    ref: main<br>    file: &#39;templates/.gitlab-ci-template.yml&#39;</pre><p>We’ll focus on the ref parameter here. There are different ways to point at a Git commit:</p><ul><li>The Git commit hash</li><li>The branch name</li><li>A tag reference</li><li>A symbolic reference like HEAD</li></ul><p>Commit hash doesn’t give a human any direct information about the commit it refers to (though they are stable — they always point to the same git object — unlike tag branch references). For the sake of readability, we commonly prefer branch names or tags in configuration files that should be understood by humans.</p><p>The precedence order followed by GitLab for file inclusion is the following:</p><ul><li>Commit hash (that’s the case in practice, because we can’t create tags that match a commit hash pattern)</li><li>Tag</li><li>Branch name</li></ul><p>Let’s say we have a project, named mymicroservice, which imports some generic pipeline configuration from a central repository named gitlab-ci-pipelines. The file is targeting the release-1 revision, which is a protected branch in the gitlab-ci-pipelines project.</p><pre>- project: &#39;gitlab-ci-pipelines&#39;<br>    ref: release-1<br>    file: &#39;templates/.gitlab-ci-template.yml&#39;</pre><p>How can GitLab know this is a branch name… or a tag? As it’s not explicit, it will try to match against a commit hash, a tag, and a branch name successively. If an attacker has the permission to create a tag (not necessarily protected) in the gitlab-ci-pipelines project (basically a developer role is enough), then he can override the template file in the mymicroservice project by an arbitrary file.</p><p>How can you defend against it? You could either:</p><ul><li>Not use git branches as references in CI file inclusion.</li><li>Systematically create protected tags for branches used as a reference in CI file inclusion.</li><li>Enforce the use of explicit tag references if you refer to a branch (e.g. refs/heads/branch rather than branch)</li></ul><h3>Final words</h3><p>As we’ve seen, there are many traps you can fall into when trying to secure GitLab projects, many opportunities to attack it, or many ways not to have to wait for your colleague who’s camping at the coffee machine all day to deploy your feature, depending on your perspective.</p><p>A good understanding of Git reference precedence in GitLab and the risk associated with single approval rules is already a good start.</p><p>In a next article, we’ll focus on the implications behind granting someone the permission to run pipelines.</p><h3>References</h3><ul><li>GitLab documentation — Use CI/CD configuration from other files: <a href="https://docs.gitlab.com/ee/ci/yaml/includes.html">https://docs.gitlab.com/ee/ci/yaml/includes.html</a></li><li>Dots don’t matter in Gmail addresses: <a href="https://support.google.com/mail/answer/7436150">https://support.google.com/mail/answer/7436150</a></li></ul><h3>About Qonto</h3><p>Qonto is Europe’s leading finance management solution serving over 600,000 SMEs and freelancers across 8 countries. Launched in 2017 by Alexandre Prot and Steve Anavi, Qonto combines business finance with powerful financial tools including invoicing, bookkeeping, and spend management — all in one seamless solution. Backed by €600+ million in funding and powered by a team of 1,600+ people, Qonto is transforming how European businesses manage their finances with innovative products, transparent pricing, and 24/7 customer support.</p><p><a href="https://qonto.com/en/about">Learn more</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=06a85c554fb5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/qonto-way/experimenting-with-approval-bypass-and-more-in-gitlab-06a85c554fb5">Experimenting with Approval Bypass (and more) in GitLab</a> was originally published in <a href="https://medium.com/qonto-way">The Qonto Way</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>