Skip to content
Book a Demo

Rand-User-Agent Attack: How It Happened & How to Protect Yourself

Rand-User-Agent Attack: How It Happened & How to Protect Yourself
8:12

Another day, another wake-up call for the software supply chain. In early May 2025, the popular npm package rand-user-agent—with over 45,000 weekly downloads—was compromised in a sophisticated supply chain attack. This incident underscores not only the evolving tactics of attackers, but also the critical gaps many organizations still have in monitoring open-source dependencies, managing non-human identities, and responding to threats buried deep in the software supply chain.

At Vorlon, we know that you can’t always prevent a compromise in third-party code, but you can detect when a breached application, integration, or token starts behaving in unexpected ways. By continuously monitoring activity between SaaS applications, Vorlon helps security teams spot these signals and respond quickly, often before a vendor or package maintainer announces the breach.

How the Attack Unfolded

The attack was first detected by Aikido’s malware analysis system on May 5, 2025. Malicious versions of rand-user-agent, specifically 2.0.83, 2.0.84, and 1.0.110, were published to npm, containing obfuscated code that activated a Remote Access Trojan (RAT).

What made this attack especially insidious was the stealthy way the malware was hidden: the code was tucked away using horizontal scrolling in the source view, making it easy to overlook. Once installed, the package created a hidden directory on the system, established a persistent connection to a command-and-control (C2) server, and enabled attackers to execute arbitrary shell commands via Node’s child_process.exec()—effectively giving them full remote control over infected machines. Multiple security outlets, including Bleeping Computer, SecurityWeek, and SC World, have detailed the technical depth and impact of this compromise.

Root Cause: The Token Nobody Was Watching

The entry point? The legitimate developer’s npm automation token. As reported by Aikido, the token was both outdated and lacked two-factor authentication (2FA), allowing attackers to publish unauthorized versions of the package. This is a classic example of the risks posed by non-human identities—API tokens, CI/CD credentials, and other secrets that often fall through the cracks of traditional security programs.

Attackers are increasingly targeting these “headless” credentials because they often lack basic hygiene controls like rotation, scope restriction, or 2FA.

Why This Attack Matters

This incident is part of a growing trend: attackers targeting semi-abandoned, yet widely-used, open-source packages. As Onsite Computing highlights, these packages often slip under the radar, especially when the original maintainers have moved on but the package is still deeply embedded in thousands of production systems.

Even more concerning is the gap between code repositories (like GitHub) and package registries (like npm). Malicious changes can be published to npm without appearing in the corresponding GitHub repo, leading to a dangerous monitoring blind spot. Most organizations simply aren’t tracking which internal systems and applications consume which third-party dependencies, let alone monitoring for suspicious updates or matching versions across sources.

Lessons Learned and Recommended Actions

  1. Secure Automation Tokens:
    Every automation or deployment token is a potential backdoor. Enforce 2FA, use least privilege, and validate credentials usage against business operations.
  2. Monitor Package Integrity Continuously:
    Set up automated scanning for all dependencies. Cross-check published package versions with corresponding source repositories.
  3. Map Your Dependencies:
    Maintain a real-time inventory of all open-source packages in use, including nested dependencies. Monitor for reported compromises and unusual version changes.
  4. Prepare for Rapid Response:
    Have an incident response playbook specifically for supply chain attacks. Include processes to quickly identify, contain, and remediate affected systems.

How Vorlon Can Help

Vorlon doesn’t inspect the code inside every third-party package or SaaS vendor. Instead, Vorlon’s SaaS ecosystem security platform is built to give security teams continuous, real-world visibility into how applications and identities are actually behaving, especially across the tangled web of SaaS, APIs, and automations that make up your environment.

In the case of an attack like the rand-user-agent npm compromise, Vorlon’s value is in detecting the evidence of a breach before the public headlines:

  • Anomalous API Behavior: Vorlon continuously monitors API activity and data flows between applications, users, and integrations. If a service account, automation token, or machine identity suddenly starts behaving abnormally–such as making unexpected external connections, accessing new data, or communicating at odd hours—Vorlon flags it fast.
  • Outdated or Over-Permissive Tokens: Vorlon inventories secrets and tokens across your SaaS ecosystem, alerting you to risky, dormant, or overly-permissive credentials that could be targeted by attackers.
  • Connecting the Dots in Real Time: When a compromised token is used to access data or trigger unusual actions between applications, Vorlon provides the context—what was accessed, where the data went, and what else might be at risk—so you can respond quickly, even before a compromise is disclosed by a vendor or open-source maintainer.
  • Application Risk Analysis and Profiling: While Vorlon doesn't assess the internal code of an npm package, it assesses the overall security posture and behavior of the SaaS applications and services that might consume such packages. Understanding which applications handle sensitive data and how they connect can help prioritize internal auditing of dependencies for those critical apps.

Vorlon doesn’t need to inspect package code to keep your SaaS ecosystem safe. Instead, it helps you spot the signals of compromise as they play out across your environment, so you can catch supply chain attacks in action and respond before they spread.

Conclusion

The rand-user-agent npm compromise is a powerful reminder: attackers don’t need to breach your perimeter if they can ride in on a trusted dependency. Security teams must treat supply chain risk as a first-class threat, monitoring not just for misconfigurations and vulnerabilities, but for the hidden connections and credentials that can turn a simple package update into a full-blown breach.

For organizations looking to close these gaps, proactive monitoring, secrets management, and rapid incident response are the new foundation for resilience in a world where your next breach might arrive through npm, PyPI, or any other package registry you trust.

If you want to see what’s really happening across your SaaS ecosystem, reach out today.

 


Book a demo to see it in action.

See how it works with a self-serve tour.

Follow us on LinkedIn for the latest SaaS security insights.


 

About the author


Anil Agrawal

Anil Agrawal
Security Researcher at Vorlon

Anil Agrawal is a security researcher at Vorlon specializing in SOC optimization and has over eight years of experience in cybersecurity. Before joining Vorlon, he served as a Solutions Architect at Palo Alto Networks, where he designed advanced automation solutions and cybersecurity strategies for Fortune 500 clients. His career includes technical roles at Syracuse University, where he streamlined incident response processes and conducted malware analysis. Anil holds a Master’s degree in Management Information Systems from Syracuse University with a specialization in Information Security Management. Passionate about mitigating third-party application risks, he focuses on pioneering R&D to address evolving cybersecurity challenges. Connect with Anil on LinkedIn to explore collaborations in security innovation and stay updated on his latest contributions.