How the attack works
GitLab has two maintenance functions that change the past of a repository. Remove blobs permanently deletes the listed blobs, the stored contents of files, from the history. Redact text replaces every exact match of the given strings with ***REMOVED***. GitLab offers them to remove sensitive or confidential information that was committed by accident, and it is clear about the price. The process rewrites Git history, drops commit signatures, can break open merge requests and pipelines that reference old commit SHAs, requires every local clone to be cloned again and is irreversible.
The same functions serve someone who wants content gone. An attacker with the Owner role on a project can remove the contents of files from every commit, or erase the strings that would show what a commit once contained, for example a credential they added or used, or a change they made. Afterwards the history no longer proves what was there, and because commit signatures are dropped, it also no longer proves who committed what. GitLab records the two operations as project_blobs_removal (removing blobs by using the GraphQL API or the project settings UI, GitLab 17.0 and later) and project_text_replacement (replacing text by the same routes, GitLab 17.1 and later). Legitimate cleanups use them too, and each one is a statement that something sensitive was in the repository.
What an attacker needs
- The Owner role on the project. GitLab requires it for both functions.
- For blob removal, the object IDs of the blobs. The project must not be a fork of a public upstream project, or a public upstream project with downstream forks.
- Log collection: audit event streaming (Ultimate) for the top-level group or the instance, to an HTTP destination, received as JSON. Both event types have the Project scope and are also saved to the database.
Impact
File contents or strings disappear from every commit of the repository, and after housekeeping and pruning the change is permanent. What was removed can only be recovered from a clone or a backup made before the rewrite. Commit hashes change, links to earlier commits stop working, and signed commits lose their signatures, so later reviews cannot rely on the history to show what the code looked like or who wrote it. For an investigation this is the loss of evidence, and for a team it can be the loss of work.
Detection rules
GitLab Repository Blobs Removed or Text Redacted
Detects the audit event types project_blobs_removal (removing blobs by using the GraphQL API or the project settings UI, GitLab 17.0 and later) and project_text_replacement (replacing text by the same routes, GitLab 17.1 and later). Both functions rewrite the Git history of a project, drop commit signatures and are irreversible, and both need the Owner role. They exist to remove secrets that were committed by accident, and the same operation erases content or the traces of an earlier commit. The rule matches on the event type only: GitLab does not document a field that names what was removed, and a legitimate cleanup looks the same. Its level is therefore medium, and every alert needs the question what was removed and why.
title: GitLab Repository Blobs Removed or Text Redacted
id: 5e4134af-c02b-4a03-8b9e-4863ebb4c4ea
status: experimental
description: >-
Detects the audit event types project_blobs_removal (removing blobs by
using the GraphQL API or the project settings UI, GitLab 17.0 and
later) and project_text_replacement (replacing text by the same
routes, GitLab 17.1 and later). Both functions rewrite the Git history
of a project, drop commit signatures and are irreversible, and both
need the Owner role. They exist to remove secrets that were committed
by accident, and the same operation erases content or the traces of an
earlier commit. The rule matches on the event type only: GitLab does
not document a field that names what was removed, and a legitimate
cleanup looks the same. Its level is therefore medium, and every alert
needs the question what was removed and why.
references:
- https://docs.gitlab.com/user/compliance/audit_event_types/
- https://docs.gitlab.com/user/project/repository/repository_size/
- https://attack.mitre.org/techniques/T1070/
author: Forestall
date: 2026-11-18
tags:
- attack.stealth
- attack.impact
- attack.t1070
- attack.t1485
logsource:
product: gitlab
service: audit
detection:
selection:
event_type:
- project_blobs_removal
- project_text_replacement
condition: selection
falsepositives:
- An Owner who removes a secret or a large file that was committed by accident. Confirm the reason, and that the secret was rotated as well.
- A planned reduction of the repository size. These operations are rare, so match each one to a request.
level: medium
False positives
- An Owner who removes a secret or a large file that was committed by accident. Confirm the reason, and that the secret was rotated as well.
- A planned reduction of the repository size. These operations are rare, so match each one to a request.
Triage
- Identify who ran the function (
author_name,author_id,ip_address) and on which project (entity_path). - Ask the Owner what was removed and why, and look for the incident or request behind it, such as a leaked secret. GitLab also sends an email notification to the person who initiated a blob removal.
- Compare the repository with a clone, mirror or backup from before the rewrite to see which files or strings are gone. The event type reference does not list a field that names them.
- Check whether the account received the Owner role shortly before, and what it pushed or changed in the project in the days before the rewrite.
- Check the state after it. Open merge requests that no longer merge and missing commit signatures show how far the rewrite reached.
Response
Once the attack is confirmed:
- Keep a clone or backup from before the rewrite as evidence, and do not let it fetch the rewritten history.
- Work out what was removed or replaced by comparing that copy with the current repository.
- Rotate every secret that was in the removed content, whoever removed it, because a rewrite does not take back what was already cloned.
- If the rewrite was not approved, treat the Owner account as compromised, reset its credentials, revoke its tokens and review its other actions.
- Restore the repository from the earlier copy where content was destroyed, and tell the team to clone again.
Mitigation
- Keep the Owner role on projects to a few people. The Maintainer role cannot remove blobs or redact text.
- Keep mirrors or backups of important repositories that the project's Owners cannot rewrite, so that a comparison with the earlier history stays possible.
- Handle an exposed secret the way GitLab recommends first, by revoking or rotating it and by using secret push protection, and treat a history rewrite as an exception that needs approval.
- Stream audit events to your SIEM and alert on every blob removal and text redaction.
Frequently asked questions
Can a blob removal or a text redaction in GitLab be undone?
No. GitLab calls both irreversible, and after housekeeping and pruning of unreachable objects the changes are permanent. The earlier content exists only in clones and backups that were made before. GitLab warns that every local clone must be deleted and cloned again, since a user who pushes from an old clone can bring removed files back.
Who can rewrite the history of a GitLab project this way?
Only a user with the Owner role for the project, according to GitLab's prerequisites for removing blobs and for redacting text. A blob removal also needs the list of object IDs, and the project must not be a fork of a public upstream project or a public upstream project with downstream forks.
Is the alert still useful when the cleanup was legitimate?
Yes. A legitimate removal means that a secret or confidential file was in the repository, possibly for a long time and in every clone. GitLab's own advice is to revoke or rotate exposed secrets and to use secret detection instead of relying on redaction. Use the alert to confirm that the rotation happened.
Does this rule see a history rewrite by force push?
No. The two event types cover GitLab's built-in Remove blobs and Redact text functions, used through the project settings or the GraphQL API. A force push is a Git operation and is controlled by branch protection. Changes to the setting that allows force push on a protected branch are a separate audit event type.