All news

TrapDoor Supply Chain Attack Hits npm, PyPI, CratesIO

TrapDoor malware spreads credential-stealing payloads across npm, PyPI, and CratesIO. Learn how the supply chain attack works and how to protect your projects.

May 25, 2026VibeWShield News Agentthehackernews.com
Editorial note: This article was generated by VibeWShield's AI news agent based on the original report. It has been reviewed for accuracy but may contain AI-generated summaries. Always verify critical details from the original source.

TrapDoor Supply Chain Attack Targets npm, PyPI, and CratesIO

A coordinated supply chain attack dubbed TrapDoor is actively spreading credential-stealing malware across three major package registries: npm, PyPI, and CratesIO. Security researchers confirmed the campaign is targeting developer machines directly through dependencies pulled during normal build processes. If your project installs packages from any of these registries without lockfile verification or integrity checks, your credentials may already be at risk.

The attack is not theoretical. Malicious packages mimicking popular libraries were published with near-identical names, a classic typosquatting approach, but TrapDoor goes further. Some packages were injected as transitive dependencies, meaning developers never directly installed the malicious code. It arrived silently through a trusted package that had itself been compromised.

How the TrapDoor Credential Stealer Works

Once a poisoned package is installed, TrapDoor executes a postinstall script that runs immediately during the dependency resolution phase. For npm this happens via the scripts.postinstall field in package.json. PyPI equivalents abuse setup.py or pyproject.toml hooks. CratesIO packages leverage build scripts (build.rs) that run at compile time.

The payload scans for stored credentials in predictable locations. Browser credential stores, SSH keys, .env files, cloud provider configuration files (AWS ~/.aws/credentials, GCP application default credentials), and CI/CD environment variables are all targeted. Exfiltration happens over HTTPS to attacker-controlled infrastructure, which makes it difficult to catch on standard network monitors without deep inspection.

The stealth here is deliberate. Postinstall hooks are a legitimate feature. Most developers never audit them. TrapDoor exploits exactly that gap between functionality and visibility.

What Developers Are Actually Losing

The immediate risk is credential theft. Stolen AWS keys, GitHub tokens, and database passwords give attackers direct access to production infrastructure. A single compromised developer machine can expose an entire organization's cloud environment.

Secondary risk is pipeline contamination. If a CI/CD runner installs a poisoned package, the stolen credentials include the runner's service account tokens. Those tokens often carry elevated permissions. From there, attackers can push malicious code into production builds, exfiltrate source code, or pivot into internal systems.

Rust developers using CratesIO may feel their ecosystem is lower-risk. It is not. Build scripts in Rust run arbitrary code with full system access. The attack surface is identical.

How to Defend Against Supply Chain Attacks Like TrapDoor

Start by auditing your dependency tree. Run npm audit, pip-audit, or cargo audit and treat unexpected packages as suspicious until verified.

Lock your dependencies. Use package-lock.json, poetry.lock, or Cargo.lock and commit those files. Verify checksums against known-good states before deploying.

Restrict postinstall hooks where possible. In npm, you can disable lifecycle scripts with npm install --ignore-scripts for packages that don't require them. Review any package that ships a postinstall, preinstall, or prepare script before allowing it in production builds.

Adopt a policy of minimal permissions in CI/CD environments. Runners should not have credentials scoped beyond what the current build requires. Rotate tokens regularly and alert on anomalous usage.

You can also scan your web application's exposed endpoints for signs of compromise or misconfiguration using automated tooling at VibeWShield's free scanner. Catching exposed secrets before attackers do is significantly cheaper than responding to an incident afterward.

For deeper reading on related risks, see our breakdown of dependency confusion attacks.

FAQ

How do I check if a package I installed contains TrapDoor malware? Cross-reference installed packages against known malicious package lists published by security researchers. Tools like socket.dev for npm and pip-audit for Python can flag suspicious packages. Review postinstall scripts manually for any network calls or file system reads outside the package directory.

Does using a private registry protect me from TrapDoor? Partially. Private registries reduce exposure to typosquatting but do not eliminate risk if your registry mirrors public packages without integrity verification. Ensure your registry enforces checksum validation and alerts on newly mirrored packages.

Are Rust developers at higher risk because CratesIO has less security tooling? The ecosystem does have fewer automated scanning options compared to npm or PyPI, which means manual review matters more. Always inspect build.rs files in unfamiliar crates before including them as dependencies.


Your dependencies are a live attack surface. Scan your application now at VibeWShield to identify exposed credentials and vulnerable endpoints before attackers find them first.

Free security scan

Is your app vulnerable to similar attacks?

VibeWShield automatically scans for these and 18 other security checks in under 3 minutes.

Scan your app free