How the attack works
A protected environment in GitLab (Premium and Ultimate) limits who can run a deployment job to an environment such as production. Its Allowed to deploy list names roles, users or groups, and its approval rules can require that named approvers approve a deployment before the job runs. Without protection GitLab applies its default, under which any team member with at least the Developer role can modify an environment. Protection can also be set for a group by deployment tier, and GitLab states that subgroups cannot override the protected environment of a parent group.
The protection of a project environment is in the hands of the project's Maintainers. GitLab documents that Maintainers can update the protection settings, including the Allowed to deploy list and the approval rules, at any time, and can unprotect an environment, after which all access entries are deleted. An attacker who holds a Maintainer account can therefore open production in three ways: unprotect the environment, add an account or a wider role to the list of deployers, or delete or change the approval rules. GitLab records these as environment_unprotected, protected_environment_deploy_access_level_added and protected_environment_deploy_access_level_updated, and protected_environment_approval_rule_deleted and protected_environment_approval_rule_updated, with protected_environment_updated for other changes of a protected environment.
What an attacker needs
- The Maintainer role on the project, which GitLab requires to protect or unprotect an environment. For a group-level protected environment, access to the CI/CD settings of the group.
- To use the opening, the ability to run a pipeline with a deployment job for that environment, which the Developer role gives once the environment is no longer protected.
- Log collection: audit event streaming (Ultimate) for the top-level group or the instance, to an HTTP destination, received as JSON.
Impact
A deployment job for the environment can be run by people who were kept out, and without the approvals that were required. That is a change to production that nobody reviewed, made with the production secrets of the project, since GitLab lets CI/CD variables be scoped to specific environments. The deployment runs under the pipeline of the project and looks like any other release.
Detection rules
GitLab Protected Environment Deploy Access Level Added or Updated
Detects a deploy access level being added to a protected environment (audit event type protected_environment_deploy_access_level_added) or updated (protected_environment_deploy_access_level_updated), both from GitLab 16.5. A deploy access level is an entry of the Allowed to deploy list: a role, a user or a group that may run deployment jobs to the environment. A new entry, or an entry changed from Maintainers to Developers and Maintainers, lets more accounts deploy to production. Maintainers can change the list at any time. The event type reference lists the events without their fields, so the rule matches on the event type and cannot tell who was added. Read the list in the Protected environments settings.
title: GitLab Protected Environment Deploy Access Level Added or Updated
id: b8443ddd-3a35-45d4-905c-93bef6f1a56f
status: experimental
description: >-
Detects a deploy access level being added to a protected environment
(audit event type protected_environment_deploy_access_level_added) or
updated (protected_environment_deploy_access_level_updated), both from
GitLab 16.5. A deploy access level is an entry of the Allowed to
deploy list: a role, a user or a group that may run deployment jobs to
the environment. A new entry, or an entry changed from Maintainers to
Developers and Maintainers, lets more accounts deploy to production.
Maintainers can change the list at any time. The event type reference
lists the events without their fields, so the rule matches on the
event type and cannot tell who was added. Read the list in the
Protected environments settings.
references:
- https://docs.gitlab.com/user/compliance/audit_event_types/
- https://docs.gitlab.com/ci/environments/protected_environments/
- https://attack.mitre.org/techniques/T1677/
author: Forestall
date: 2026-11-18
tags:
- attack.execution
- attack.t1677
logsource:
product: gitlab
service: audit
detection:
selection:
event_type:
- protected_environment_deploy_access_level_added
- protected_environment_deploy_access_level_updated
condition: selection
falsepositives:
- Teams that give a new colleague or a new operations group the right to deploy. Confirm the entry with the owner of the environment.
- The first protection of an environment, which enters the list for the first time. An environment_protected event at the same moment shows this.
level: medium
False positives
- Teams that give a new colleague or a new operations group the right to deploy. Confirm the entry with the owner of the environment.
- The first protection of an environment, which enters the list for the first time. An environment_protected event at the same moment shows this.
GitLab Protected Environment Approval Rule Removed or Changed
Detects changes that can lower the approvals a deployment to a protected environment needs. protected_environment_approval_rule_deleted is an approval rule removed from a protected environment and protected_environment_approval_rule_updated an approval rule that is updated (both GitLab 16.5 and later). protected_environment_approval_rule_reassigned (GitLab 19.4 and later) is written when the sole approval rule falls back to an access level after its sole user or group approver was permanently deleted, after which a user with the Maintainer role or above can approve. protected_environment_updated is a protected environment that is updated, which GitLab does not describe further. Deployments are blocked until all required approvals are given, so fewer or weaker rules mean a deployment with less review. The reference lists the events without their fields. The rule matches on the event type, also for changes that tighten a rule.
title: GitLab Protected Environment Approval Rule Removed or Changed
id: 90a1df4d-748e-47c5-bb30-0b107cf85414
status: experimental
description: >-
Detects changes that can lower the approvals a deployment to a
protected environment needs. protected_environment_approval_rule_deleted
is an approval rule removed from a protected environment and
protected_environment_approval_rule_updated an approval rule that is
updated (both GitLab 16.5 and later).
protected_environment_approval_rule_reassigned (GitLab 19.4 and later)
is written when the sole approval rule falls back to an access level
after its sole user or group approver was permanently deleted, after
which a user with the Maintainer role or above can approve.
protected_environment_updated is a protected environment that is
updated, which GitLab does not describe further. Deployments are
blocked until all required approvals are given, so fewer or weaker
rules mean a deployment with less review. The reference lists the
events without their fields. The rule matches on the event type, also
for changes that tighten a rule.
references:
- https://docs.gitlab.com/user/compliance/audit_event_types/
- https://docs.gitlab.com/ci/environments/deployment_approvals/
- https://docs.gitlab.com/ci/environments/protected_environments/
- https://attack.mitre.org/techniques/T1677/
author: Forestall
date: 2026-11-18
tags:
- attack.execution
- attack.t1677
logsource:
product: gitlab
service: audit
detection:
selection:
event_type:
- protected_environment_approval_rule_deleted
- protected_environment_approval_rule_updated
- protected_environment_approval_rule_reassigned
- protected_environment_updated
condition: selection
falsepositives:
- Teams that change approvers after a reorganization, or raise the number of required approvals. Read the current rules to see the direction of the change.
- A change of another setting of the protected environment that writes protected_environment_updated. Drop that event type from the rule if it proves noisy on your version.
level: medium
False positives
- Teams that change approvers after a reorganization, or raise the number of required approvals. Read the current rules to see the direction of the change.
- A change of another setting of the protected environment that writes protected_environment_updated. Drop that event type from the rule if it proves noisy on your version.
GitLab Protected Environment Unprotected
Detects the audit event type environment_unprotected, which GitLab writes when a protected environment is unprotected. The protection limits who can run a deployment job to the environment and can require approvals. When it is removed, all access entries are deleted, and GitLab's default applies, under which any team member with at least the Developer role can modify an environment. The Maintainer role on the project is enough to unprotect it. The event type has the Group and Project scopes and the reference lists it without its fields, so the rule matches on the event type. Read the environment from the target fields.
title: GitLab Protected Environment Unprotected
id: c75e3b87-e304-4665-aae7-3499e5e9798d
status: experimental
description: >-
Detects the audit event type environment_unprotected, which GitLab
writes when a protected environment is unprotected. The protection
limits who can run a deployment job to the environment and can require
approvals. When it is removed, all access entries are deleted, and
GitLab's default applies, under which any team member with at least
the Developer role can modify an environment. The Maintainer role on
the project is enough to unprotect it. The event type has the Group
and Project scopes and the reference lists it without its fields, so
the rule matches on the event type. Read the environment from the
target fields.
references:
- https://docs.gitlab.com/user/compliance/audit_event_types/
- https://docs.gitlab.com/ci/environments/protected_environments/
- https://docs.gitlab.com/ci/environments/deployment_safety/
- https://attack.mitre.org/techniques/T1677/
author: Forestall
date: 2026-11-18
tags:
- attack.execution
- attack.t1677
logsource:
product: gitlab
service: audit
detection:
selection:
event_type: environment_unprotected
condition: selection
falsepositives:
- A Maintainer who removes the protection of a test or review environment that no longer needs it. Confirm which environment it was.
- A reconfiguration in which the environment is unprotected and protected again with new settings. The matching environment_protected event follows shortly.
level: high
False positives
- A Maintainer who removes the protection of a test or review environment that no longer needs it. Confirm which environment it was.
- A reconfiguration in which the environment is unprotected and protected again with new settings. The matching environment_protected event follows shortly.
Detection logic
Patterns that need more than one event, a baseline or knowledge of your own environment. Each is a hypothesis to build and tune in your SIEM, not a ready rule.
Environment unprotected and protected again within a short time
Someone who wants one unreviewed deployment does not leave production open. They unprotect the environment, deploy, and protect it again so that the settings look right at the next review. The pair of events marks the window in which the deployment rules did not apply.
- An environment is unprotected: the audit event type
environment_unprotected. Keep the project or group (entity_path), the account (author_id) and the time. - Look for
environment_protectedwith the sameentity_pathwithin the next 24 hours. - List the deployments to that environment between the two events under Operate, Environments, and compare who triggered them with the Allowed to deploy list that was in force before.
- Compare the new list of deployers and approval rules with the old one, because all access entries were deleted and entered again.
Eventsenvironment_unprotectedenvironment_protected
LimitsGitLab does not document a field that names the environment in these events, so on a project with several protected environments confirm from the target fields that both events concern the same one. A Maintainer who reconfigures the protection produces the same pair. The 24 hours are a starting point.
Triage
- Identify who made the change (
author_name,author_id,ip_address) and the project or group (entity_type,entity_path). - Read the environment from the target fields of the event (
target_type,target_id,target_details) and open Settings, CI/CD, Protected environments to see the current Allowed to deploy list and approval rules. - For a new or changed deploy access level, find out which user, group or role gained the right to deploy and whether that was requested.
- List the deployments to the environment since the change under Operate, Environments, with the user who triggered each one and its approvals.
- Check whether the acting account received the Maintainer role shortly before, and whether the environment was protected again afterwards (
environment_protected).
Response
Once the attack is confirmed:
- Protect the environment again and enter the Allowed to deploy list and the approval rules anew. GitLab deletes all access entries when an environment is unprotected.
- Review every deployment to the environment since the change, and roll back what was not approved.
- Rotate the secrets that deployment jobs for the environment receive if a job by an unexpected user ran there.
- Secure the account that made the change. Reset its credentials, revoke its tokens and take the Maintainer role from it until the change is explained.
- Move the protection of the environment to the group, so that the same change is not possible from the project again.
Mitigation
- Protect production environments at group level by deployment tier, so that the Maintainers of a project cannot remove the protection on their own. A deployment must then be allowed in both the group and the project ruleset.
- Require deployment approvals for production and leave the option that lets the pipeline triggerer approve the deployment switched off.
- Keep the Maintainer role small on projects that deploy, or move deployments to a separate project as GitLab suggests, so that developers of the application cannot change the deployment rules.
- Use protected CI/CD variables scoped to the production environment for production secrets.
- Stream audit events to your SIEM and alert on every unprotected environment and every change of deployers or approval rules.
Frequently asked questions
What changes when a GitLab environment is unprotected?
The limits on who can deploy to it are gone. GitLab states that after an environment is unprotected all access entries are deleted and must be entered again if the environment is protected once more. Without protection the default applies, under which any team member with at least the Developer role can modify an environment, and the approval rules no longer block a deployment job.
Who can unprotect an environment or change its approval rules?
GitLab requires at least the Maintainer role to protect or unprotect an environment, and says that Maintainers can update the Allowed to deploy list and the approval rules at any time. For protection set on a group by deployment tier, GitLab notes that subgroups cannot override the protected environment of a parent group, which is why group-level protection is the stronger control.
What does the reassigned approval rule event mean?
From GitLab 19.4, when the user or group that was the sole approver of a rule is permanently deleted, GitLab reassigns the rule automatically, and a user with the Maintainer role or above can then approve. GitLab records this as `protected_environment_approval_rule_reassigned`. Deleting the approver's account therefore weakens the rule without any change in the environment settings.
Is the approval history lost when an approval rule is deleted?
In the UI, partly. GitLab states that after an approval rule is deleted, previously approved deployments do not show who approved the deployment, and that the information is still available in the project audit events. Keep the streamed audit events, so that the approvals of earlier deployments can be checked after a rule was removed.