Skip to content
RCE Write-up Intermediate

Axios npm compromise—Recreation & PoC write-up

A malicious npm package used a postinstall script to run code automatically during installation, which sent system information to an attacker-controlled server. An attacker could execute arbitrary code on a victim's machine simply by getting them to install a package that depends on the malicious one.

medium.com

Published on medium.com

From what I understood reading the Supply Chain Attack on Axios Pulls Malicious Dependency from npm from Socket.dev, the attacker added a hidden dependency which executed code during install. So just running npm install was enough to trigger it.

Akshatshirsat, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the package manager runs postinstall scripts from dependencies without sufficient sandboxing or user consent, allowing arbitrary code execution during installation.

Impact

An attacker could execute arbitrary code and exfiltrate system information from any machine that installs the package, with no user interaction beyond the install command.

What the attacker needed

Victim runs npm install on a package with the dependency

How it was found

  1. Create a malicious package with a postinstall script that sends data to an attacker server.
  2. Create a normal-looking package that depends on the malicious package.
  3. Set up an attacker server to receive the data.
  4. On the victim machine, install the normal-looking package from a git repository.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

When you install a software package, it can run setup scripts automatically. In this case, a hidden dependency ran a script that sent your computer's details to an attacker. You don't need to open the app; just installing it is enough.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.