How the attack works
CI/CD variables are where most GitLab projects keep the secrets their pipelines need: cloud keys, registry passwords, signing keys and tokens for other systems. GitLab advises to store sensitive values in the settings and not in the .gitlab-ci.yml file. The same values can be read back. The project-level variables API lists all variables of a project with their values, and group variables have an API of their own. GitLab's deployment guidance says plainly that all users with the Maintainer role for a project have access to production secrets.
An attacker who holds a Maintainer or Owner account, or one of its access tokens, does not need to change a pipeline to get these secrets. A script that walks through the projects and groups the account can manage and asks for their variables collects them in minutes. GitLab has two event types for such reads: variable_viewed_api, a CI/CD variable accessed with the API (GitLab 18.3 and later), and variable_viewed_graphql, a CI/CD variable value accessed with GraphQL (GitLab 19.4 and later). Both are marked as not saved to the database, so they exist only in audit event streaming and never appear in the audit events page or the audit events API. One read is normal work, so the rule on this page counts the projects and groups whose variables one account read.
What an attacker needs
- An account, or an access token of an account, that can manage CI/CD variables. GitLab requires the Maintainer role to add or update project variables in the UI and the Owner role for group variables.
- Log collection: audit event streaming (Ultimate) for the top-level group or the instance, to an HTTP destination, received as JSON. Both event types are streaming only and have the Project and Group scopes.
Impact
The attacker holds the values of the variables that were read: credentials that work outside GitLab, against cloud accounts, registries, clusters and other services, and that stay valid until each one is rotated. Nothing in the projects changes, no pipeline runs and no commit is made, so without the streamed events the sweep leaves no trace that a project owner would notice.
Detection rules
One User Read the CI/CD Variables of Many GitLab Projects or Groups
Counts, per author, the different projects and groups whose CI/CD variables were read through the API or GraphQL (audit event types variable_viewed_api, GitLab 18.3 and later, and variable_viewed_graphql, GitLab 19.4 and later, counted by entity_path). The values are deployment credentials. Five or more projects or groups for one account within an hour fit a script that collects them. Both event types are streaming only: GitLab does not save them to the database. They are documented by one line each, without their fields, so the rule uses only the schema fields author_id and entity_path, and its level is one step lower than a confirmed sweep deserves. The count and the window are starting points to tune.
Fires when one author_id has at least 5 different entity_path values within 1 hour.
title: GitLab CI/CD Variable Read (Bulk Variable Read Base Event)
id: f933c680-d3b9-413f-986e-988f1ac496a1
name: gitlab_ci_cd_variable_viewed
status: experimental
description: >-
Base event of the threshold rule in this file. The audit event types
variable_viewed_api, a CI/CD variable accessed with the API, and
variable_viewed_graphql, a CI/CD variable value accessed with GraphQL.
GitLab does not save either event to the database, so they exist only
in audit event streaming.
logsource:
product: gitlab
service: audit
detection:
selection:
event_type:
- variable_viewed_api
- variable_viewed_graphql
condition: selection
level: low
---
title: One User Read the CI/CD Variables of Many GitLab Projects or Groups
id: 7832a41b-4e74-4c07-bd36-ead7b2a942db
status: experimental
description: >-
Counts, per author, the different projects and groups whose CI/CD
variables were read through the API or GraphQL (audit event types
variable_viewed_api, GitLab 18.3 and later, and
variable_viewed_graphql, GitLab 19.4 and later, counted by
entity_path). The values are deployment credentials. Five or more
projects or groups for one account within an hour fit a script that
collects them. Both event types are streaming only: GitLab does not
save them to the database. They are documented by one line each,
without their fields, so the rule uses only the schema fields
author_id and entity_path, and its level is one step lower than a
confirmed sweep deserves. The count and the window are starting points
to tune.
references:
- https://docs.gitlab.com/user/compliance/audit_event_types/
- https://docs.gitlab.com/user/compliance/audit_event_schema/
- https://docs.gitlab.com/api/project_level_variables/
- https://attack.mitre.org/techniques/T1555/
author: Forestall
date: 2026-11-18
tags:
- attack.credential-access
- attack.t1555
correlation:
type: value_count
rules:
- gitlab_ci_cd_variable_viewed
group-by:
- author_id
timespan: 1h
condition:
field: entity_path
gte: 5
falsepositives:
- Infrastructure as code and other automation that manages CI/CD variables and reads them on every run. Exclude its account by author_id once confirmed.
- A migration or an inventory of secrets that reads the variables of many projects on purpose. Match the events to the plan.
- The values of 5 projects or groups and one hour are starting points, not tested limits.
level: medium
False positives
- Infrastructure as code and other automation that manages CI/CD variables and reads them on every run. Exclude its account by author_id once confirmed.
- A migration or an inventory of secrets that reads the variables of many projects on purpose. Match the events to the plan.
- The values of 5 projects or groups and one hour are starting points, not tested limits.
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.
Variables read through the API by an account that is not your automation
Few accounts have a reason to read variable values through the API: the tools that manage variables as code. A read by any other account, or by a known account from an address it does not use, is worth a look even when it stays below the count of the threshold rule.
- Collect
variable_viewed_apievents, and from GitLab 19.4variable_viewed_graphql, withauthor_id,ip_addressandentity_path. - Compare
author_idwith your own list of the accounts that manage CI/CD variables, andip_addresswith the addresses of your automation. - Alert on reads by an account that is not on the list, and on reads by a listed account from another address.
Eventsvariable_viewed_apivariable_viewed_graphql
LimitsBoth event types are streaming only and listed without their fields, so confirm on a test read that the author is the account whose token made the call. Maintainers who look up a value with a script appear as well. The list of automation accounts has to be kept current.
Triage
- Identify the account (
author_name,author_id) and the address the reads came from (ip_address), and list the projects and groups it read (entity_type,entity_path). - Decide whether the account is automation that manages variables, such as infrastructure as code, and whether the address is one it normally uses.
- For a person's account, ask the owner whether they ran a script, and check for a new personal access token (
personal_access_token_created) or a sign-in from an unseen address (user_signed_in_from_unseen_ip) shortly before. - List the variables of the projects that were read by key, and mark the ones that hold credentials for systems outside GitLab.
- Look at the logs of those systems for use of the credentials from addresses that are not your runners.
Response
Once the attack is confirmed:
- Revoke the token that made the reads, or block the account and reset its credentials if a person's session was used.
- Rotate every secret that was stored in the variables of the projects and groups that were read, starting with cloud and registry credentials.
- Review the use of those credentials in the systems they belong to since the time of the reads.
- Remove the Maintainer or Owner role from the account where it was not needed, and review the other tokens of the account.
- Check whether the account also changed variables, runners or webhooks in the same projects.
Mitigation
- Keep the Maintainer role on projects that hold deployment secrets small, or move deployments to a separate project as GitLab suggests, so that fewer accounts can read the values.
- Define production secrets on the runner side where that is possible. GitLab notes that this prevents other users with the Maintainer role from reading the secrets.
- Keep long-lived credentials out of variables where a short-lived alternative exists, so that a value that was read loses its worth quickly.
- Give automation that manages variables its own account and token, so that reads by any other account stand out.
- Stream audit events to your SIEM and alert on variable reads across many projects by one account.
Frequently asked questions
Why do these events not show up in the GitLab audit events page?
GitLab marks `variable_viewed_api` and `variable_viewed_graphql` as not saved to the database. Its event type reference explains that most audit events are saved to the database, where the audit events page and API read them, while all audit events can be streamed to external destinations, which needs the Ultimate tier. These reads therefore exist only in a stream to your own destination.
Does a pipeline that uses a variable write this event?
The two event types are described as a variable accessed with the API and a variable value accessed with GraphQL. They concern reads through those interfaces by a user or a token, not the use of a variable inside a job. GitLab lists the events without their fields, so test one read through the API on your version to see what the event carries.
Are reads from GitLab Secrets Manager covered?
Not by the rule. GitLab has streaming-only event types for the value of a project or group secret being read from OpenBao by a CI/CD job or a non-CI/CD workload (`secrets_manager_read_project_secret`, `secrets_manager_read_group_secret`). Every job that requests a secret writes one, and GitLab does not document a field that tells a job from another workload, so a count would fire on normal pipelines.
Why is the rule only at medium level?
The event types are new and documented by one line each, without fields. The rule counts the documented `entity_path` per `author_id`, but it has not been tested against a real sweep, and infrastructure as code that manages variables reads them in the same way. Treat the count of five projects or groups in an hour as a starting point and raise the level once you know your own automation.