Skip to content
Pwnversity
AUD-GITLABintermediate · 10 min · upd. 2026-11

Auditing GitLab

GitLabGitLab CI/CDRunners

GitLab brings repository, CI/CD, container registry and packages together in one platform, on GitLab.com or on your own instance (self-managed). The audit centers on the group, where members, 2FA and variables are inherited, and on the pipeline, which is what runs code with those variables. The general CI/CD principles are in CI/CD security.

On GitLab.com, GitLab runs the platform and the hosted runners. On a self-managed instance, the customer also takes on the server, its patching and the admin configuration. In both cases the customer decides:

  • members, roles and 2FA;
  • tokens and their expiry;
  • branch protection;
  • CI/CD variables and who can use them;
  • their own runners.
flowchart TB
    U["Members<br/>2FA, inherited role"] --> G(("Group"))
    G --> P["Project<br/>protected branches and tags"]
    TK["PATs, group and project<br/>tokens, deploy tokens"] --> P
    P --> PL["Pipeline<br/>.gitlab-ci.yml"]
    V["CI/CD variables<br/>protected, hidden"] --> PL
    PL --> RN["Runner<br/>shared or own"]
    PL -->|"CI_JOB_TOKEN<br/>allowlist"| P2["Other projects"]
    MR["MR from a fork"] -->|"pipeline in the fork<br/>or in the parent"| PL
Setting Where Recommended value
Required 2FA Group (Settings > General > Permissions) or instance (Admin) On, with a short grace period. It also applies to inherited members
2FA with an external provider (SSO) Identity provider Require it there: GitLab’s setting doesn’t apply to users who sign in through an external provider
Members and roles Group and projects Owner and Maintainer only for those who need them; review inherited and invited members
Personal access tokens User (or the admin inventory) Expiry required (365-day maximum by default), minimal scopes
Group and project tokens, deploy tokens, deploy keys Group and project Inventory, minimal scope, rotation
Visibility Group and project Review which projects are public or internal and whether they should be

Since GitLab 16.0 every access token has an expiry date. A token created without one before that version got one on upgrade. On a self-managed instance an admin can turn the requirement off, so check it’s still on.

Ventana de terminal
# GitLab API with a read-only token (read_api)
curl -s -H "PRIVATE-TOKEN: $T" "$GL/api/v4/groups/GROUP" | jq '{require_two_factor_authentication, two_factor_grace_period, visibility}'
curl -s -H "PRIVATE-TOKEN: $T" "$GL/api/v4/groups/GROUP/members/all" | jq '.[] | {username, access_level, expires_at}'
curl -s -H "PRIVATE-TOKEN: $T" "$GL/api/v4/projects/ID/protected_branches" | jq '.[] | {name, allow_force_push}'
  • The default branch and release branches protected: nobody pushes directly and nobody force-pushes.
  • Protected tags on projects that release from tags. Protected variables and runners also apply to them.
  • MR approval rules, without the author being able to approve their own change.
  • CODEOWNERS on .gitlab-ci.yml and the included CI templates.

Variables are set at project, group or instance level and encrypted in the database. They have two independent settings:

Setting Options Effect
Protect variable Yes / No Only reaches pipelines running on protected branches or tags
Visibility Visible, Masked, Masked and hidden Masked replaces the value with [MASKED] in logs. Masked and hidden (since 17.4) also prevents viewing it again in the UI

Since GitLab 18.3, the default visibility for new variables is Masked.

Ventana de terminal
curl -s -H "PRIVATE-TOKEN: $T" "$GL/api/v4/projects/ID/variables" \
| jq '.[] | {key, protected, masked, hidden, environment_scope}' # doesn't print value
curl -s -H "PRIVATE-TOKEN: $T" "$GL/api/v4/groups/GROUP/variables" | jq '.[] | {key, protected, masked}'

What to look for: variables with secret-like names (*_TOKEN, *_KEY, *_PASSWORD, DATABASE_URL) that aren’t protected, group variables inherited by projects that don’t need them and environment_scope: * on secrets only production uses.

By default, the pipeline for an MR from a fork runs in the fork, with the fork’s configuration, runners and variables. It doesn’t see the parent’s.

