Skip to content
RCE Write-up Advanced

OMGCICD - Attacking GitLab CI/CD Via Shared Runners

A low-privileged GitLab user could create a personal project and run a malicious pipeline on a shared, privileged docker-in-docker runner, then escape the container to the underlying host. From there the attacker could wait for other pipelines and steal the credentials they use to deploy to production.

Denis Andzakovic Follow

Published on pulsesecurity.co.nz

CI/CD systems are often used for continuous deployment so that when the right things happen in the source repo, the code magically ends up built and deployed where it needs to be. Underneath all of this is usually a “runner”, which is responsible for doing the work.

Denis Andzakovic, on pulsesecurity.co.nz

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the shared runner ran jobs in privileged docker-in-docker containers with no isolation between workloads, so any user able to create a project could escape to the host.

Impact

An attacker with any GitLab access could take over the shared runner host and steal deployment credentials and secrets belonging to other projects using that runner.

What the attacker needed

Any GitLab account able to create a project; a shared instance-level runner; runner uses privileged docker-in-docker

The fix

Shared runners should isolate workloads, for example by not running jobs in privileged docker-in-docker mode and by giving sensitive deployments their own dedicated runners.

How it was found

  1. Create a personal project and check that a shared instance-level runner is available to it
  2. Add a pipeline configuration that opens a reverse shell back to the attacker
  3. Run the pipeline and catch the shell inside the job container
  4. Inspect mounts and block devices, then mount the host disk to read the host filesystem
  5. Add an SSH key to the host's root account and log in to the host
  6. Watch running containers and wait for a high-value pipeline to harvest its credentials

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A CI/CD runner is a machine that automatically builds and deploys code when someone pushes changes. Here many different projects shared one runner, and each job ran in a container with extra privileges, so a user with only their own throwaway project could break out of that container and reach the machine underneath. Once on that machine, they could watch other projects' jobs and copy the passwords those jobs use.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by Denis Andzakovic

View all

7 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.