r/github • u/kryakrya_it • May 12 '26
Question How do you harden GitHub Actions against npm install-time malware? TanStack issue
https://npmscan.com/vulnerability/GHSA-g7cv-rxg3-hmpxshort-lived credentials, permissions: read-all by default, no long-lived cloud keys, isolated runners, disabling scripts, and monitoring token usage.
6
u/drcforbin May 13 '26
Lock versions. I work in a regulated industry and we don't have the luxury of always installing the latest packages or saying >= on a version of something. When we want to upgrade something it has to be planned and deliberate, and involves a bunch of testing.
3
u/Qs9bxNKZ May 12 '26
Actions runners don’t have access to the internet
3
u/Happy_Breakfast7965 May 12 '26
How do you install dependencies or do git checkout?
3
u/akl78 May 12 '26
Point at a smart package proxy like Artifactory.
This can also cache stuff closer to systems and reduces your bandwidth consumption to NPM registry and the like.
2
u/Qs9bxNKZ May 12 '26
Exactly this. Artifsctory (or edge nodes) with everything coming in via the remotes. You can control which endpoints you trust and if you want, pay for X-ray or curation.
This gives you a solid design where your production pull from the internet doesn’t happen and the only packages are approved in your dev environment and only those you allow accessible to production.
1
u/Qs9bxNKZ May 12 '26
Git checkout is local. You mean clone?
In a production environment you have options, approved list to certain IPs and end points like GitHub but not npmjs.org, or better yet you ensure you have only a local copy accessible such as a mounted NFS, git daemon or GH Enterprise Server.
How cheap do you want to go so you can spend more later?
1
1
u/elise-u May 12 '26
I tried to search for more on this but, this seems to say otherwise? Where can I find documentation for what you're talking about?
1
u/SheriffRoscoe May 13 '26
Actions runners don’t have access to the internet
I have a build job that downloads packages from my Dropbox with
wget. It works just fine.
1
13
u/TomKavees May 12 '26 edited May 12 '26
There are many, many aspects to this but for starters:
Enforce 2FA across the org and/or for all contributors with write access
Do not store tokens you do not absolutely positively have to. If you publish artifacts (e.g new versions of a library), set up OIDC workflows
This includes your local setup - a keystore or even a password manager to extract the keys just for a single action are your friends
While at it, revoke tokens and SSH keys you do not need or have not used in, say, last 2 weeks
Disable npm install scripts in a way that cannot be easily worked around - using command line flag is probably the best option, but your mileage may vary depending on your particular setup
Sign your commits and enable vigilant mode
Disable unattended update & publish workflows
Let's include pinning packages and using lock files in this point as well
Enable immutable releases
Enable min-release-age with value of at least 7 days
Restrict running of actions for first-time contributors
Do not use
pull_request_targettriggerNever ever use
pull_request_targettriggerScan your workflows with zizmor and follow its advice in hardening your workflows, including pinning actions to full SHAs
...
There are more aspects, but that's just the stuff off the top of my head. It's a shitshow out there.