North Korean Hackers Used Mastra npm Packages to Target Developers and CI/CD Pipelines


North Korean state-backed hackers poisoned more than 140 npm packages in the Mastra ecosystem, turning a trusted developer dependency chain into a malware delivery channel for workstations and CI/CD pipelines.

Microsoft Threat Intelligence attributes the campaign with high confidence to Sapphire Sleet, a North Korean threat actor also known as BlueNoroff. The group mainly targets the financial sector, cryptocurrency companies, developers, and software supply chains.

The attack started with the compromise of the ehindero npm maintainer account, which had publishing rights across the Mastra package environment. The attackers used that access to publish poisoned package versions that added a malicious dependency called easy-day-js.

Mastra npm Packages Were Poisoned Through a Fake dayjs Dependency

Mastra is an open-source TypeScript framework for building AI agents and AI-powered applications. Because it is used in developer environments, a compromise can expose secrets such as API keys, cloud credentials, npm tokens, GitHub tokens, and cryptocurrency wallet data.

The malicious package, easy-day-js, was designed as a typosquat of the popular dayjs JavaScript date library. Attackers first published a clean bait version, then released a weaponized version with a postinstall script that ran automatically during package installation.

According to StepSecurity, the affected Mastra packages had a combined weekly download count of more than 1.1 million. That made the campaign especially dangerous for automated development workflows that install dependencies without manual review.

How the Mastra npm Attack Worked

StageWhat happenedWhy it mattered
Account compromiseThe ehindero npm maintainer account was taken over.The account had publish rights across the Mastra ecosystem.
Typosquat packageAttackers published easy-day-js to imitate dayjs.The fake package looked familiar enough to avoid quick suspicion.
Mass package poisoningMore than 140 Mastra packages were republished with easy-day-js as a dependency.Developers and CI/CD systems could pull the malicious dependency during normal installs.
Postinstall executionThe package ran setup.cjs during installation.The malware executed even if developers never imported the package in application code.
Second-stage payloadThe dropper contacted attacker infrastructure and launched a hidden Node.js payload.The attackers gained a path to collect system data, secrets, and wallet-related information.

The public Mastra GitHub issue noted that [email protected] was published with easy-day-js as a new dependency and that the malicious postinstall script downloaded and executed code from attacker infrastructure.

The same issue flagged several warning signs. The affected package version was manually published rather than through the usual GitHub Actions pipeline, npm provenance was missing, and easy-day-js was not referenced in the real Mastra codebase.

Microsoft says the payload ran during installation, which means developer machines and CI/CD pipelines could have been exposed through a routine npm install or npm update. The risk did not depend on whether the package was later used by the application.

The Malware Targeted Secrets, Wallets, and Developer Systems

Once installed, easy-day-js launched an obfuscated dropper that disabled TLS certificate verification, contacted command-and-control infrastructure, downloaded a second-stage payload, and ran it as a detached hidden process.

The second-stage implant collected host details, installed applications, running processes, browser history, and cryptocurrency wallet browser extension data. Microsoft said it checked for 166 wallet extension IDs across Chrome, Edge, and Brave profiles.

End-to-end attack chain (Source – Microsoft)

The malware also used persistence methods across major operating systems. On Windows, it used a registry Run key. On macOS, it used a LaunchAgent. On Linux, it used a systemd user service. The file and service names were designed to look like normal Node.js tooling.

Why CI/CD Pipelines Were at Risk

CI/CD systems are attractive targets because they often hold deployment secrets, package publishing tokens, cloud credentials, and source code access. In this case, the malware ran during dependency installation, a step that many pipelines perform automatically.

For development teams, the biggest concern is not only a compromised local workstation. A poisoned package can also expose build servers and deployment systems, giving attackers a path toward downstream software tampering or wider credential theft.

Microsoftโ€™s analysis also links the campaign to broader Sapphire Sleet tradecraft, including post-compromise activity and a separate npm supply chain compromise affecting Axios in April 2026.

Key Indicators From the Campaign

TypeIndicatorPurpose
npm packageeasy-day-jsMalicious typosquat of dayjs
npm accountehinderoCompromised Mastra package publisher
npm accountsergey2016Publisher of easy-day-js
IP address23.254.164[.]92Primary command-and-control server
IP address23.254.164[.]123Secondary command-and-control address
Domainteams[.]onweblive[.]orgPowerShell backdoor delivery domain
Domainmaskasd[.]comPost-compromise beacon domain
File artifact$TMPDIR/.pkg_historyInstall path marker for compromised package activity
File artifact$TMPDIR/.pkg_logsMarker containing encoded easy-day-js data

