Skip to content
Write-up Intermediate

Exploiting CI / CD Pipelines for fun and profit

A publicly exposed .git directory leaked credentials that allowed cloning the repository, which contained a Bitbucket Pipelines configuration. The attacker modified the pipeline to add their SSH key to the production server, gaining shell access and full server takeover.

blog.razzsecurity.com

Published on blog.razzsecurity.com

In today’s world of fast-paced development and continuous integration, security vulnerabilities can be easy to overlook. Recently, I discovered a severe exploit chain, starting from a publicly exposed .git directory, which led to a full server takeover.

Mukesh, on blog.razzsecurity.com

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 .git directory was publicly accessible and contained credentials, and the CI/CD pipeline allowed arbitrary code execution on the production server without proper access controls.

Impact

The attacker gained full shell access to the production server, effectively compromising it.

What the attacker needed

Publicly exposed .git directory; credentials in .git/config; access to the repository; pipeline runs on push

The fix

The .git directory should be blocked from public access, and CI/CD pipelines should not allow arbitrary code execution on production servers without strict controls.

How it was found

  1. Scan for and find a publicly accessible .git directory on the target.
  2. Read .git/config to obtain credentials and a repository URL.
  3. Clone the repository using the found credentials.
  4. Discover the Bitbucket Pipelines configuration that logs into the production server via SSH.
  5. Modify the pipeline to append the attacker's SSH public key to the server's authorized_keys file.
  6. Commit and push the change, wait for the pipeline to run, then log in to the server with the added key.

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 .git folder is part of a code project that stores its history and settings; if it is left on a public website, anyone can download it. Here it contained login details for the code repository, and the repository's automation script (pipeline) could run commands on the live server. By changing that script, the attacker made the server accept their own key, letting them log in.

Similar reports

Same bug class and techniques, clearest first.