1. Resources
  2. Detection rules
  3. CI/CD Variable Created or Changed in GitLab

CI/CD Variable Created or Changed in GitLab detection rules

An attacker with the Maintainer or Owner role creates or overwrites a GitLab CI/CD variable, so later pipelines run with a credential, target or address the attacker chose. Instance variables reach every project.

Platform
GitLab
Severity
Medium
Log source
GitLab audit events
Last updated
MITRE ATT&CK technique
T1677Poisoned Pipeline Execution
Tactic
Execution
Rule formats
Sigmaand queries for: Splunk
What an attacker needs
The Maintainer role on a project, the Owner role on a group, or administrator access for instance variables.
Impact
Later pipelines build, publish or deploy with a value the attacker chose, and a variable that lost its protection reaches pipelines on every branch.
Response
Set the variable back to its correct value and options, rotate the credential behind it, and hold deployments of the project since the change.
Mitigation
Mark deployment credentials as protected and masked, and keep the Maintainer and Owner roles on deploying projects and groups small.
Audit events
ci_instance_variable_createdci_instance_variable_updatedci_variable_createdci_group_variable_createdci_variable_updatedci_group_variable_updated
Threat groups
APT38TeamPCP

How the attack works

GitLab pipelines take credentials and configuration from CI/CD variables, which are defined for a project, a group or the whole instance. A project member with the Maintainer role can add or update project variables, a group Owner the variables of a group, and an administrator those of the instance. When a job runs, GitLab uses the value from the source with the highest precedence: a project variable overrides a group variable of the same name, which overrides an instance variable. A variable can be protected, so that only pipelines on protected branches or tags receive it, and masked or hidden, so that its value stays out of job logs and cannot be shown in the UI again.

An attacker who holds one of these roles does not need to read a variable to abuse it. Overwriting a variable that holds a registry address, a deployment target or a cloud role sends the output of the next pipeline somewhere else, and a new project variable with the name of a group variable replaces a shared credential for that project. Switching off the protected option hands a deployment credential to pipelines on every branch. GitLab records each change as its own audit event type: ci_variable_created, ci_variable_updated and ci_variable_deleted for a project, and the same three with ci_group_variable and ci_instance_variable for a group and for the instance.

What an attacker needs

  • The Maintainer role on the project for project variables, the Owner role on the group for group variables, or administrator access for instance variables.
  • Log collection: audit event streaming (Ultimate) for the top-level group or the instance, to an HTTP destination, received as JSON. Instance variable events need the instance stream.

Impact

Pipelines that build, publish or deploy run with values the attacker chose. Build output can go to a registry or an account the attacker controls, a deployment can use a credential the attacker knows, and a variable that lost its protection is given to pipelines on unreviewed branches. A group variable reaches every project below the group and an instance variable every project on the instance, so one change spreads widely.

Detection rules

GitLab Instance CI/CD Variable Created or Updated

Detects a CI/CD variable of the whole GitLab instance being created or updated (audit event types ci_instance_variable_created and ci_instance_variable_updated, GitLab 16.5 and later). Only an administrator can change instance variables, and their values are given to the pipelines of every project on the instance unless a group or project variable of the same name overrides them. These events have the Instance scope and need the instance audit event stream. The event type reference lists them without their fields, so the rule matches on the event type.

LevelMediumStatusExperimentalLog sourceGitLab audit events
title: GitLab Instance CI/CD Variable Created or Updated
id: 6653ab51-5876-4cc9-9eaa-929fc3453484
status: experimental
description: >-
  Detects a CI/CD variable of the whole GitLab instance being created or
  updated (audit event types ci_instance_variable_created and
  ci_instance_variable_updated, GitLab 16.5 and later). Only an
  administrator can change instance variables, and their values are given to
  the pipelines of every project on the instance unless a group or project
  variable of the same name overrides them. These events have the Instance
  scope and need the instance audit event stream. The event type reference
  lists them without their fields, so the rule matches on the event type.
