# 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.help` fake 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 ([[raw/ethswarm.org/swarm-incident-malicious-bee-js-13-3-0-and-swarm-desktop-0-56-2-15953|Swarm Foundation]]); a suspected stolen ESRP client certificate and key published Microsoft's `agent-framework` ([[raw/medium.com/the-credential-was-valid-the-publisher-was-not-15854|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|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 | 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 (`[email protected]` clean, published 18 h before `4.2.1` malicious) or a typosquatted transitive dep (`proc-macro1` in 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 ([[raw/ethswarm.org/swarm-incident-malicious-bee-js-13-3-0-and-swarm-desktop-0-56-2-15953|Swarm Foundation]]). - Functional camouflage: `agent-framework` 1.26.1/1.26.2 were rebuilt from the real 1.26.0 wheel plus one `.pth` file and kept the dependency on genuine `agent-framework-core` 1.26.0, so nothing broke ([[raw/medium.com/microsoft-s-ai-agent-package-was-hijacked-on-pypi-here-s-how-to-check-15853|incident guide]], [[raw/medium.com/the-credential-was-valid-the-publisher-was-not-15854|VeritasChain]]). - Anti-forensics: delete `setup.js` and swap the hooked `package.json` for 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.exe` in 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.js` invoked Claude Code / Gemini CLI / Amazon `q` with `--dangerously-skip-permissions`, `--yolo`, `--trust-all-tools` and a prompt to inventory wallets, SSH keys and `.env` files — see [[AI Coding Assistant Risks]]. - 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.1` and `0.30.4` added `[email protected]`, whose `postinstall` dropped cross-platform RAT WAVESHAPER.V2 (C2 `sfrclak[.]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 `.pth` stealer 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 ([[raw/medium.com/the-credential-was-valid-the-publisher-was-not-15854|VeritasChain]], [[raw/medium.com/microsoft-s-ai-agent-package-was-hijacked-on-pypi-here-s-how-to-check-15853|incident guide]]). - **Swarm `@ethersphere/bee-js` 13.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 ([[raw/ethswarm.org/swarm-incident-malicious-bee-js-13-3-0-and-swarm-desktop-0-56-2-15953|Swarm Foundation]]; [[SBOM and Provenance]]). - **chalk / debug + 16 (Sep 2025)** — phished maintainer; browser-only payload hooking `window.ethereum`, `fetch` and `XMLHttpRequest`, 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_target` workflow with PR-title injection; malicious `nx` 20.9.0–21.8.0 and `@nx/*` versions exfiltrated triple-base64 data to `s1ngularity-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, `privcollect` stealer) 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.io` to 100K+ sites; block `polyfill[.]com`, `bootcdn[.]net`, `staticfile[.]net`, use Cloudflare's `cdnjs` clone. - **DPRK "Contagious Interview"** — 1,700+ loader packages across npm, PyPI, Go, Rust, Packagist (`dev-log-core`, `logutilkit`, `github[.]com/golangorg/formstash`); the Aug 2026 `arrayref` crates compromise overlaps DPRK tradecraft. - **RubyGems** — SleeperGem hijacked dormant gems (`Dendreo`, `fastlane-plugin-run_tests_firebase_testlab`) and wired in a fake `git_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 ([[raw/cyb3rops.medium.com/the-sweet-spot-is-a-day-old-15955|Roth, The Sweet Spot Is a Day Old]]): | Tool | Setting | Unit / default | |---|---|---| | npm ≥ 11.10 | `min-release-age` | days | | pnpm | `minimumReleaseAge` | minutes; 1 day default since pnpm 11 | | Yarn | `npmMinimalAgeGate` | duration (`1w`) | | Bun | `minimumReleaseAge` in `bunfig.toml` | **seconds** (1440 = 24 min) | | Deno | `minimumDependencyAge` | 24 h default since 2.9 | | uv | `exclude-newer` | relative duration (`24 hours`) | | pip ≥ 26.1 | `--uploaded-prior-to` | ISO duration (`P1D`) | | Cargo | `registry.global-min-publish-age` | off by default | | Renovate / Dependabot | `minimumReleaseAge` / `cooldown` | Dependabot 3 days for version updates | Give security fixes a narrow fast lane (Dependabot cooldown skips security updates, Renovate lets them bypass, `pnpm audit --fix` adds an exclusion, `npm audit fix` warns), 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-directory` flags. - 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. - 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: write` only where needed); per-project venvs/containers. After a `.pth` compromise, 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 ([[raw/medium.com/microsoft-s-ai-agent-package-was-hijacked-on-pypi-here-s-how-to-check-15853|incident guide]], [[raw/medium.com/the-credential-was-valid-the-publisher-was-not-15854|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|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 - [[raw/snyk.io/axios-npm-package-compromised-supply-chain-attack-delivers-cross-platf-8746|Axios npm package compromised — Snyk]] - [[raw/wiz.io/axios-npm-distribution-compromised-in-supply-chain-attack-6889|Axios NPM distribution compromised — Wiz]] - [[raw/cloud.google.com/dprk-threat-actor-compromises-axios-npm-package-4028|DPRK threat actor compromises axios — Google Cloud]] - [[raw/thehackernews.com/unc1069-social-engineering-of-axios-maintainer-led-to-npm-supply-chain-6872|UNC1069 social engineering of Axios maintainer — THN]] - [[raw/autodoc.bearblog.dev/the-axios-npm-compromise-was-visible-in-registry-metadata-before-anyon-9218|The Axios npm compromise was visible in registry metadata]] - [[raw/upwind.io/npm-supply-chain-attack-debug-chalk-16-packages-compromise-upwind-4481|debug/chalk 16 packages compromise — Upwind]] - [[raw/wiz.io/widespread-npm-supply-chain-attack-breaking-down-impact-scope-across-d-4031|Widespread npm supply chain attack — Wiz]] - [[raw/wiz.io/s1ngularity-supply-chain-attack-leaks-secrets-on-github-everything-you-4033|s1ngularity supply chain attack — Wiz]] - [[raw/snyk.io/weaponizing-ai-coding-agents-for-malware-in-the-nx-malicious-package-s-9063|Weaponizing AI Coding Agents in the Nx package — Snyk]] - [[raw/wiz.io/three-s-a-crowd-teampcp-trojanizes-litellm-in-continuation-of-campaign-8841|TeamPCP trojanizes LiteLLM — Wiz]] - [[raw/snyk.io/how-a-poisoned-security-scanner-became-the-key-to-backdooring-litellm-3398|How a poisoned security scanner backdoored LiteLLM — Snyk]] - [[raw/securitylabs.datadoghq.com/litellm-and-telnyx-compromised-on-pypi-tracing-the-teampcp-supply-chai-4932|LiteLLM and Telnyx compromised on PyPI — Datadog]] - [[raw/thehackernews.com/teampcp-pushes-malicious-telnyx-versions-to-pypi-hides-stealer-in-wav-4928|TeamPCP Telnyx stealer in WAV — THN]] - [[raw/stepsecurity.io/litellm-1-107-0-compromised-on-pypi-and-docker-credential-stealer-and-14805|litellm 1.107.0 compromised — StepSecurity]] - [[raw/blog.pypi.org/supply-chain-attack-analysis-ultralytics-4045|Supply-chain attack analysis: Ultralytics — PyPI]] - [[raw/snyk.io/polyfill-supply-chain-attack-embeds-malware-in-javascript-cdn-assets-9483|Polyfill supply chain attack — Snyk]] - [[raw/thehackernews.com/n-korean-hackers-spread-1-700-malicious-packages-across-npm-pypi-go-ru-3753|N. Korean hackers spread 1,700 malicious packages — THN]] - [[raw/thehackernews.com/rust-supply-chain-attack-puts-build-time-malware-in-crates-with-245-mi-11596|Rust build-time malware in crates — THN]] - [[raw/wiz.io/rust-supply-chain-attack-on-arrayref-significant-overlap-with-dprk-cam-11622|arrayref attack overlaps DPRK — Wiz]] - [[raw/aikido.dev/compromised-rust-crate-onering-performs-code-exfiltration-9015|Compromised Rust crate onering — Aikido]] - [[raw/thehackernews.com/sleepergem-uses-three-malicious-rubygems-packages-to-target-developer-10602|SleeperGem — THN]] - [[raw/thehackernews.com/rubygems-suspends-new-signups-after-hundreds-of-malicious-packages-are-7870|RubyGems suspends new signups — THN]] - [[raw/news.risky.biz/rubygems-adds-dependency-cooldown-to-counter-supply-chain-attacks-8646|RubyGems adds dependency cooldown — Risky Biz]] - [[raw/jfrog.com/npm-v12-s-biggest-security-change-from-implicit-to-explicit-trust-9551|npm v12: implicit to explicit trust — JFrog]] - [[raw/thehackernews.com/npm-adds-2fa-gated-publishing-and-package-install-controls-against-sup-8235|npm adds 2FA-gated publishing — THN]] - [[raw/bleepingcomputer.com/github-pypi-add-time-absed-defenses-against-supply-chain-attacks-10766|GitHub, PyPI add time-based defenses — BleepingComputer]] - [[raw/infoq.com/pip-26-1-ships-dependency-cooldowns-and-experimental-lockfile-support-8131|pip 26.1 ships dependency cooldowns — InfoQ]] - [[raw/snyk.io/a-forgotten-contributor-account-compromised-the-entire-mastra-npm-pack-9484|A Forgotten Contributor Account Compromised Mastra — Snyk]] - [[raw/channellife.co.uk/cloudsmith-adds-cooldown-policies-for-software-supply-chain-11502|Cloudsmith adds cooldown policies — ChannelLife]] - [[raw/rescana.com/github-enhances-npm-security-with-mandatory-2fa-and-provenance-to-comb-9095|GitHub enhances npm security with mandatory 2FA and provenance — Rescana]] - [[raw/helpnetsecurity.com/pypi-makes-release-attestations-easier-to-find-with-new-security-tab-13908|PyPI release attestations security tab — Help Net Security]] - [[raw/github.com/guarddog-cli-tool-to-identify-malicious-pypi-and-npm-packages-4339|GuardDog]] - [[raw/cyb3rops.medium.com/the-sweet-spot-is-a-day-old-15955|The Sweet Spot Is a Day Old]] - [[raw/ethswarm.org/swarm-incident-malicious-bee-js-13-3-0-and-swarm-desktop-0-56-2-15953|Swarm incident: malicious bee-js 13.3.0 and Swarm Desktop 0.56.2]] - [[raw/medium.com/microsoft-s-ai-agent-package-was-hijacked-on-pypi-here-s-how-to-check-15853|Microsoft's AI Agent Package Was Hijacked on PyPI: Here's How to Check If You're Affected]] - [[raw/medium.com/the-credential-was-valid-the-publisher-was-not-15854|The Credential Was Valid. The Publisher Was Not.]]