StepSecurityโ€™s timeline says the attacker used semantic versioning to widen the impact. The dependency was added as easy-day-js@^1.11.21, which allowed npm to resolve installs to the later malicious 1.11.22 version once it appeared on the registry.

The Mastra project remains a widely used AI development framework, and its official site describes support for agents, workflows, memory, observability, and deployment into Node.js-compatible environments. That developer focus made the ecosystem a high-value target for a supply chain attack.

The incident also shows why npm postinstall scripts remain risky. They can run automatically during normal package installation, which gives attackers an execution path before developers review or run the application itself.

What Developers and Security Teams Should Do

Teams that installed affected Mastra packages should review local developer systems, build runners, and package-lock files for easy-day-js. They should also look for unexpected JavaScript files in home or temporary directories and review CI/CD logs for suspicious postinstall execution.

Security teams should rotate credentials, tokens, API keys, and wallet-related secrets that were present on any potentially exposed system. This includes GitHub tokens, npm tokens, cloud credentials, LLM API keys, database credentials, and deployment secrets.

The obfuscated setup.cjs dropper (Source – Microsoft)
  • Review dependency trees for affected Mastra and @mastra package versions.
  • Search node_modules and lock files for easy-day-js.
  • Pin known-good versions where possible.
  • Use npm install with –ignore-scripts when postinstall scripts are not required.
  • Rotate credentials and API keys from potentially exposed systems.
  • Block known command-and-control IP addresses at the network perimeter.
  • Audit CI/CD logs for unexpected outbound connections.
  • Review developer workstations for persistence artifacts.

Sapphire Sleet Continues to Target the Software Supply Chain

Sapphire Sleet has a long history of financially motivated cyber activity tied to North Korea. The group has targeted cryptocurrency firms, developers, financial organizations, and software supply chains to steal credentials and crypto assets.

The GitHub disclosure thread also showed how quickly the community identified suspicious publishing behavior. That public reporting helped connect the unusual package changes, missing provenance, new dependency, and malicious setup script.

The incident adds to a growing list of attacks where trusted development tools became delivery mechanisms for malware. Developers should treat dependency installation as a security boundary, not just a build step.

StepSecurityโ€™s research and Microsoftโ€™s follow-up analysis both point to the same lesson: supply chain attacks can spread fast when attackers control a trusted maintainer account, especially inside ecosystems used by modern AI and cloud development teams.

For teams using Mastra, the immediate priority is to confirm whether affected versions were installed, rotate exposed secrets, and check both developer machines and automated build systems for signs of compromise.

FAQ

What happened in the Mastra npm supply chain attack?

Attackers compromised an npm maintainer account with publish rights across the Mastra ecosystem and republished more than 140 packages with a malicious dependency called easy-day-js. The package ran a postinstall script that downloaded and executed a second-stage payload.

Who was behind the Mastra npm compromise?

Microsoft attributes the activity with high confidence to Sapphire Sleet, a North Korean state-backed threat actor also known as BlueNoroff. The group is known for targeting financial organizations, cryptocurrency assets, developers, and software supply chains.

Why were CI/CD pipelines at risk?

The malware executed during npm installation through a postinstall script. That means automated build systems and CI/CD pipelines could run the malicious code during normal dependency installation, even if the package was never imported in application code.

What did easy-day-js do?

easy-day-js acted as a malicious typosquat of the dayjs library. Its weaponized version launched an obfuscated postinstall dropper, contacted attacker-controlled infrastructure, downloaded a second-stage payload, and helped collect system and wallet-related data.

What should developers do after the Mastra npm attack?

Developers should check dependency trees, node_modules folders, and lock files for easy-day-js, review CI/CD logs for suspicious postinstall activity, rotate credentials and API keys from exposed systems, and use –ignore-scripts when package lifecycle scripts are not required.

Readers help support VPNCentral. We may get a commission if you buy through our links. Tooltip Icon

Read our disclosure page to find out how can you help VPNCentral sustain the editorial team Read more

User forum

0 messages