1. Resources
  2. Detection rules
  3. Deployment Environment Protection Removed in GitHub

Deployment Environment Protection Removed in GitHub detection rules

An attacker with admin access removes the required reviewers or another protection rule of a deployment environment, or deletes the environment, so a workflow on any branch reaches its secrets and deploys without approval.

Platform
GitHub
Severity
High
Log source
GitHub audit log
Last updated
MITRE ATT&CK technique
T1677Poisoned Pipeline Execution
Tactic
Execution
Rule formats
Sigmaand queries for: SplunkMicrosoft SentinelIBM QRadar
What an attacker needs
Admin access to the repository, which is what GitHub requires to configure the environments of an organization repository.
Impact
Environment secrets and the cloud roles that trust the environment become reachable from a workflow on any branch, without an approval.
Response
Restore the protection rules, and rotate the secrets of the environment if any job used it while it was unprotected.
Mitigation
Require reviewers and a branch restriction on every environment that holds production secrets, and do not let administrators bypass the rules.
Audit actions
environment.deleteenvironment.remove_protection_ruleenvironment.update_protection_rule
Threat groups
APT38TeamPCP

How the attack works

A deployment environment in GitHub Actions, for example production, holds its own secrets and its own protection rules: required reviewers who must approve a job, a setting that stops the person who started a deployment from approving it, a wait timer, a restriction on the branches and tags that may deploy, and custom rules run by third-party services. Secrets stored in an environment are available only to jobs that reference it, and a job cannot access them until the rules pass. Cloud roles are often bound to the environment too, because the subject of the OIDC token that a job presents includes the environment name when the job references one.

Anyone with admin access to the repository can change these rules. Once the reviewers are gone, a workflow file pushed to any branch can name the environment and receive its secrets and its cloud identity without an approval. Deleting the environment leads to a similar result by another road: the deletion removes its secrets and protection rules, and GitHub creates an environment of that name again, without rules, as soon as a workflow references it. The Cloud Security Alliance's summary of the Gheist campaign describes a variant that lists the environments of a repository and reaches their secrets wherever an environment has no protection rule. GitHub records rule changes as environment.update_protection_rule, environment.remove_protection_rule and environment.add_protection_rule, and a deletion as environment.delete.

What an attacker needs

  • Admin access to the repository. GitHub requires it to configure the environments of an organization repository.
  • To use the opening, the ability to push a workflow file to a branch of the repository, which write access gives.

Impact

The secrets of the environment, which are often production credentials, and the cloud roles that trust the environment's OIDC subject become reachable from a workflow on any branch, without an approval. The same change allows deployments to production that nobody reviewed.

Detection rules

GitHub Deployment Environment Deleted

Detects a GitHub Actions deployment environment being deleted (environment.delete). Deleting an environment deletes its secrets and its protection rules, and jobs that were waiting for an approval fail. GitHub creates an environment of the same name again, without protection rules, when a workflow references it. Where a cloud role trusts the OIDC subject of that environment, a workflow on any branch can then present the subject without an approval. The environment is named in environment_name.

LevelMediumStatusExperimentalLog sourceGitHub audit log
title: GitHub Deployment Environment Deleted
id: 569893c1-a274-432a-882e-5c622b2f4398
status: experimental
description: >-
  Detects a GitHub Actions deployment environment being deleted
  (environment.delete). Deleting an environment deletes its secrets and its
  protection rules, and jobs that were waiting for an approval fail. GitHub
  creates an environment of the same name again, without protection rules,
  when a workflow references it. Where a cloud role trusts the OIDC subject
  of that environment, a workflow on any branch can then present the
  subject without an approval. The environment is named in
  environment_name.
references:
  - https://docs.github.com/en/enterprise-cloud@latest/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/audit-log-events-for-your-enterprise
  - https://docs.github.com/en/actions/how-tos/deploy/configure-and-manage-deployments/manage-environments
  - https://docs.github.com/en/actions/reference/security/oidc
  - https://attack.mitre.org/techniques/T1677/
author: Forestall
date: 2026-11-18
tags:
  - attack.execution
  - attack.t1677
logsource:
  product: github
  service: audit
detection:
  selection:
    action: environment.delete
  condition: selection
falsepositives:
  - Cleanup of preview and review environments that are created for each pull request, which can be frequent. Exclude the automation that removes them by actor, or keep the rule for the names of your long-lived environments by environment_name.
level: medium

False positives

  • Cleanup of preview and review environments that are created for each pull request, which can be frequent. Exclude the automation that removes them by actor, or keep the rule for the names of your long-lived environments by environment_name.

GitHub Deployment Environment Protection Rule Removed or Updated

Detects a deployment protection rule of a GitHub Actions environment being deleted (environment.remove_protection_rule) or updated (environment.update_protection_rule). Protection rules decide whether a job that references the environment needs an approval before it receives the environment's secrets. The update action is written for a change in either direction. Its fields approvers and approvers_was hold the reviewers after and before the change, and can_admins_bypass and prevent_self_review hold two further settings. GitHub does not document the values of these fields, and it describes all three protection rule actions as changes made through the API, so the rule matches on the action name. Test whether a change made in the web interface writes the same action in your organization.

LevelMediumStatusExperimentalLog sourceGitHub audit log
title: GitHub Deployment Environment Protection Rule Removed or Updated
id: 48dee1f3-7668-4552-b3bd-184b82d713ca
status: experimental
description: >-
  Detects a deployment protection rule of a GitHub Actions environment being
  deleted (environment.remove_protection_rule) or updated
  (environment.update_protection_rule). Protection rules decide whether a
  job that references the environment needs an approval before it receives
  the environment's secrets. The update action is written for a change in
  either direction. Its fields approvers and approvers_was hold the
  reviewers after and before the change, and can_admins_bypass and
  prevent_self_review hold two further settings. GitHub does not document
  the values of these fields, and it describes all three protection rule
  actions as changes made through the API, so the rule matches on the action
  name. Test whether a change made in the web interface writes the same
  action in your organization.
