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.jsopens a permanent connection to an attacker server. - It creates a hidden folder
~/.node_modulesfor its ownaxiosandsocket.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\Python3127at 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-agent2.0.83 and 2.0.84.rand-user-agent1.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 holdsaxiosandsocket.io-client. - On Windows, a PATH entry for
%LOCALAPPDATA%\Programs\Python\Python3127and that folder on disk. - Obfuscated code in
dist/index.jsof 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
- Pin rand-user-agent to 2.0.82 or a later clean release.
- On any machine that installed a bad version, remove
~/.node_modulesand the PATH change. Do a full scan. - Rotate credentials that the machine held.
- 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.
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
Send this page to the person who looks after AI at your company.