Harden your GitHub Actions Workflows with zizmor, dependency pinning, and dependency cooldowns
It's been a crazy week (or weeks?) for a lot of people with several supply chain attacks.
They all seem to have originated from the compromise of trivy (ironically, trivy is a security scanner).
I wanted to understand how they initially gained access to the secrets used in their GitHub organization and found that there was an earlier attack that targeted GitHub Actions workflows of open source projects.
Looking at the details of how the secrets were extracted I noticed that they all used similar techniques.
And, unless I missed something, it is through template injection and unsafe pull_request_target triggers.
This could be avoided because all of those vulnerabilities (and more) can be found by zizmor, a static analysis tool for GitHub Actions!
The problem is that, unfortunately, GitHub Actions is NOT secure by default1.
One would think that when following the official documentation you end up with workflows that are secure and can not be exploited.
Last year, I came across zizmor and upon checking my workflows it pointed out several problems that I was quite surprised to find out about.
Of course, GitHub should make Actions more secure by default2. And it seems that the latest attacks have finally helped to make some progress in that direction. GitHub have published a security roadmap for GitHub Actions and are looking for feedback from the community.
Until that happens, what can you do right now to harden your GitHub Actions workflows?