Live data from Hacker News

Exploiting CI / CD Pipelines for fun and profit

blog.razzsecurity.com

11–20 of 45 posts

Re: Exploiting CI / CD Pipelines for fun and profit

#11

Earlier quoted context omitted.

Its easy to miss that you need to duplicate your .gitignore into your .dockerignore

To not have to remember that one can not use a .dockerignore at all and instead explicitly pick the files and directories from the build context that need to be in the image.

This is annoying and error prone if you use an interpreted language that relies on loading source files at runtime.

For a Go service? Sure, that's easy and makes a ton of sense.

Re: Exploiting CI / CD Pipelines for fun and profit

#12
post #2

I’ve never deployed a .git folder and wonder what systems/approaches lead to such a thing. How does that happen?

For scripting languages, I sometimes clone a readonly repo to prod. Then I use git pull && systemctl --user restart srv to deploy. For compiled programs, I do it with rsync or docker pull.

Re: Exploiting CI / CD Pipelines for fun and profit

#14
post #11

Earlier quoted context omitted.

To not have to remember that one can not use a .dockerignore at all and instead explicitly pick the files and directories from the build context that need to be in the image.

This is annoying and error prone if you use an interpreted language that relies on loading source files at runtime. For a Go service? Sure, that's easy and makes a ton of sense.

For a go service you have a multi stage build that copies just the built executable into a clean base image.

Re: Exploiting CI / CD Pipelines for fun and profit

#15
post #6

The real problem is keeping sensetive information in .git directory. Like WTH would you put your password, in plaintext, in some general ini file? (or into a source file for that matter)? When I see things like those, they look so wrong to me. But sadly it's apparently uncommon nowadays: not only random bloggers, even my coworkers see nothing wrong with putting passwords or tokens into general config or source code f…

You know, Sun fixed this almost 30 years ago in the J2EE standard.

Re: Exploiting CI / CD Pipelines for fun and profit

#16
post #2

I’ve never deployed a .git folder and wonder what systems/approaches lead to such a thing. How does that happen?

It's because dockerignore file does not take this into consideration.

But in what cases would your root/source directory be part of what you want to shove into a dockerimage? Is it like if you have a static website or php site with its root at the root of your source repo?

Re: Exploiting CI / CD Pipelines for fun and profit

#17

naive question: Doesn't github secret scan kind of thing wont catch this?

It was deployed using a Bitbucket pipeline which does have a secret scanner available. However the scanner would need to be manually configured to be fully effective.

Re: Exploiting CI / CD Pipelines for fun and profit

#18
post #6

The real problem is keeping sensetive information in .git directory. Like WTH would you put your password, in plaintext, in some general ini file? (or into a source file for that matter)? When I see things like those, they look so wrong to me. But sadly it's apparently uncommon nowadays: not only random bloggers, even my coworkers see nothing wrong with putting passwords or tokens into general config or source code f…

>The real problem is keeping sensetive information in .git directory. Like WTH would you put your password, in plaintext, in some general ini file? (or into a source file for that matter)?

People & organisations tend to follow the path of least resistance. If it's easier to put passwords into a plaintext config file than not, passwords will invariably end up in plaintext config files in some projects. `PASSWORD = open("/home/user/.config/mypass.txt").read().strip()` will work right up until a colleague without `"/home/user/.config/mypass.txt"` attempts to run the project - at which point it'll be replaced with `PASSWORD = "the_password123"`.

The only pragmatic solution is to make it easier to handle passwords securely than to handle them insecurely.

Re: Exploiting CI / CD Pipelines for fun and profit

#19
Am I missing something, or does the step in

> Pushing Malicious Changes to the Pipeline

mean that they already have full access to the repository in the first place? Normally I wouldn't expect an attacker to be able to push to master (or any branch for that matter). Without that, the exploit won't work. And with that access, there's so many other exploits one can do that it's really no longer about ci/cd vulns.

Re: Exploiting CI / CD Pipelines for fun and profit

#20

Am I missing something, or does the step in > Pushing Malicious Changes to the Pipeline mean that they already have full access to the repository in the first place? Normally I wouldn't expect an attacker to be able to push to master (or any branch for that matter). Without that, the exploit won't work. And with that access, there's so many other exploits one can do that it's really no longer about ci/cd vulns.

edit: Credentials for modifying the piepline were found in the .git/config file
Post reply on HN