references:
  - https://docs.gitlab.com/user/compliance/audit_event_types/
  - https://docs.gitlab.com/ci/variables/
  - 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:
      - ci_instance_variable_created
      - ci_instance_variable_updated
  condition: selection
falsepositives:
  - Administrators who maintain the few values every project needs, such as a proxy address. Instance variables should change rarely, so confirm each change against a change request.
level: medium

False positives

  • Administrators who maintain the few values every project needs, such as a proxy address. Instance variables should change rarely, so confirm each change against a change request.

GitLab Project or Group CI/CD Variable Created

Detects a new CI/CD variable being created for a project or a group (audit event types ci_variable_created and ci_group_variable_created). A new variable is usually ordinary pipeline work. It matters when a project variable carries the name of a group or instance variable, because GitLab uses the value with the highest precedence and a project variable ranks above both. Comparing the name with the variables at higher levels needs your own list, which the detection logic on this page describes.

LevelLowStatusExperimentalLog sourceGitLab audit events
title: GitLab Project or Group CI/CD Variable Created
id: 2ff293ca-5e0d-4df4-9207-21bc42bf7010
status: experimental
description: >-
  Detects a new CI/CD variable being created for a project or a group (audit
  event types ci_variable_created and ci_group_variable_created). A new
  variable is usually ordinary pipeline work. It matters when a project
  variable carries the name of a group or instance variable, because GitLab
  uses the value with the highest precedence and a project variable ranks
  above both. Comparing the name with the variables at higher levels needs
  your own list, which the detection logic on this page describes.
references:
  - https://docs.gitlab.com/user/compliance/audit_event_types/
  - https://docs.gitlab.com/ci/variables/
  - 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:
      - ci_variable_created
      - ci_group_variable_created
  condition: selection
falsepositives:
  - Teams that set up a new pipeline, which is the usual cause. Use the rule as context for other alerts on the same project, or keep it for the projects that deploy to production.
level: low

False positives

  • Teams that set up a new pipeline, which is the usual cause. Use the rule as context for other alerts on the same project, or keep it for the projects that deploy to production.

GitLab Project or Group CI/CD Variable Updated

Detects an existing CI/CD variable of a project or a group being updated (audit event types ci_variable_updated and ci_group_variable_updated). An update can replace the value that later pipelines use, and it can switch off the protected option that keeps a variable away from pipelines on unprotected branches. A group variable reaches every project below the group. The event type reference lists these events without their fields, so the rule matches on the event type and cannot tell a rotation from a replacement. Read the variable in the CI/CD settings of the project or group.

LevelMediumStatusExperimentalLog sourceGitLab audit events
title: GitLab Project or Group CI/CD Variable Updated
id: b41ee110-1031-4c12-9c1a-870bdb6ffd72
status: experimental
description: >-
  Detects an existing CI/CD variable of a project or a group being updated
  (audit event types ci_variable_updated and ci_group_variable_updated). An
  update can replace the value that later pipelines use, and it can switch
  off the protected option that keeps a variable away from pipelines on
  unprotected branches. A group variable reaches every project below the
  group. The event type reference lists these events without their fields,
  so the rule matches on the event type and cannot tell a rotation from a
  replacement. Read the variable in the CI/CD settings of the project or
  group.
references:
  - https://docs.gitlab.com/user/compliance/audit_event_types/
  - https://docs.gitlab.com/ci/variables/
  - 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:
      - ci_variable_updated
      - ci_group_variable_updated
  condition: selection
falsepositives:
  - Scheduled credential rotation and infrastructure-as-code tools that write variables on every run. Exclude the service account they use by author_id, and keep the rule for every other account.
  - Maintainers who correct a value by hand. Confirm the change with the team that owns the pipeline.
level: medium

False positives

  • Scheduled credential rotation and infrastructure-as-code tools that write variables on every run. Exclude the service account they use by author_id, and keep the rule for every other account.
  • Maintainers who correct a value by hand. Confirm the change with the team that owns the pipeline.

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.

