Skip to main content
RAT in the Registry: npm Supply Chain Attack Targets Alibaba DevelopersIncident
4 min readFor Security Engineers

RAT in the Registry: npm Supply Chain Attack Targets Alibaba Developers

What Happened

Between November 2023 and early 2025, attackers published 18 malicious npm packages targeting developers using Alibaba Group's internal tools. These packages had names like lib-mtop, mimicking legitimate Alibaba dependencies to exploit naming confusion.

Once installed, the packages deployed a multi-stage loader that fetched a remote JavaScript payload using curl. This payload delivered a cross-platform remote access trojan (RAT) capable of command execution and lateral movement across compromised workstations.

Socket's analysis showed the attack targeted developers in technology and finance sectors within Alibaba's ecosystem. The attackers maintained these packages for over a year, refining their delivery methods.

Timeline

November 2023: First malicious package lib-mtop published to npm registry.

November 2023 - Early 2025: Attackers maintain and update packages, adding variants to evade detection.

Early 2025: Socket researchers identify the malicious package family and publish their findings.

Current status: Packages removed from npm, but organizations that installed them may still be compromised.

Which Controls Failed or Were Missing

The attack succeeded due to missing or misconfigured defenses:

Dependency verification: Teams installed packages without verifying their provenance or comparing checksums with known sources. The similarity to private Alibaba packages led developers to assume these were internal tools, but no verification caught the discrepancy.

Network egress controls: The loader used curl to fetch remote payloads. If your build environment allows arbitrary outbound connections during package installation, it provides attackers a direct channel for payload delivery.

Package registry monitoring: The malicious packages persisted for over a year. Organizations lacked real-time monitoring of their dependency trees to detect new or suspicious packages.

Least privilege in build environments: The RAT achieved command execution and lateral movement, indicating build processes ran with excessive permissions. Properly isolating build environments limits the damage when a malicious package executes.

What the Standards Require

PCI DSS v4.0.1 Requirement 6.3.2 mandates secure development for bespoke and custom software, including third-party components. If you're processing payment data, you can't claim compliance while blindly trusting npm packages.

OWASP Top 10 2021: A06:2021, Vulnerable and Outdated Components addresses this risk. You're vulnerable if you don't know the versions of all components you use, including transitive dependencies like lib-mtop.

NIST 800-53 Rev 5 Control SA-12 (Supply Chain Protection) requires security safeguards against supply chain threats. Control enhancement SA-12(11) specifically addresses penetration testing of supply chain elements. Test whether your build process would catch a malicious package.

ISO/IEC 27001:2022 Annex A.8.30 (Outsourced Development) requires security controls for externally developed software. Open-source packages count as externally developed. You need documented procedures for evaluating and accepting external code.

Lessons and Action Items for Your Team

Implement package verification before installation. Create an internal registry that mirrors only vetted packages. When developers request a new dependency, trigger a review process instead of automatic installation. Tools like Sonatype Nexus or JFrog Artifactory let you proxy npm while enforcing approval workflows.

Lock your dependency versions and verify checksums. Your package-lock.json should specify exact versions with integrity hashes. When you run npm ci in CI/CD, it verifies those hashes. If a package gets compromised and republished with the same version number, the hash mismatch stops installation.

Isolate build environments from production networks. Your CI/CD runners shouldn't have the same network access as your application servers. Use network policies to restrict outbound connections during builds. If a package tries to curl a remote payload, the request should fail.

Monitor your dependency tree continuously. Tools like Socket, Snyk, or GitHub's Dependabot can alert you when new packages appear in your tree or when existing packages exhibit suspicious behavior. Set up alerts for packages that make network requests, access the filesystem outside their directory, or spawn child processes.

Audit installation scripts. npm packages can execute arbitrary code in preinstall, install, and postinstall hooks. Review these scripts before adding dependencies. Disable automatic script execution with npm install --ignore-scripts and explicitly allow only the scripts you've reviewed.

Scope your blast radius. Run builds in containers with minimal permissions. If a malicious package achieves code execution, it should be contained to that container, unable to access credentials, pivot to other systems, or persist beyond the build.

Create an incident response plan for supply chain compromise. If you discover a malicious package in your builds, have procedures to identify which builds used it, determine what credentials or systems those builds could access, rotate compromised credentials, and assess whether production systems were affected. Don't wait for an incident to figure this out.

The npm ecosystem moves fast. Attackers know you're under pressure to ship features, and they're betting you'll skip security checks to meet deadlines. The Alibaba-targeted attack worked because it exploited that pressure. Your defense is process: systematic verification before any package enters your build.

Topics:Incident

You Might Also Like