-
Notifications
You must be signed in to change notification settings - Fork 431
npm Supply Chain Compromise & Lifecycle Hook Abuse Detection #3806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+419
−77
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BRING MAIN UP TO DATE
…promise story tags
…e_execution (replacement for deprecated curl/wget bash detections)
…low_file_modification search
nasbench
reviewed
Nov 25, 2025
detections/endpoint/windows_curl_download_to_suspicious_path.yml
Outdated
Show resolved
Hide resolved
nasbench
reviewed
Nov 25, 2025
nasbench
reviewed
Nov 25, 2025
nasbench
reviewed
Nov 25, 2025
Co-authored-by: Nasreddine Bencherchali <[email protected]>
nasbench
approved these changes
Nov 25, 2025
patel-bhavin
approved these changes
Nov 25, 2025
Contributor
|
🚢 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR introduces comprehensive detection coverage for npm supply chain compromises, addressing both the immediate threat of the Shai-Hulud worm campaigns and the broader category of npm lifecycle hook abuse that has plagued the JavaScript ecosystem for years.
npm's lifecycle hooks (
preinstall,install,postinstall,prepare) execute arbitrary code during package installation—a powerful feature that attackers have repeatedly weaponized. From the event-stream incident (2018) to ua-parser-js (2021) to the current Shai-Hulud campaigns (2025), the pattern remains consistent: compromise a maintainer account, inject malicious lifecycle scripts, and harvest credentials at scale.The Shai-Hulud 2.0 campaign (November 2025) represents the most sophisticated npm supply chain attack to date, compromising 700+ npm packages including major projects from Zapier, ENS Domains, PostHog, and Postman, affecting 25,000+ repositories across ~500 GitHub users with propagation rates of ~1,000 new repos every 30 minutes.
Why Lifecycle Hooks Matter
npm lifecycle hooks are the primary attack vector for supply chain compromises:
preinstallinstallpostinstallprepareThese hooks run with the privileges of the installing user, often in CI/CD pipelines with access to secrets, cloud credentials, and deployment tokens. The analytics in this PR detect the downstream behaviors of malicious lifecycle scripts rather than the scripts themselves—providing detection regardless of which specific package is compromised.
Threat Intelligence Summary
Shai-Hulud 1.0 (September 2025):
postinstallhooksshai-hulud-workflow.ymlinto.github/workflows/Shai-Hulud 2.0 (November 2025):
preinstallexecution for broader blast radius (executes before install completes)setup_bun.js,bun_environment.jscloud.json,contents.json,environment.json,truffleSecrets.json,actionsSecrets.jsondiscussion.yamlenabling remote command injection via GitHub Discussions on self-hosted runners namedSHA1HULUDHistorical Context - This PR's analytics also detect patterns from past npm incidents:
postinstalltargeting Bitcoin walletsNew Analytics (3 Total)
🔴 Production Detections (TTP)
shai_hulud_workflow_file_creation_or_modification.ymlshai_hulud_2_exfiltration_artifact_files.ymlcloud.json,contents.json,environment.json,truffleSecrets.json,actionsSecrets.json🟡 Hunting Queries
github_workflow_file_creation_or_modification.yml.github/workflows/or\\.github\\workflows\\Tagged Existing Analytics (16 Total)
These existing detections provide coverage for behaviors observed in lifecycle hook abuse and Shai-Hulud campaigns:
Curl/Wget Exfiltration & Download (Linux)
linux_ingress_tool_transfer_with_curl.ymllinux_ingress_tool_transfer_hunting.ymllinux_curl_upload_file.ymlWindows Network Tools
windows_curl_download_to_suspicious_path.ymlwindows_curl_upload_to_remote_destination.ymlwindows_file_download_via_powershell.ymlGitHub Audit Log Detections
github_enterprise_register_self_hosted_runner.ymlSHA1HULUDgithub_enterprise_repository_deleted.ymlgithub_enterprise_repository_archived.ymlgithub_organizations_repository_deleted.ymlgithub_organizations_repository_archived.ymlgithub_enterprise_delete_branch_ruleset.ymlgithub_organizations_delete_branch_ruleset.ymlgithub_enterprise_disable_audit_log_event_stream.ymlgithub_enterprise_modify_audit_log_event_stream.ymlgithub_enterprise_pause_audit_log_event_stream.ymlLookup Updates
attacker_tools.csvtrufflehogandtrufflehog.exe- used by Shai-Hulud for secret scanningKill Chain Coverage
Testing & Emulation
For defenders wanting to validate these detections in their environment:
Data Sources Required
self_hosted_runner.*,repo.*,protected_branch.*MITRE ATT&CK Coverage
References
Shai-Hulud Campaign
Community Detection Rules
Historical npm Incidents
Validation