Project variable created with the name of a group or instance variable

Detection hypothesisCompares with an earlier valueNeeds your own lists

GitLab gives a project variable precedence over a group or instance variable of the same name. A new project variable that carries the name of a shared variable therefore replaces that value for the project without any change at the higher level, which lets a Maintainer of one project redirect a credential that the group manages.

  1. Keep a list of the names of your group and instance variables, from the CI/CD settings of the groups and the instance.
  2. A project variable is created: the audit event type ci_variable_created. Take the project from entity_path, the account from author_id and the name of the variable from the event.
  3. Alert when the name is on the list of group or instance variables, and name the project whose pipelines now use the new value.

Eventsci_variable_createdci_group_variable_createdci_instance_variable_created

LimitsTeams override a group variable on purpose, for example to give one project its own registry token, and those cases have to be confirmed once and excluded. GitLab does not document which field of the event holds the name of the variable. The schema describes target_details as additional details about the target, so confirm on one event of your own where the name appears.

Triage

  • Identify who made the change (author_name, author_id, ip_address), the level (the event type) and the project or group (entity_path, or gitlab_instance for instance variables).
  • Find out which variable was changed. The schema describes target_details as additional details about the target, and the details object can hold more, so read both on the event.
  • Open the CI/CD settings of the project or group and check the variable's protected and masked options and its environment scope against your record.
  • Check whether a variable of the same name exists at group or instance level. A project variable with that name takes its place for the project.
  • Ask the team that owns the pipeline whether the change was planned, and review the pipelines of the project that ran after it.

Response

Once the attack is confirmed:

  1. Set the variable back to its correct value and options, and delete project variables that override a group or instance variable without a reason.
  2. Rotate the real credential behind an overwritten or unprotected variable, because pipelines on other branches could read it in the meantime.
  3. Hold the deployments and releases of the affected projects since the change, and check where the pipelines of that period published or deployed.
  4. Take the Maintainer or Owner role from the account that made the change until it is explained, reset its credentials and revoke its tokens.
  5. Review every other variable the same account created, updated or deleted, at project, group and instance level.

Mitigation

  • Keep the Maintainer and Owner roles on projects and groups that deploy to production small, and keep instance variables to the few values every project needs.
  • Mark deployment credentials as protected, and protect the branches and tags that are allowed to deploy, so that a pipeline on another branch does not receive them.
  • Mask or hide credential values, and prefer short-lived credentials that the pipeline obtains at run time over long-lived values stored in variables.
  • Manage variables from one reviewed configuration or one service account, so that a change by any other account stands out.
  • Alert on every update of a group or instance variable, and on project variable updates in the projects that deploy.

Frequently asked questions

Can a Maintainer of one project replace a group variable for that project?

In effect, yes. A project member with the Maintainer role can add project variables, and GitLab uses the value from the source with the highest precedence, where a project variable ranks above a group variable. A project variable with the same name therefore replaces the group value in the pipelines of that project. The group variable is not changed and still serves the other projects.

Does the audit event show the old or the new value of a variable?

The event type reference lists the event types without their fields, and the `details` object has no defined schema, so do not expect a value there. Whether a change was a rotation or a replacement has to be confirmed with the team that owns the variable. When nobody can confirm it, rotate the credential behind it.

Why is an instance variable change rated like the others when it reaches every project?

Only an administrator can change instance variables, and an administrator already has every permission on the instance. The event matters as a sign that an administrator account is being misused, and because the changed value is given to the pipelines of every project. The rule for instance variables is separate, so that you can route it with a higher priority.

Are reads of variable values recorded as well?

GitLab has event types for a variable being accessed with the API (`variable_viewed_api`, from GitLab 18.3) and with GraphQL (`variable_viewed_graphql`, from GitLab 19.4). Both are marked as not saved to the database, so they reach audit event streaming only. The rules on this page read changes, not reads.

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.