Back to Blog
Industry Insights
11 min read
Mar 31, 2026

NPM Supply Chain Attack Prevention: Axios Trojan Breakdown

Fajarix breaks down the Axios NPM compromise to help CTOs prevent supply chain attacks. Learn dependency auditing, secure CI/CD pipelines, and trojan defense.

The Axios NPM Compromise: A Wake-Up Call for Every Software Team

On March 31, 2026, two poisoned versions of Axios — the JavaScript HTTP client with over 300 million weekly downloads — were published to NPM using a hijacked maintainer account. The malicious releases, axios@1.14.1 and axios@0.30.4, silently injected a remote access trojan (RAT) into every machine that ran npm install. No alarm sounded. No code review caught it. The attack bypassed GitHub Actions, OIDC trusted publishing, and every automated check the project had in place. If your startup or enterprise ships JavaScript — and statistically, you almost certainly do — this incident is the single most important case study you will read this year on why npm supply chain attack prevention must be a board-level priority, not a developer afterthought.

npm supply chain attack prevention is the discipline of securing every link in the software dependency chain — from the public registries where open-source packages are hosted, through the CI/CD pipelines that build and deploy your code, to the developer workstations where packages are first installed — against the injection of malicious code via compromised, typosquatted, or counterfeit packages. It encompasses dependency auditing, lockfile enforcement, provenance verification, runtime anomaly detection, and incident response planning, all designed to ensure that the third-party code you trust has not been tampered with before it reaches production.

Anatomy of the Attack: How Axios Was Weaponised

Step 1 — Maintainer Account Hijack

The attacker compromised the jasonsaayman NPM account — the primary maintainer of Axios. The account email was silently changed to an anonymous ProtonMail address (ifstap@proton.me). With full publishing rights, the attacker could push releases that appeared identical to legitimate ones in the NPM registry. Every prior Axios 1.x release was published via GitHub Actions with NPM's OIDC Trusted Publisher mechanism, cryptographically binding the publish event to a verified workflow. The malicious 1.14.1 broke that pattern entirely, published manually via a stolen long-lived NPM access token with no OIDC binding and no gitHead. There is no corresponding commit or tag in the Axios GitHub repository — the release exists only on NPM.

Step 2 — Staging a Decoy Dependency

Roughly 18 hours before the Axios releases, the attacker published plain-crypto-js@4.2.0 from a throwaway account (nrwise@proton.me). This version was a clean copy of the legitimate crypto-js library — same description, same author attribution, same repository URL. Its sole purpose was to establish publishing history so the package would not trigger zero-history alerts from security scanners. A day later, plain-crypto-js@4.2.1 followed, this time containing an obfuscated setup.js postinstall script — the actual RAT dropper.

Step 3 — Injecting the Trojan into Axios

Both poisoned Axios versions added plain-crypto-js@4.2.1 as a runtime dependency. The package is never imported anywhere in the Axios source code. Its only function is to execute the postinstall hook, which deploys platform-specific second-stage payloads for macOS (AppleScript), Windows (VBScript + PowerShell), and Linux (Python). After execution, the malware deletes itself and replaces its own package.json with a clean stub, leaving zero forensic evidence in node_modules for any developer who inspects the folder after the fact.

If you have installed axios@1.14.1 or axios@0.30.4, assume your system is compromised. Pin to the safe versions: axios@1.14.0 (1.x) or axios@0.30.3 (0.x). Rotate all secrets and credentials on affected machines immediately.

Why Traditional Security Fails Against NPM Supply Chain Attacks

Most engineering leaders we speak to at Fajarix AI automation engagements share a common misconception: "We run npm audit, so we are covered." This is dangerously wrong. npm audit checks for known vulnerabilities in already-disclosed CVEs. A zero-day supply chain attack — where the malicious code is published minutes ago and has no CVE — will sail through npm audit with a clean bill of health. The Axios compromise was live for hours before any advisory was filed.

A second misconception is that lockfiles alone prevent supply chain attacks. Lockfiles (package-lock.json, yarn.lock, pnpm-lock.yaml) are essential, but they protect you only if you already have a clean dependency tree locked and you never run commands that update the lockfile without review. A developer running npm install axios@latest or a CI pipeline configured with npm install instead of npm ci will happily resolve and install the poisoned version, then update the lockfile to match.

The Real Attack Surface

