Posted in

CanisterWorm Spreads Through npm Accounts Stealing Tokens

A new supply chain malware campaign called CanisterWorm is targeting the npm ecosystem by compromising publisher accounts and spreading malicious package updates. The worm steals npm authentication tokens and automatically propagates itself across developer-maintained packages, creating a self-amplifying supply chain attack. ⚠️

By hiding malicious code inside routine version updates, the campaign turns trusted developer tools into credential-stealing delivery mechanisms.


How CanisterWorm Works

The attack begins when a developer installs a compromised npm package. A malicious postinstall script runs automatically and deploys a Python-based backdoor on the system.

Initial Infection Flow

  1. Developer installs compromised package
  2. postinstall hook executes automatically
  3. Python backdoor dropped on host
  4. Persistent service created
  5. npm tokens harvested
  6. Worm spreads to publisher packages
  7. Malicious updates published

This chain reaction allows a single compromised developer to infect dozens of downstream packages.


Token Theft and Autonomous Spread

The worm searches for authentication credentials in multiple locations.

Credential Sources

  • .npmrc files
  • User home directory configs
  • System-wide npm configuration
  • Environment variables
  • CI/CD pipeline secrets

Once tokens are collected, the worm:

  • Queries npm registry
  • Identifies owned packages
  • Increments patch versions
  • Publishes poisoned updates automatically

Persistence Mechanism

On Linux systems, the worm registers a background service.

Persistence Details

  • Service name: pgmon
  • Registered via systemd
  • Survives reboots
  • Runs silently in background

Command-and-Control Infrastructure

CanisterWorm communicates with a decentralized backend.

C2 Characteristics

  • Uses Internet Computer Protocol (ICP) canister
  • Blockchain-hosted endpoint
  • Dead-drop communication
  • Blends with normal web traffic

This architecture makes network detection significantly harder.


Files and Artifacts Created

The worm stores data in temporary directories.

Known File Paths

  • /tmp/pglog – payload storage
  • /tmp/.pg_state – execution tracking

These artifacts indicate possible compromise.


Why This Attack Is Dangerous

  • Self-propagating behavior
  • Token theft and reuse
  • Trusted package poisoning
  • Silent execution via postinstall
  • Decentralized command channel
  • Hard-to-detect infrastructure

Supply Chain Impact

One compromised developer account can:

  • Infect multiple packages
  • Impact thousands of downstream users
  • Poison CI/CD pipelines
  • Spread across organizations
  • Enable credential reuse attacks

Detection Indicators

Security teams should monitor for:

  • Unexpected postinstall script execution
  • Unknown systemd services
  • npm token access anomalies
  • Python processes during npm install
  • Temporary files in /tmp/pglog
  • Unauthorized package version bumps

Immediate Response Actions

Developers using affected packages should assume compromise.

Required Steps

  • Rotate npm publishing tokens
  • Revoke CI/CD secrets
  • Delete .npmrc tokens
  • Stop pgmon service
  • Remove persistence files
  • Clean node_modules directories
  • Rebuild dependencies from trusted sources

Linux Cleanup Commands

Recommended remediation includes:

  • Stop background service
  • Disable persistence
  • Remove temporary files
  • Reinstall dependencies

These steps help remove active infection.


Preventive Security Measures

Developer Best Practices

  • Use scoped npm tokens
  • Enable 2FA on npm accounts
  • Audit package updates carefully
  • Monitor publishing activity
  • Limit CI/CD token permissions

Defensive Configuration

  • Disable install scripts when possible
  • Validate dependency integrity
  • Monitor dependency version changes
  • Implement package allowlists

Risk Impact Analysis

Risk AreaImpact
Credentialsnpm token theft
Supply ChainPackage poisoning
CI/CDPipeline compromise
DistributionMalicious code spread
DevelopmentBackdoor persistence

Key Takeaways

  • CanisterWorm is self-propagating
  • Steals npm authentication tokens
  • Uses postinstall script execution
  • Publishes malicious package updates
  • Targets developer supply chain

Conclusion

CanisterWorm highlights the growing risk of self-propagating supply chain malware in open-source ecosystems. By stealing npm tokens and automatically poisoning packages, attackers can rapidly expand their reach across developer communities.

Organizations should prioritize:

  • Token security
  • Dependency monitoring
  • CI/CD hardening
  • Behavioral detection

Securing developer workflows is critical to preventing large-scale software supply chain compromises.

Leave a Reply

Your email address will not be published. Required fields are marked *