npm

The rand-user-agent npm Supply Chain Attack

Updated 5 Oct 2026 · Incident date 5 May 2025

rand-user-agent 2.0.83, 2.0.84 and 1.0.110 on npm carried a remote access trojan that let outsiders run commands, from 5 May 2025.

The package builds random user-agent strings and has about 45,000 weekly downloads. The bad code sits in dist/index.js.

What happened

Attackers published three bad versions in early May 2025 with an outdated automation token that had no two-factor protection. The code was not in the GitHub repository.

  • The obfuscated code in dist/index.js opens a permanent connection to an attacker server.
  • It creates a hidden folder ~/.node_modules for its own axios and socket.io-client.
  • It sends the host name, user name, operating system and a UUID.
  • The server can run shell commands and upload files.
  • On Windows, it puts %LOCALAPPDATA%\Programs\Python\Python3127 at the front of the system PATH.

Aikido, which found the problem, reports detection on 6 May 2025. The last clean version, 2.0.82, was seven months old.

Affected versions

  • rand-user-agent 2.0.83 and 2.0.84.
  • rand-user-agent 1.0.110.
  • Clean: 2.0.82. npm removed the malicious versions.
  • A downgrade does not remove the trojan.

Indicators of compromise

  • Command and control: 85.239.62[.]36. Socket.io channel on port 3306 and file upload at port 27017 path /u/f.
  • A hidden folder ~/.node_modules/ that holds axios and socket.io-client.
  • On Windows, a PATH entry for %LOCALAPPDATA%\Programs\Python\Python3127 and that folder on disk.
  • Obfuscated code in dist/index.js of the package.
  • RAT command names: ss_dir, ss_fcd, ss_upf, ss_upd, ss_stop.

How to check

Look for the bad versions in your projects.

npm ls --all rand-user-agent
grep -n 'rand-user-agent' package-lock.json

Look for traces on the machine.

ls -la ~/.node_modules 2>/dev/null
lsof -nP -i | grep '85.239.62.36'

What to do now

  1. Pin rand-user-agent to 2.0.82 or a later clean release.
  2. On any machine that installed a bad version, remove ~/.node_modules and the PATH change. Do a full scan.
  3. Rotate credentials that the machine held.
  4. Block the command server address and search logs for past connections.

What Vigilance would show

These examples show an install hold and the corresponding owner report.

Example install message

Vigilance blocked `rand-user-agent` 2.0.83. This version is too new or changed in a way Vigilance must check first.

Example owner report

Bad update

rand-user-agent 2.0.83

A small text-generating helper gained hidden code that opened a permanent connection letting outsiders run commands.

See what to do now.

No security team? See who reads the alert.

Frequently asked questions

Which versions were compromised?

Versions 2.0.83, 2.0.84 and 1.0.110. Version 2.0.82 is the last clean release.

Does a downgrade remove the trojan?

No. A downgrade stops new infections only. The machine needs a full scan and credential rotation.

Sources

  1. aikido.dev/blog/catching-a-rat-remote-access-trojian-rand-user-agent-supply-chain-compromise
  2. bleepingcomputer.com/news/security/supply-chain-attack-hits-npm-package-with-45-000-weekly-downloads/
  3. securityweek.com/popular-scraping-tools-npm-package-compromised-in-supply-chain-attack/

Send this page to the person who looks after AI at your company.

Email it

More supply chain attacks

All 172 attacks in the library · npm supply chain attacks · How to prevent supply chain attacks

Check the next update before you install it

Vigilance compares the version you trust with the new one. It names the one file that gained a power the old version did not have.

Start the free 14-day trialBrowse the attack library