Modern JavaScript projects average between 300 and 1,200 transitive dependencies. Each one is a potential entry point. The Axios attack exploited a postinstall script — a feature NPM provides for legitimate build steps like compiling native modules. Attackers love postinstall hooks because they execute arbitrary code with the permissions of the installing user, often root in Docker-based CI environments. Your SAST scanner will never flag this because the malicious code is not in your source — it is in a nested dependency you never explicitly chose.

NPM Supply Chain Attack Prevention: A Comprehensive Playbook

Below is the layered defence strategy we implement for clients across our web development services and mobile development practices. Each layer addresses a different phase of the attack lifecycle.

Layer 1 — Dependency Auditing and Provenance Verification

  1. Enable NPM provenance checks. Starting with npm CLI v9.5.0, you can verify that a package was built from a known source repository and CI system using npm audit signatures. The Axios attack would have been flagged immediately: axios@1.14.1 had no OIDC provenance attestation, while every legitimate 1.x release did.
  2. Use Socket.dev for real-time dependency risk scoring. Socket analyses packages for install scripts, obfuscated code, network calls, filesystem access, and other behavioral signals — exactly the indicators present in plain-crypto-js@4.2.1. Integrate Socket as a GitHub App so every PR that modifies package.json is automatically scanned before merge.
  3. Pin exact versions and review every update. Replace semver ranges (^1.14.0) with exact versions (1.14.0) in package.json. Use Renovate or Dependabot to propose updates as pull requests, giving your team a review gate before any new version enters the codebase.
  4. Audit transitive dependencies. Run npm ls --all after any dependency change to inspect the full tree. Look for packages you do not recognise — especially those with postinstall hooks. The command npm ls --all | grep postinstall is a quick first-pass filter.
  5. Maintain a Software Bill of Materials (SBOM). Generate SBOMs with tools like CycloneDX or SPDX on every build. An SBOM makes it trivial to answer the question "Are we affected?" within minutes of any future advisory.

Layer 2 — Hardening CI/CD Pipelines

The Axios attacker published manually via the NPM CLI because the compromised maintainer held a long-lived access token. Your CI/CD pipeline is the single most important control point for preventing this class of attack.

  • Enforce npm ci in all pipeline steps. Unlike npm install, npm ci installs exactly what is in the lockfile and fails if the lockfile is out of sync with package.json. This prevents any surprise resolution of a new malicious version.
  • Disable postinstall scripts in CI. Pass --ignore-scripts to npm ci and explicitly run only the build scripts you need. This single flag would have completely neutralised the Axios RAT dropper in your pipeline. If a legitimate dependency requires a postinstall step (e.g., esbuild native binaries), allowlist it explicitly.
  • Use ephemeral, scoped tokens. Replace long-lived NPM tokens with OIDC-based trusted publishing (GitHub Actions) or short-lived automation tokens scoped to specific packages. The attacker exploited a classic token with broad publish rights — a pattern that OIDC eliminates entirely.
  • Implement StepSecurity Harden-Runner. This GitHub Action monitors network egress, process trees, and file system mutations during workflow execution. In StepSecurity's own analysis of the Axios attack, Harden-Runner captured the full kill chain: the C2 contact, the payload download, and the self-cleanup — all in real time.
  • Require two-person approval for dependency changes. Configure your repository's CODEOWNERS file so that any change to package.json, package-lock.json, or CI workflow files requires review from a designated security owner.

Layer 3 — Runtime and Network Monitoring

Even with perfect pipeline hygiene, developer workstations remain vulnerable. A developer running npm install locally can still trigger the postinstall dropper.

  • Monitor outbound network connections from build environments. The Axios RAT contacted a live command-and-control server. Network monitoring tools like Falco, Sysdig, or cloud-native VPC flow logs can detect unexpected egress from development containers and CI runners.
  • Restrict developer machine privileges. Run npm install in sandboxed environments (containers, VMs, or tools like Docker Dev Environments) where postinstall scripts cannot access host credentials, SSH keys, or cloud IAM tokens.
  • Deploy endpoint detection and response (EDR). The Axios dropper launched platform-specific child processes: AppleScript on macOS, VBScript + PowerShell on Windows, and Python on Linux. A modern EDR agent would flag these anomalous process trees spawned from a Node.js parent process.

Layer 4 — Incident Response Readiness