A member of the parent project can run it in the parent. Then the .gitlab-ci.yml from the fork’s branch is used with the parent’s variables, meaning the contributor’s code with the project’s secrets. GitLab asks you to accept a warning before doing it.

Since 18.1 you can prevent MR pipelines from accessing protected variables and runners. Those from a fork never do. Audit:

  • the project setting ci_allow_fork_pipelines_to_run_in_parent_project;
  • the pipeline history tagged fork;
  • whether reviewers know never to run a pipeline for an MR that touches CI configuration without reading it.

Each job gets a CI_JOB_TOKEN with the permissions of whoever triggered the pipeline, valid only for the job’s duration. For a job from another project to use it against yours, that project has to be on your allowlist. Each project’s allowlist starts with only itself.

  • When a self-managed instance upgrades to GitLab 18.0, a migration turns on the admin setting that enforces the allowlist for every project. An admin can turn it off again, so check it.
  • What to review:
    • that access control is on (inbound_enabled: true in the job token scope API);
    • which groups and projects are on the list and whether they’re still needed;
    • that public or internal projects don’t expose to any job artifacts, container registry and packages that should be private.
Ventana de terminal
curl -s -H "PRIVATE-TOKEN: $T" "$GL/api/v4/projects/ID/job_token_scope"
curl -s -H "PRIVATE-TOKEN: $T" "$GL/api/v4/projects/ID/job_token_scope/allowlist" | jq '.[].path_with_namespace'
Risk Why What to ask for
shell executor The job runs as the runner’s user and can read other projects’ code on that machine Trusted code only; Docker or Kubernetes is better
Docker in privileged mode (docker-in-docker) A privileged container has all root capabilities over the runner machine No privileges; if images must be built, a separate, ephemeral runner with one build per machine
Shared, persistent runner A malicious job leaves something that affects the next project Ephemeral runners; pull_policy: always on shared runners
Unprotected runner holding deployment credentials Any branch can use it Mark it as protected: it only picks jobs from protected branches and tags
Ventana de terminal
curl -s -H "PRIVATE-TOKEN: $T" "$GL/api/v4/projects/ID/runners" | jq '.[] | {id, description, is_shared, active}'
  • Patching. Unpatched instances are the main risk. Check the version against GitLab’s security releases, which ship critical fixes often.
  • Open sign-up. Check whether anyone can create an account, whether admin approval is required and which domains are allowed.
  • Admin 2FA, access to the Rails console and the machine, and copies of gitlab-secrets.json: with it, the variables in the database can be decrypted.
  • Audit events kept outside the instance.
  • CVE-2023-7028 (January 2024). A specially crafted request made any account’s password reset email also go to an unverified attacker-controlled address. It allowed account takeover without interaction (CVSS 10). Accounts with 2FA had their password reset, but couldn’t be taken over.

    • It was fixed in 16.7.2, 16.6.4 and 16.5.6, with backports to older branches.
    • CISA added it to the KEV catalog on May 1, 2024 for active exploitation.
    • By then, Shadowserver still saw more than 2,100 vulnerable instances.

    It’s the example of why a self-managed instance needs a patching process and required 2FA.

  • Shared runners with docker-in-docker. Pulse Security documented how a low-privileged user escalates from a job on a shared runner in privileged mode. From there they reach the data of the other projects going through that runner. It’s the privileged-runner row in the table above.

  • 2FA required on the top-level group and the instance; also required at the SSO provider
  • Members, roles and invitations reviewed; few Owners
  • Token expiry required; PATs, group and project tokens, deploy tokens and deploy keys inventoried
  • Release branches and tags protected; no force push; approval without the author; CODEOWNERS on CI configuration
  • Every secret as a protected, Masked and hidden variable; no secrets in .gitlab-ci.yml
  • Group variables limited by environment and to the projects that use them
  • Fork pipelines in the parent disabled or covered by a review procedure
  • CI_JOB_TOKEN allowlist on and minimal
  • Runners without shell or privileged mode for untrusted code; deployment runners protected; ephemeral
  • Self-managed: up-to-date version, controlled sign-up, gitlab-secrets.json protected, audit events stored outside