TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How to harden GitHub Actions

184 pointsby moyer3 days ago

23 comments

ebfe1about 7 hours ago
After tj-actions hack, I put together a little tool to go through all of github actions in repository to replace them with commit hash of the version<p><a href="https:&#x2F;&#x2F;github.com&#x2F;santrancisco&#x2F;pmw">https:&#x2F;&#x2F;github.com&#x2F;santrancisco&#x2F;pmw</a><p>It has a few &quot;features&quot; which allowed me to go through a repository quickly:<p>- It prompts user and recommend the hash, it also provides user the url to the current tag&#x2F;action to double check the hash value matches and review the code if needed<p>- Once you accept a change, it will keep that in a json file so future exact vesion of the action will be pinned as well and won&#x27;t be reprompted.<p>- It let you also ignore version tag for github actions coming from well-known, reputational organisation (like &quot;actions&quot; belong to github) - as you may want to keep updating them so you receive hotfix if something not backward compatible or security fixes.<p>This way i have full control of what to pin and what not and then this config file is stored in .github folder so i can go back, rerun it again and repin everything.
评论 #43928539 未加载
评论 #43929100 未加载
评论 #43928837 未加载
评论 #43927229 未加载
cyrnelabout 8 hours ago
This has some good advice, but I can&#x27;t help but notice that none of this solves a core problem with the tj-actions&#x2F;changed-files issue: The workflow had the CAP_SYS_PTRACE capability when it didn&#x27;t need it, and it used that permission to steal secrets from the runner process.<p>You don&#x27;t need to audit every line of code in your dependencies and their subdependencies if your dependencies are restricted to only doing the thing they are designed to do and nothing more.<p>There&#x27;s essentially nothing nefarious changed-files could do if it were limited to merely reading a git diff provided to it on stdin.<p>Github provides no mechanism to do this, probably because posts like this one never even call out the glaring omission of a sandboxing feature.
评论 #43927329 未加载
评论 #43927338 未加载
评论 #43926528 未加载
评论 #43926424 未加载
maenbaljaabout 3 hours ago
Timely article... I recently learned about self-hosted runners and set one up on a Hetzner instance. Pretty smooth experience overall. If your action contains any SSH commands and you&#x27;d like to avoid setting up a firewall with 5000+ rules[0], I would recommend self-hosting a runner to help secure your target server&#x27;s SSH port.<p>[0] <a href="https:&#x2F;&#x2F;api.github.com&#x2F;meta" rel="nofollow">https:&#x2F;&#x2F;api.github.com&#x2F;meta</a>
gose1about 4 hours ago
&gt; Safely Writing GitHub Workflows<p>If you are looking for ways to identify common (and uncommon) vulnerabilities in Action workflows, last month GitHub shipped support for workflow security analysis in CodeQL and GitHub Code Scanning (free for public repos): <a href="https:&#x2F;&#x2F;github.blog&#x2F;changelog&#x2F;2025-04-22-github-actions-workflow-security-analysis-with-codeql-is-now-generally-available&#x2F;" rel="nofollow">https:&#x2F;&#x2F;github.blog&#x2F;changelog&#x2F;2025-04-22-github-actions-work...</a>.<p>The GitHub Security Lab also shared a technical deep dive and details of vulnerabilities that they found while helping develop and test this new static analysis capability: <a href="https:&#x2F;&#x2F;github.blog&#x2F;security&#x2F;application-security&#x2F;how-to-secure-your-github-actions-workflows-with-codeql&#x2F;" rel="nofollow">https:&#x2F;&#x2F;github.blog&#x2F;security&#x2F;application-security&#x2F;how-to-sec...</a>
cedwsabout 9 hours ago
I’ve been reviewing the third party Actions we use at work and seen some scary shit, even with pinning! I’ve seen ones that run arbitrary unpinned install scripts from random websites, cloning the HEAD of repos and running code from there, and other stuff. I don’t think even GitHub’s upcoming “Immutable Actions” will help if people think it’s acceptable to pull and run arbitrary code.<p>Many setup Actions don’t support pinning binaries by checksum either, even though binaries uploaded to GitHub Releases can be replaced at will.<p>I’ve started building in house alternatives for basically every third party Action we use (not including official GitHub ones) because almost none of them can be trusted not to do stupid shit.<p>GitHub Actions is a security nightmare.
评论 #43925816 未加载
kylegalbraithabout 9 hours ago
Glad this got posted. It&#x27;s an excellent article from the Wiz team.<p>GitHub Actions is particularly vulnerable to a lot of different vectors, and I think a lot of folks reach for the self-hosted option and believe that closes up the majority of them, but it really doesn&#x27;t. If anything, it might open more vectors and potentially scarier ones (i.e., a persistent runner could be compromised, and if you got your IAM roles wrong, they now have access to your AWS infrastructure).<p>When we first started building Depot GitHub Actions Runners [0], we designed our entire system to never trust the actual EC2 instance backing the runner. The same way we treat our Docker image builders. Why? They&#x27;re executing untrusted code that we don&#x27;t control.<p>So we launch a GitHub Actions runner for a Depot user in 2-5 seconds, let it run its job with zero permissions at the EC2 level, and then kill the instance from orbit to never be seen again. We explicitly avoid the persistent runner, and the IAM role of the instance is effectively {}.<p>For folks reading the Wiz article. This is the line that folks should be thinking about when going the self-hosted route:<p>&gt; Self-hosted runners execute Jobs directly on machines you manage and control. While this flexibility is useful, it introduces significant security risks, as GitHub explicitly warns in their documentation. Runners are non-ephemeral by default, meaning the environment persists between Jobs. If a workflow is compromised, attackers may install background processes, tamper with the environment, or leave behind persistent malware.<p>&gt; To reduce the attack surface, organizations should isolate runners by trust level, using runner groups to prevent public repositories from sharing infrastructure with private ones. Self-hosted runners should never be used with public repositories. Doing so exposes the runner to untrusted code, including Workflows from forks or pull requests. An attacker could submit a malicious workflow that executes arbitrary code on your infrastructure.<p>[0] <a href="https:&#x2F;&#x2F;depot.dev&#x2F;products&#x2F;github-actions">https:&#x2F;&#x2F;depot.dev&#x2F;products&#x2F;github-actions</a>
axelfontaineabout 8 hours ago
This is a great article, with many important points.<p>One nitpick:<p>&gt; Self-hosted runners should never be used with public repositories.<p>Public repositories themselves aren&#x27;t the issue, pull requests are. Any infrastructure or data mutable by a workflow involving pull requests should be burned to the ground after that workflow completes. You can achieve this with ephemeral runners with JIT tokens, where the complete VM is disposed of after the job completes.<p>As always the principle of least-privilege is your friend.<p>If you stick to that, ephemeral self-hosted runners on disposable infrastructure are a solid, high-performance, cost-effective choice.<p>We built exactly this at Sprinters [0] for your own AWS account, but there are many other good solutions out there too if you keep this in mind.<p>[0] <a href="https:&#x2F;&#x2F;sprinters.sh" rel="nofollow">https:&#x2F;&#x2F;sprinters.sh</a>
tomrodabout 10 hours ago
I support places that use GH Actions like its going out of style. This article is useful.<p>I wonder how we get out of the morass of supply chain attacks, realistically.
评论 #43925446 未加载
RadiozRadiozabout 4 hours ago
GHA Newbie here: what are all these 3rd-party actions that people are using? How complicated is your build &#x2F; deployment pipeline that you need a bunch of premade special steps for it?<p>Surely it&#x27;s simple: use a base OS container, install packages, run a makefile.<p>For deployment, how can you use pre-made deployment scripts? Either your environment is bespoke VPS&#x2F;on-prem, In which case you write your deployment scripts anyway, or you use k8s and have no deployment scripts. Where is this strange middleground where you can re-use random third party bits?
评论 #43929791 未加载
20thrabout 4 hours ago
These suggestions make a lot of sense.<p>At Namespace (namespace.so), we also take things one step further: GitHub jobs run under a cgroup with a subset of privileges by default.<p>Running a job with full capabilities, requires an explicit opt-in, you need to enable &quot;privileged&quot; mode.<p>Building a secure system requires many layers of protection, and we believe that the runtime should provide more of these layers out of the box (while managing the impact to the user experience).<p>(Disclaimer: I&#x27;m a founder at Namespace)
dupedabout 5 hours ago
I feel like there was a desire from GH to avoid needing a &quot;build&quot; step for actions so you could use `use: someones&#x2F;work` or whatever, `git push` and see the action run.<p>But if you think about it, the entire design is flawed. There should be a `gh lock` command you can run to lock your actions to the checksum of the action(s) your importing, and have it apply transitively, and verify those checksums when your action runs every time it pulls in remote dependencies.<p>That&#x27;s how every modern package manager works - because the alternative are gaping security holes.
wallratabout 8 hours ago
Been tracking this project for a while <a href="https:&#x2F;&#x2F;github.com&#x2F;chains-project&#x2F;ghasum">https:&#x2F;&#x2F;github.com&#x2F;chains-project&#x2F;ghasum</a> . It creates a verifiable checksum manifest for all actions - still in development but looks very promising.<p>Will be a good compliment to Github&#x27;s Immutable Actions when they arrive.
评论 #43931444 未加载
评论 #43926507 未加载
bob1029about 7 hours ago
&gt; By default, the Workflow Token Permissions were set to read-write prior to February 2023. For security reasons, it&#x27;s crucial to set this to read-only. Write permissions allow Workflows to inadvertently or maliciously modify your repository and its data, making least-privilege crucial.<p>&gt; Double-check to ensure this permission is set correctly to read-only in your repository settings.<p>It sounds to me like the most secure GH Action is one that doesn&#x27;t need to exist in the first place. Any time the security model gets this complicated you can rest assured that it is going to burn someone. Refer to Amazon S3&#x27;s byzantine configuration model if you need additional evidence of this.
digganabout 9 hours ago
&gt; Using Third-Party GitHub Actions<p>Maybe I&#x27;m overly pedantic, but this whole section seems to miss the absolutely most obvious way to de-risk using 3rd party Actions, review the code itself? It talks about using popularity, number of contributors and a bunch of other things for &quot;assessing the risk&quot;, but it never actually mentions reviewing the action&#x2F;code itself.<p>I see this all the time around 3rd party library usage, people pulling in random libraries without even skimming the source code. Is this really that common? I understand for a whole framework you don&#x27;t have time to review the entire project, but for these small-time GitHub Actions that handle releases, testing and such? Absolute no-brainer to sit down and review it all before you depend on it, rather than looking at the number of stars or other vanity-metrics.
评论 #43925814 未加载
newman314about 4 hours ago
Step Security has a useful tool that aids in securing GitHub Actions here: <a href="https:&#x2F;&#x2F;app.stepsecurity.io&#x2F;securerepo" rel="nofollow">https:&#x2F;&#x2F;app.stepsecurity.io&#x2F;securerepo</a><p>Disclaimer: No conflict of interest just a happy user.
MadsRCabout 7 hours ago
Shameless plug, I pushed a small CLI for detecting unpinned dependencies and automatically fix them the other day: <a href="https:&#x2F;&#x2F;codeberg.org&#x2F;madsrc&#x2F;gh-action-pin" rel="nofollow">https:&#x2F;&#x2F;codeberg.org&#x2F;madsrc&#x2F;gh-action-pin</a><p>Works great with commit hooks :P<p>Also working on a feature to recursively scan remote dependencies for lack of pins, although that doesn’t allow for fixing, only detection.<p>Very much alpha, but it works.
DGAPabout 9 hours ago
Great article!<p>I also found this open source tool for sandboxing to be useful: <a href="https:&#x2F;&#x2F;github.com&#x2F;bullfrogsec&#x2F;bullfrog">https:&#x2F;&#x2F;github.com&#x2F;bullfrogsec&#x2F;bullfrog</a>
评论 #43925611 未加载
评论 #43927811 未加载
评论 #43925661 未加载
goosetheabout 3 hours ago
your article inspired me <a href="https:&#x2F;&#x2F;github.com&#x2F;seanwevans&#x2F;Ghast">https:&#x2F;&#x2F;github.com&#x2F;seanwevans&#x2F;Ghast</a> still a WIP
Arch-TKabout 9 hours ago
The recommendation is not to interpolate certain things into shell scripts. Don&#x27;t interpolate _anything_ into shell scripts as a rule. Use environment variables.<p>This combined with people having no clue how to write bash well&#x2F;safely is a major source of security issues in these things.
评论 #43925949 未加载
analyticallyabout 8 hours ago
<a href="https:&#x2F;&#x2F;centralci.com&#x2F;blog&#x2F;posts&#x2F;concourse_vs_gha" rel="nofollow">https:&#x2F;&#x2F;centralci.com&#x2F;blog&#x2F;posts&#x2F;concourse_vs_gha</a>
esafakabout 7 hours ago
Can dependabot pin actions to commits while upgrading them?
crohrabout 9 hours ago
I guess TL;DR just use ephemeral runners when self hosting? There are lots of solutions for that. Also would be nice for GitHub to do something on the security front (allowlist &#x2F; blocklists if IPs, hosted, etc or at least just reporting on traffic)
enescakirabout 9 hours ago
The riskiest line in your repo isn’t in &quot;src&#x2F;&quot;, it’s in &quot;.github&#x2F;workflows&#x2F;&quot;<p>Self-hosted runners feel more secure at first since they execute jobs directly on machines you manage. But they introduce new attack surfaces, and managing them securely and reliably is hard.<p>At Ubicloud, we built managed GitHub Actions runners with security as the top priority. We provision clean, ephemeral VMs for each job, and they&#x27;re fully isolated using Linux KVM. All communication and disks are encrypted.<p>They’re fully compatible with default GitHub runners and require just a one-line change to adopt. Bonus: they’re 10× more cost-effective.<p><a href="https:&#x2F;&#x2F;www.ubicloud.com&#x2F;use-cases&#x2F;github-actions">https:&#x2F;&#x2F;www.ubicloud.com&#x2F;use-cases&#x2F;github-actions</a>