Disrupting Supply Chain Attacks: Securing npm and GitHub Actions
Supply chain attacks are increasingly common, often starting with the compromise of a single project. Attackers may gain access by targeting a maintainer's account or exploiting vulnerabilities in the project's actions workflows. Recent improvements in npm and GitHub Actions are designed to cut off these common attack vectors and provide mechanisms for identifying and responding to such threats.
One key vulnerability is known as pwn requests, where workflows trigger on pull requests from forks, executing untrusted code. To combat this, trusted publishing allows you to authorize publishes to your package repository without relying on long-lived credentials. Additionally, staged publishing ensures that new packages on npm require further approval and 2FA authentication before they are published. The Actions network firewall logs all outbound network traffic from your Action workflow runs, helping you detect unusual behavior, such as pulling down malicious code or exfiltrating credentials.
In production, be aware that npm v12 will introduce a breaking change that disables install scripts by default, which can impact your workflows. Understanding these features and their configurations is essential to secure your CI/CD pipelines effectively.
Key takeaways
- →Understand pwn requests to avoid executing untrusted code from forked pull requests.
- →Implement trusted publishing to authorize publishes without long-lived credentials.
- →Utilize staged publishing for npm packages to require additional approval and 2FA.
- →Leverage the Actions network firewall to monitor outbound traffic for unusual behavior.
- →Prepare for npm v12's breaking change that disables install scripts by default.
Why it matters
In production, securing your CI/CD pipelines against supply chain attacks can prevent significant breaches and protect sensitive data. Implementing these strategies can safeguard your projects and maintain trust in your development processes.
When NOT to use this
The official docs don't call out specific anti-patterns here. Use your judgment based on your scale and requirements.
Want the complete reference?
Read official docsDeploy any app in seconds — no infrastructure config, no DevOps overhead. Instant deployments from GitHub, built-in databases, and automatic scaling.
Start deploying free →Automating Repo Hygiene with Evergreen: Secure Access Made Easy
Tired of stale repositories and unchecked access in your shared org? Evergreen automates access reviews and repository hygiene, ensuring your GitHub organization remains secure and efficient. With features like automatic access revocation and recoverable archived repos, you can maintain control effortlessly.
Mastering GitHub's Secret Detection: Less Noise, More Security
In a world where secrets leak can lead to catastrophic breaches, GitHub's secret detection model is a game changer. It employs a two-tiered approach: push protection and post-push scanning, ensuring you catch secrets before they become a problem.
Harnessing AI for Fuzzing: The GitHub Security Lab Taskflow Agent
Fuzzing is a critical part of security testing, and the GitHub Security Lab Taskflow Agent automates this process with AI. It uses a coverage-feedback loop to iteratively improve fuzzing coverage, making it a powerful tool for C/C++ projects.
Get the daily digest
One email. 5 articles. Every morning.
No spam. Unsubscribe anytime.