Securing the open source supply chain across GitHub (opens in new tab)
Attackers increasingly target GitHub Actions workflows to steal secrets, publish malicious packages, and spread into additional projects. GitHub recommends reducing credential exposure, hardening workflows, and using automated tools such as CodeQL and Dependabot. It is also expanding trusted publishing, malware detection, and GitHub Actions security improvements in response to campaigns such as Shai-Hulud.
How attacks begin
- Many supply-chain attacks start by exploiting insecure GitHub Actions workflows.
- Stolen API keys and other secrets can let attackers publish packages from their own machines.
- Malicious packages can then compromise downstream projects and propagate the attack.
Securing GitHub Actions today
- Enable CodeQL’s GitHub Actions queries, which are free for public repositories, to identify workflow security weaknesses.
- Avoid triggering workflows with
pull_request_target. - Pin third-party Actions to full-length commit SHAs.
- Updates should be made by maintainers or Dependabot.
- Treat pull requests that change pinned Actions with suspicion.
- Protect workflows against script injection when using pull-request or other user-submitted content.
- Monitor GitHub’s Advisory Database and use Dependabot malware alerts to detect compromised or vulnerable dependencies.
Replacing secrets with trusted publishing
- GitHub recommends using short-lived OpenID Connect tokens containing a workflow’s workload identity instead of storing long-lived secrets.
- Cloud providers, package registries, and hosted services can use these tokens to authorize workflow activity.
- Through collaboration with OpenSSF, trusted publishing is supported by npm, PyPI, NuGet, RubyGems, Crates, and other registries.
- Trusted publishing both removes credentials from build pipelines and provides a signal when a package unexpectedly switches away from it.
Detecting malicious packages
- npm publishes more than 30,000 packages daily and scans every package version for malware.
- Hundreds of newly published packages contain malicious code each day.
- Human review confirms detections before action is taken, helping avoid disrupting legitimate maintainers.
- Even a 1% false-positive rate would affect hundreds of valid package releases daily at npm’s scale.
GitHub’s upcoming security work
- Attacks such as Shai-Hulud accelerated npm’s security roadmap.
- GitHub is expanding trusted publishing, malware detection and removal, and collaboration with maintainers.
- The company is also revisiting and accelerating its GitHub Actions security roadmap.
- New protections may require workflow changes or create compatibility concerns, so GitHub aims to make the transition gradual and solicits community feedback.
Projects should audit their Actions workflows immediately, eliminate long-lived publishing credentials where possible, pin dependencies, and enable CodeQL and Dependabot. Adopting trusted publishing provides both stronger protection and useful evidence for identifying suspicious package releases.