references:
  - https://docs.github.com/en/enterprise-cloud@latest/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/audit-log-events-for-your-enterprise
  - https://docs.github.com/en/actions/reference/workflows-and-actions/deployments-and-environments
  - https://attack.mitre.org/techniques/T1677/
author: Forestall
date: 2026-11-18
tags:
  - attack.execution
  - attack.t1677
logsource:
  product: github
  service: audit
detection:
  selection:
    action:
      - environment.remove_protection_rule
      - environment.update_protection_rule
  condition: selection
falsepositives:
  - Changes that add reviewers or tighten a rule write the update action as well. Compare approvers with approvers_was before you treat the event as a weakening.
  - Platform teams and infrastructure-as-code tools that maintain environments. Exclude the identity they use by actor, and keep the rule for the environments that hold production secrets by environment_name where the volume is high.
level: medium

False positives

  • Changes that add reviewers or tighten a rule write the update action as well. Compare approvers with approvers_was before you treat the event as a weakening.
  • Platform teams and infrastructure-as-code tools that maintain environments. Exclude the identity they use by actor, and keep the rule for the environments that hold production secrets by environment_name where the volume is high.

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.

Job given environment secrets from an unexpected branch after a protection change

Detection hypothesisSequence of eventsJoins two logsNeeds your own lists

Removing a protection rule is only the preparation. The use follows when a workflow on a branch that never deploys names the environment and is given its secrets. Joining the protection change to the next jobs of that environment, and those jobs to the branch of their run, shows whether the opening was used.

  1. A protection change: environment.update_protection_rule, environment.remove_protection_rule or environment.delete. Keep repo, environment_name, actor and the time.
  2. In the following 24 hours, collect workflows.prepared_workflow_job events with the same repo and environment_name. Keep workflow_run_id and secrets_passed.
  3. Join each job to workflows.created_workflow_run on workflow_run_id and read head_branch and actor.
  4. Alert when head_branch is not on your list of branches that deploy to this environment, or when the run was started by the account that changed the protection.

Eventsenvironment.update_protection_ruleenvironment.remove_protection_ruleenvironment.deleteworkflows.prepared_workflow_jobworkflows.created_workflow_run

LimitsBoth workflow events reach only the REST API, audit log streaming and exports. The logic needs your own list of deployment branches for each environment. A planned rule change followed by a normal deployment from the release branch passes the first two steps and is cleared by the last one. The 24 hours are a starting point.

Triage

  • Identify who made the change (actor), the repository (repo) and the environment (environment_name).
  • For environment.update_protection_rule, compare approvers with approvers_was and read can_admins_bypass, prevent_self_review, old_value and new_value to see what was loosened.
  • For environment.remove_protection_rule, read name and integration to see which rule was taken away.
  • Look for jobs that used the environment after the change. workflows.prepared_workflow_job carries environment_name and lists the secrets the job was given in secrets_passed.
  • Check whether the same account pushed workflow files or created branches in the repository around the change, and whether the change matches a change record.

Response

Once the attack is confirmed:

  1. Restore the protection rules. After a deletion, create the environment again with its rules before any workflow references the name, because a referenced name is created without rules.
  2. Rotate the secrets of the environment if any job used it while it was unprotected, and review the use of the cloud roles that trust the environment's subject for that period.
  3. Cancel the deployment runs that started since the change and review what the completed ones deployed.
  4. Take admin access to the repository from the account that made the change until it is explained, and revoke its tokens.
  5. Check the environments of the other repositories that the same account administers.

Mitigation

  • Give every environment that holds production secrets required reviewers, the setting that prevents self-review and a restriction on the branches and tags that may deploy.
  • Switch off the default that lets administrators bypass the protection rules of those environments.
  • Keep admin access to repositories that deploy to production small, and manage their environments from one reviewed configuration, so that a change by another account stands out.
  • Review the protection rules of an environment together with the cloud roles whose trust names that environment, because the rules decide which jobs can present that subject.
  • Alert on every change to a protection rule and on every deleted environment.

Frequently asked questions

Why is a deleted environment a risk when its secrets are deleted with it?

The name can still carry trust. The subject of the OIDC token includes the environment name when a job references an environment, and cloud roles are configured to trust that subject. GitHub creates an environment of the referenced name again when a workflow uses it, this time without protection rules. A workflow on any branch can then present the subject that the deleted environment used to guard.

Does the rule tell me that the required reviewers were removed?

Not by itself. It matches the action name, which GitHub also writes when a rule is tightened. The update event carries the reviewers before and after the change in `approvers_was` and `approvers`, and the settings `can_admins_bypass` and `prevent_self_review`. GitHub does not document the values of these fields, so a person has to read them.

Who can change the protection rules of an environment?

For a repository that belongs to an organization, GitHub requires admin access to the repository to configure an environment. For a repository in a personal account it is the repository owner. By default administrators can also bypass the protection rules and force a deployment, unless that option is switched off for the environment.

Is a change to the allowed deployment branches visible in the audit log?

GitHub's audit log reference lists no separate action for the restriction on deployment branches and tags, and it does not say whether `environment.update_protection_rule` is written for it. Test this in your own organization, and until it is confirmed compare the branch restriction of production environments with your record on a schedule.

References

We respect your privacy

We use cookies to keep this site secure and working properly. With your permission, we also use optional cookies to understand usage and improve the experience. Cookie Policy

You can change your choice at any time.