The question is not if a supply chain attack will affect your organisation, but when. Preparation dramatically reduces blast radius and recovery time.

  • Maintain a dependency inventory. Know which versions of which packages are deployed in which environments. Without this, answering "Are we affected?" takes days instead of minutes.
  • Pre-draft incident response runbooks. Include steps for: identifying affected systems via SBOM, rotating credentials, rebuilding from clean lockfiles, scanning for indicators of compromise (IOCs), and notifying downstream consumers.
  • Conduct tabletop exercises. Walk your engineering and security teams through a simulated supply chain attack scenario at least once per quarter. The Axios incident is an excellent real-world case study for this purpose.

Indicators of Compromise (IOCs) from the Axios Attack

For teams conducting forensic analysis, here are the key IOCs published by StepSecurity and corroborated by our own review:

  • Malicious NPM packages: axios@1.14.1, axios@0.30.4, plain-crypto-js@4.2.0, plain-crypto-js@4.2.1
  • Attacker-controlled emails: ifstap@proton.me, nrwise@proton.me
  • Network indicators: Outbound connections from node processes to unfamiliar IPs/domains during or immediately after npm install. Check CI runner and developer machine logs for connections initiated by setup.js.
  • File system indicators: A plain-crypto-js directory in node_modules with a suspiciously clean package.json (the self-cleanup replaces the original with a stub). Look for the absence of setup.js — the dropper deletes itself after execution.
  • Process indicators: Child processes spawned from node setup.js — specifically osascript (macOS), cscript/powershell (Windows), or python3 (Linux) running immediately after an npm install operation.

What CTOs and Startup Founders Must Do Now

If you are a technical leader responsible for a product built on JavaScript or TypeScript, the Axios compromise demands immediate action — not next sprint, not next quarter, today. Here is your prioritised checklist:

  1. Check your lockfiles immediately. Search for axios@1.14.1, axios@0.30.4, or plain-crypto-js across all repositories. Use grep -r "plain-crypto-js" . or your monorepo's search tooling.
  2. Pin Axios to safe versions. axios@1.14.0 for 1.x, axios@0.30.3 for 0.x. Update lockfiles and deploy.
  3. Rotate all secrets on affected systems. If any developer machine or CI runner installed the poisoned version, treat every credential on that system as compromised: NPM tokens, AWS keys, database passwords, API secrets, SSH keys.
  4. Disable postinstall scripts by default. Add --ignore-scripts to your .npmrc and CI configuration. Allowlist only the packages that genuinely require postinstall hooks.
  5. Enable NPM provenance verification. Add npm audit signatures to your CI pipeline. Any package without a valid provenance attestation should trigger a build failure.
  6. Deploy Socket.dev or a comparable behavioural analysis tool. Static vulnerability databases are insufficient against zero-day supply chain attacks. You need behavioural analysis that detects what packages do, not just what CVEs they match.
  7. Commission a dependency security audit. If you lack in-house expertise, engage a team that specialises in securing JavaScript supply chains. Our staff augmentation practice can embed senior security engineers directly into your team to conduct this audit and implement the controls described above.
The Axios attack is not an anomaly. It is the new normal. The NPM ecosystem has seen compromises of event-stream, ua-parser-js, colors, node-ipc, and now axios. Each attack is more sophisticated than the last. The only responsible posture is defence in depth.

How Fajarix Helps Clients Prevent Supply Chain Attacks

At Fajarix, we do not treat dependency security as an afterthought bolted onto the final sprint. It is embedded into every project from day one. When we build web applications, mobile apps, or AI-powered automation systems, we implement the full layered defence described in this article: exact version pinning, lockfile-only installs, postinstall script restrictions, provenance verification, SBOM generation, and runtime monitoring.

For existing products, our security audit service provides a comprehensive review of your dependency tree, CI/CD pipeline configuration, NPM token management, and incident response readiness. We deliver a prioritised remediation plan with specific tooling recommendations and implementation support. Our AI automation capabilities also allow us to build custom monitoring bots that continuously scan your dependency graph for behavioural anomalies and alert your team in Slack, Teams, or PagerDuty within minutes of a suspicious publish event.

The Axios compromise is a stark reminder that the code you do not write — the open-source dependencies you trust — can be the most dangerous code in your stack. Proactive npm supply chain attack prevention is not optional. It is the cost of shipping software responsibly in 2026.

Ready to put these insights into practice? The team at Fajarix builds exactly these solutions. Book a free consultation to discuss your project.

Ready to build something like this?

Talk to Fajarix →