Malicious Packages
Trojanized releases of legitimate packages (or purpose-built lookalikes) on public registries that execute attacker code at install, build or import time — the dominant delivery vector for developer and CI credential theft.
How it works
Two ways in, then one of several execution hooks.
Getting a malicious version published
- Maintainer account takeover — phishing (
npmjs.helpfake 2FA-reset for~qix), targeted social engineering (UNC1069 cloning founders, fake Slack/Teams calls to RAT the Axios maintainer), dormant accounts (SleeperGem, forgotten Mastra contributor). - Stolen publish credentials — long-lived npm/PyPI tokens harvested by a previous compromise (Shai-Hulud Worm chains this into self-propagation), or an unrevoked API token left beside Trusted Publishing (Ultralytics round 2).
- Stolen release-pipeline credentials — a maintainer login plus the release bot’s token let Swarm’s pipeline build, sign and publish with no second approver (Swarm Foundation); a suspected stolen ESRP client certificate and key published Microsoft’s
agent-framework(VeritasChain). - Hijacked release pipeline — attacker code runs inside the project’s own CI and publishes with its identity, yielding valid provenance (Pwn Requests, cache poisoning, poisoned upstream Action — see CI/CD Pipeline Attacks).
- Name-based lookalikes: Typosquatting, Dependency Confusion, Slopsquatting.
Execution hooks
| Ecosystem | Hook | Example |
|---|---|---|
| npm | preinstall/postinstall/prepare lifecycle scripts | Axios → plain-crypto-js node setup.js; Shai-Hulud 2.0 setup_bun.js |
| npm | binding.gyp (node-gyp build) | Shai-Hulud Miasma wave |
| npm | git / remote-URL optionalDependencies | AntV orphan-commit dependency |
| PyPI | .pth file in site-packages → runs on every interpreter start | LiteLLM 1.82.8 litellm_init.pth (MITRE T1546.018); agent-framework 1.26.1 agent_framework_meta.pth, 1.26.2 af_runtime_diag.pth |
| PyPI | import-time source injection | LiteLLM 1.82.7 → litellm.proxy.proxy_server drops p.py |
| PyPI | overridden install command in setup.py | instantscrape 0.1.5/0.1.8 runs an embedded infostealer executable at install or import (GHSA-wqr9-48cj-55gj) |
| npm | runtime event in the library’s normal flow | PhantomSub Baileys forks fire on WhatsApp connection.update === 'open' or a setTimeout after socket creation (Corgea) |
| PyPI | build backend data options | LiteLLM 1.107.0 via maturin data |
| crates.io | build.rs at compile time | arrayref/internment/append-only-vec, onering 1.4.1 |
| RubyGems | gem install loader | SleeperGem git_credential_manager |
| CDN / script | domain or project ownership transfer | Polyfill.io |
Payload patterns
- Indirection: don’t touch the real package source; add a pre-staged malicious dependency (
plain-crypto-js@4.2.0clean, published 18 h before4.2.1malicious) or a typosquatted transitive dep (proc-macro1in the Rust campaign). - Runtime fetch: Swarm’s loader downloaded stage-2 from attacker infrastructure at install or app start, so the release itself never contained the payload and its behaviour could change at any time (Swarm Foundation).
- Functional camouflage:
agent-framework1.26.1/1.26.2 were rebuilt from the real 1.26.0 wheel plus one.pthfile and kept the dependency on genuineagent-framework-core1.26.0, so nothing broke (incident guide, VeritasChain). - Anti-forensics: delete
setup.jsand swap the hookedpackage.jsonfor a clean decoy (package.md) after running; swallow errors; masquerade as telemetry (Sentry ingest, OpenTelemetry). - Steganography: Telnyx 4.87.1/4.87.2 pulled
hangup.wav(Windows →msbuild.exein Startup) /ringtone.wav(Linux/macOS) and extracted stages from audio. - Environment gating: SleeperGem checks ~30 CI env vars (GitHub Actions, GitLab, CircleCI, Jenkins, Vercel) and exits in CI to target laptops; Nx payload ran only on Linux/macOS.
- Weaponized local AI agents: Nx
telemetry.jsinvoked Claude Code / Gemini CLI / Amazonqwith--dangerously-skip-permissions,--yolo,--trust-all-toolsand a prompt to inventory wallets, SSH keys and.envfiles — see AI Coding Assistant Risks. - Session abuse instead of theft: PhantomSub forks never steal credentials; they use the bot’s own authenticated WhatsApp socket to send
w:mexFOLLOW queries for attacker newsletter JIDs,groupAcceptInvite()into attacker groups and MUTE to hide the evidence. Targets are hidden as base64,String.fromCharCodearrays or remote JSON lists, and a fork may arm only in a patch release (Corgea). - Stealth execution:
agent-framework’s loader set an env marker to run once per process tree andfork()+setsid()’d a detached child so the parent showed no delay (Elastic). - Targets: npm/GitHub/PyPI tokens, cloud creds, kubeconfigs, Vault, SSH keys, wallets → feeds Leaked Cloud Credentials.
Notable cases
- Axios (Mar 31 2026) — 100M+ weekly downloads;
1.14.1and0.30.4addedplain-crypto-js@4.2.1, whosepostinstalldropped cross-platform RAT WAVESHAPER.V2 (C2sfrclak[.]com:8000). GHSA-fw8c-xr5c-95f9 / MAL-2026-2306; attributed to DPRK UNC1069. OpenAI rotated macOS code-signing certs after it hit a signing workflow. - Microsoft
agent-framework(PyPI, 17 Nov 2026) — 1.26.1 (~20:35 UTC) and 1.26.2 (~21:08 UTC), both gone by ~21:30; the attacker published 1.26.2 after 1.26.1 had been quarantined, showing continued access. ~190K monthly downloads for the package overall. The.pthstealer harvested env vars by name pattern, process secrets, 60–80 credential files, Azure DevOps OIDC, Azure managed-identity tokens for twelve resources and (1.26.2) GitHub Actions OIDC tokens, exfiltrated in one HTTPS request to webhook.site. The drop point’s 100-request free tier held 50 requests: 4 from the attacker, 29 from sandboxes and scanners, 17 from three real victim exfiltrations. Tooling traces named the open-source Cairn AI pentest framework. PYSEC-2026-4388, GHSA-764m-3ppc-5m73; no CVE (VeritasChain, incident guide). Elastic’s supply-chain monitor flagged 1.26.1 six minutes after publish; hunt for the four dropped filenames in site-packages andwebhook.sitetraffic with UAaf-runtime-diagnostics/1orruntime-diagnostics/1(Elastic). - PhantomSub (npm, Aug–Nov 2026) — Baileys (
@whiskeysockets/baileys) andlibsignal-nodeimpersonator forks: OX Security named 101, Safeguard counted 240+ malware records by mid-October, and GitHub published 247 advisories in one batch on 10 November (787 versions; 242 still live three days later). Roughly 40 names lack “bail” (angularsockets,malvin-wa), so name-grep deny-lists miss them;@corexium/xbailsaliasedlibsignalto a third party’s mutable@latest.--ignore-scriptsand install-time sandboxes don’t help because the payload needs a live WhatsApp login. Response: remove and pin upstream, unlink the device session, review followed/muted channels and groups, rebuild and rotate where behaviour can’t be bounded (Corgea). - Swarm
@ethersphere/bee-js13.3.0 + Swarm Desktop 0.56.2 (9 Nov 2026) — loader stole node keys/passwords (wallet control) and installed a RAT; tied by Socket and Pluto Security to an operation planting fake Solidity tooling in extension marketplaces since 2025. npm window ~00:09–01:25 UTC; projects with a committed lockfile never received 13.3.0 (Swarm Foundation; SBOM and Provenance). - chalk / debug + 16 (Sep 2025) — phished maintainer; browser-only payload hooking
window.ethereum,fetchandXMLHttpRequest, swapping wallet addresses by Levenshtein similarity; ~2 h exposure across packages with billions of weekly downloads. - Nx “s1ngularity” (Aug 2025) — root cause a
pull_request_targetworkflow with PR-title injection; maliciousnx20.9.0–21.8.0 and@nx/*versions exfiltrated triple-base64 data tos1ngularity-repository*repos; phase 2 used stolen tokens to flip 5,500+ private repos public (400+ users/orgs). Precursor to Shai-Hulud Worm. - TeamPCP chain (Mar 2026) — Trivy Action tags rewritten → CI creds → Checkmarx KICS Action (35 tags hijacked) → LiteLLM 1.82.7/1.82.8 → Telnyx; persistence callout
checkmarx.zone/raw, Kubernetes persistence. LiteLLM was hit again in 1.107.0 (Oct 2026: stolen GitHub org-owner token, lookalike repo,privcollectstealer) and is tied to the Mercor breach. - Ultralytics (Dec 2024) — GitHub Actions compromise published 8.3.41/8.3.42 via the real workflow (visible in Sigstore logs and PyPI attestations), then 8.3.45/8.3.46 via a leftover API token; coinminer payload.
- Polyfill.io (Jun 2024) — Funnull acquired the domain/project in Feb 2024 and served malware from
cdn.polyfill.ioto 100K+ sites; blockpolyfill[.]com,bootcdn[.]net,staticfile[.]net, use Cloudflare’scdnjsclone. - DPRK “Contagious Interview” — 1,700+ loader packages across npm, PyPI, Go, Rust, Packagist (
dev-log-core,logutilkit,github[.]com/golangorg/formstash); the Aug 2026arrayrefcrates compromise overlaps DPRK tradecraft. - RubyGems — SleeperGem hijacked dormant gems (
Dendreo,fastlane-plugin-run_tests_firebase_testlab) and wired in a fakegit_credential_manager; May 2026 RubyGems suspended sign-ups after hundreds of malicious uploads.
Defenses
Consumer side
-
Dependency cooldowns / minimum release age: pip 26.1, uv, npm, Yarn, Bun, Deno, RubyGems (e.g. 7 days); Dependabot defaults to a 72 h cooldown for version (not security) updates; Cloudsmith cooldown policies. Most malicious versions are pulled within hours: axios ~3 h, TanStack reported in 26 min and fully removed in ~4.5 h,
agent-framework< 1 h; in Woodruff’s list of ten attacks, seven had windows ≤ 12 h. Longer tails exist (tj-actions ~3 days, Kong Ingress Controller ~10, xz ~5 weeks), and attackers will delay payloads once waiting is common. Setting names and units differ (Roth, The Sweet Spot Is a Day Old):Tool Setting Unit / default npm ≥ 11.10 min-release-agedays pnpm minimumReleaseAgeminutes; 1 day default since pnpm 11 Yarn npmMinimalAgeGateduration ( 1w)Bun minimumReleaseAgeinbunfig.tomlseconds (1440 = 24 min) Deno minimumDependencyAge24 h default since 2.9 uv exclude-newerrelative duration ( 24 hours)pip ≥ 26.1 --uploaded-prior-toISO duration ( P1D)Cargo registry.global-min-publish-ageoff by default Renovate / Dependabot minimumReleaseAge/cooldownDependabot 3 days for version updates Give security fixes a narrow fast lane (Dependabot cooldown skips security updates, Renovate lets them bypass,
pnpm audit --fixadds an exclusion,npm audit fixwarns), with human review, because a hijacked maintainer can label a release a security fix. Go, Maven, Gradle and SwiftPM have no equivalent yet. Cooldowns don’t replace lockfiles, scanning or short-lived CI credentials. -
Disable install scripts:
npm ci --ignore-scripts; npm v12 blocks lifecycle scripts, git deps and remote URLs by default (explicit trust); npm--allow-file/--allow-remote/--allow-directoryflags. -
Lockfiles + clean-cache rebuilds; treat any host that installed a bad version as compromised and rotate everything reachable.
-
Scan before install:
guarddog pypi scan <pkg> --version <v>/guarddog npm scan(Semgrep + metadata heuristics, SARIF output; also Go, RubyGems, Actions, VS Code extensions); commercial feeds (Socket, Aikido, Snyk) flag releases within minutes — Axios 1.14.1 was a manual token push lacking the trusted-publisher block and source-commit binding of normal releases, so an install-time provenance-mismatch check would have flagged it. -
Feeds are signal, not verdicts. A pre-registered re-measurement found registries mostly settle a flag in its first weeks (OpenSSF’s new npm flags 55.8% removed within the window, GitHub’s 58.2% npm / 77.3% PyPI, Vulnetix 0 of 28), Amazon Inspector PyPI records read 72.7–77.3% benign, and the Vulnetix STIX domain feed matched 41% of popular PyPI packages vs 27% of malware. Registry checkers must treat both
0.0.1-securityand the new0.0.0-stagestub as placeholders, and compare file upload time with record date since names get re-served with other code. Scanner recall depends on the labels (GuardDog 77% → 90% once benign samples left DataDog’s set) (modelmarket.dev). -
Vendor due diligence after an incident like
agent-framework: exact pins and reviewed upgrades, build records that answer “did it reach us” within the hour, short-lived per-job build credentials, a release cooldown, and a named incident contact (Redlio Labs). -
Egress allowlisting on CI runners and build boxes.
-
Hash-pinned installs:
pip-compile --generate-hashes/uv pip compile --generate-hashes+pip install --require-hashes; least-privilege CI (contents: read,id-token: writeonly where needed); per-project venvs/containers. After a.pthcompromise, check lockfiles, CI logs and image layers from the window, remove hook files before running Python there, clear caches and internal mirrors, and rotate everything the environment could reach (incident guide, VeritasChain).
Publisher / registry side
- Trusted Publishing (OIDC) instead of long-lived tokens; revoke stale API tokens; require a GitHub Environment with reviewers on the publishing job.
- npm staged publishing (
npm stage publish, CLI 11.15.0+) requires a 2FA approval for every publish including OIDC/CI; npm mandatory 2FA + provenance. - PyPI 14-day cutoff on adding files to existing releases (stops poisoning old trusted versions); release attestations surfaced in a security tab.
- Provenance is necessary but not sufficient — TanStack and tensorlake shipped malware with valid provenance (SBOM and Provenance).
Related
- Software Supply Chain Security
- Shai-Hulud Worm
- XZ Utils Backdoor
- Typosquatting
- Dependency Confusion
- Slopsquatting
- CI/CD Pipeline Attacks
- GitHub Actions Security
- Pwn Requests
- tj-actions changed-files Compromise
- SBOM and Provenance
- AI Coding Assistant Risks
- Leaked Cloud Credentials
- Secret Scanning
Sources
- Axios npm package compromised — Snyk · original
- Axios NPM distribution compromised — Wiz · original
- DPRK threat actor compromises axios — Google Cloud · original
- UNC1069 social engineering of Axios maintainer — THN · original
- The Axios npm compromise was visible in registry metadata · original
- debug/chalk 16 packages compromise — Upwind · original
- Widespread npm supply chain attack — Wiz · original
- s1ngularity supply chain attack — Wiz · original
- Weaponizing AI Coding Agents in the Nx package — Snyk · original
- TeamPCP trojanizes LiteLLM — Wiz · original
- How a poisoned security scanner backdoored LiteLLM — Snyk · original
- LiteLLM and Telnyx compromised on PyPI — Datadog · original
- TeamPCP Telnyx stealer in WAV — THN · original
- litellm 1.107.0 compromised — StepSecurity · original
- Supply-chain attack analysis: Ultralytics — PyPI · original
- Polyfill supply chain attack — Snyk · original
- N. Korean hackers spread 1,700 malicious packages — THN · original
- Rust build-time malware in crates — THN · original
- arrayref attack overlaps DPRK — Wiz · original
- Compromised Rust crate onering — Aikido · original
- SleeperGem — THN · original
- RubyGems suspends new signups — THN · original
- RubyGems adds dependency cooldown — Risky Biz · original
- npm v12: implicit to explicit trust — JFrog · original
- npm adds 2FA-gated publishing — THN · original
- GitHub, PyPI add time-based defenses — BleepingComputer · original
- pip 26.1 ships dependency cooldowns — InfoQ · original
- A Forgotten Contributor Account Compromised Mastra — Snyk · original
- Cloudsmith adds cooldown policies — ChannelLife · original
- GitHub enhances npm security with mandatory 2FA and provenance — Rescana · original
- PyPI release attestations security tab — Help Net Security · original
- GuardDog · original
- The Sweet Spot Is a Day Old · original
- Swarm incident: malicious bee-js 13.3.0 and Swarm Desktop 0.56.2 · original
- Microsoft's AI Agent Package Was Hijacked on PyPI: Here's How to Check If You're Affected · original
- The Credential Was Valid. The Publisher Was Not. · original
- Corgea — PhantomSub: Baileys npm forks hijack WhatsApp channel follows · original
- Elastic — We caught the agent-framework PyPI compromise six minutes after it published · original
- Malicious code in instantscrape (PyPI) · original
- Seventeen days after the letters: npm and PyPI malware feeds, measured again · original
- A popular AI package was poisoned for 45 minutes · original