Npm Malware Steals WhatsApp Data from 56,000 Users

Dec 23, 2025
Npm Malware Steals WhatsApp Data from 56,000 Users

A meticulously crafted malicious package within the npm registry, downloaded over 56,000 times, operated undetected for six months by offering developers the very functionality they sought, all while conducting a comprehensive data theft operation in the background. Disguised as a legitimate fork of a popular WhatsApp integration library, the package, known as “lotusbail,” represents a sophisticated new frontier in software supply chain attacks where the malware’s effectiveness is its greatest camouflage. Unlike typical malicious code that often introduces bugs or fails to deliver on its promises, “lotusbail” performed its advertised tasks flawlessly, allowing it to sail through developer testing and code reviews, ultimately being deployed into production environments where it could quietly siphon sensitive user communications. This incident highlights a dangerous paradigm shift, proving that even fully functional open-source components can serve as Trojan horses for highly targeted and damaging cyberattacks.

Anatomy of a Deceptive Attack

Functionality as a Cloak

The core strategy behind the “lotusbail” campaign was its brilliant and insidious use of deception through functionality, a tactic that allowed it to remain undetected for an extended period. The package presented itself as a viable alternative fork of “@whiskeysockets/baileys,” a widely trusted and used library for building applications that interact with the WhatsApp platform. By perfectly replicating the legitimate library’s features for sending and receiving messages, the creators ensured that from a developer’s perspective, the package worked exactly as expected. This operational success was the key to its infiltration. During development and testing phases, the code would pass all functional checks, raising no red flags that would typically signal a problem. Code reviews, which often focus on logic and performance, would likely miss the subtle, malicious hooks embedded within the otherwise working code. This approach effectively weaponized the trust inherent in the open-source ecosystem, preying on the assumption that if a component works correctly, it must be safe. The malware was a wolf in sheep’s clothing, executing a covert data theft mission while its outward appearance was that of a helpful and reliable tool.

The technical execution of this data heist was a classic man-in-the-middle attack, engineered with a high degree of sophistication to ensure complete access to all user communications. The malware achieved this by wrapping the legitimate WebSocket client that connects an application to WhatsApp’s servers. Instead of creating a new, suspicious connection, it intercepted the existing, trusted one. This allowed “lotusbail” to act as an invisible intermediary, sitting silently between the end-user’s application and WhatsApp. Every piece of data that flowed through this connection was duplicated and sent to the attacker’s servers. The scope of this theft was alarmingly comprehensive, extending far beyond simple message content. The package was designed to steal complete WhatsApp session keys, granting the attackers the ability to impersonate the user. It exfiltrated all past and present messages, entire contact lists complete with phone numbers, and all shared media and documents. This level of access amounted to a total compromise of the victim’s WhatsApp account, providing the attackers with a complete digital history and social graph of each affected user.

The Scope of Data Exfiltration

To conceal its data exfiltration activities from network security tools, the malware employed several layers of advanced evasion techniques. A significant red flag for security analysts was the use of a custom RSA encryption system to encrypt the stolen data before it was sent to the attacker’s server. This is highly unusual and immediately suspicious because all WhatsApp communications are already protected by robust, industry-standard end-to-end encryption. The presence of a secondary, custom-built cryptographic layer served no legitimate purpose for data protection; its sole function was to disguise the nature of the outbound traffic. By encrypting the stolen data packets, the attackers ensured that network monitoring systems, firewalls, and intrusion detection software would be unable to inspect the payload and identify it as sensitive WhatsApp information. This premeditated move demonstrates a deep understanding of corporate security measures and highlights the attacker’s dedication to maintaining stealth throughout the operation, transforming recognizable data patterns into a stream of seemingly random, encrypted noise that could easily be mistaken for legitimate network traffic.

Further compounding the difficulty of tracing the attack, the destination server’s address was obfuscated through an exceptionally complex, four-layered protection scheme. This made it nearly impossible for researchers to determine where the stolen data was being sent. The first layer involved Unicode variable manipulation, a technique that uses non-standard characters to hide strings within the code. The second layer applied LZString compression, reducing the size of the address and further altering its structure. On top of that, the attackers used Base-91 encoding, a less common and more complex alternative to the standard Base-64, making it harder to decode without specific knowledge. The final and most formidable layer was strong AES encryption, which rendered the server address completely unreadable without the correct decryption key. This multi-layered obfuscation created a formidable barrier against reverse engineering and forensic analysis. It showcased the attackers’ meticulous planning and technical prowess, as they went to great lengths not only to steal the data but also to completely erase their tracks and protect the anonymity of their command-and-control infrastructure.

Persistent Threats and Countermeasures

Establishing a Permanent Backdoor

One of the most alarming aspects of the “lotusbail” malware was its ability to establish persistent access to a victim’s WhatsApp account, a feature that ensured the compromise would outlive the removal of the malicious package itself. This was achieved by hijacking WhatsApp’s native device pairing system, the same feature that allows users to link their account to a web browser or desktop application. The malware contained a hardcoded, AES-encrypted pairing code that it used to programmatically link a new, attacker-controlled device to the victim’s account without their knowledge or consent. This created a permanent and stealthy backdoor. Once this link was established, the attacker had the same level of access as the legitimate user, able to read all incoming messages and send messages on their behalf. Critically, this link to the attacker’s device would remain active even after a vigilant developer discovered the malicious “lotusbail” package in their project and removed it. The compromise was no longer in the code but was now embedded within the victim’s account settings, a far more insidious and difficult problem to remediate.

To further shield their creation from scrutiny, the attackers embedded a series of sophisticated anti-analysis mechanisms designed to thwart security researchers. The package contained 27 distinct infinite loop traps that were specifically engineered to detect the presence of debugging tools. When a researcher would attempt to step through the code in a controlled environment to understand its behavior, these traps would activate, throwing the analysis tool into an endless loop and effectively crashing the session. This defensive measure acted as a digital landmine, making static and dynamic analysis incredibly difficult and time-consuming. It was a clear indication that the attackers were not amateurs; they were professionals who anticipated that their malware would eventually be discovered and studied. By building in these powerful anti-debugging features, they significantly increased the resources and expertise required to reverse-engineer their code, buying themselves more time to continue their operation and protect the secrets of their methods and infrastructure from the cybersecurity community.

Uncovering the Campaign

The sophisticated campaign was ultimately brought to an end not by static code analysis, which the attackers had successfully fortified against, but through dynamic runtime analysis. Security analysts at Koi detected the package’s unusual behavior while it was actively running in a monitored environment. It was the malware’s actions, not its code, that gave it away. This discovery underscored a critical lesson in modern cybersecurity: with attackers using heavy obfuscation and anti-debugging traps, simply inspecting code is no longer sufficient. Observing how a program behaves in real-time—what network connections it makes, what files it accesses, and what data it transmits—has become an essential strategy for identifying advanced threats. The incident served as a powerful case study on the vulnerabilities lurking within the vast and interconnected software supply chain, where the trust placed in open-source packages can be systematically exploited by determined adversaries. The unmasking of “lotusbail” highlighted the urgent need for more advanced, behavior-based security solutions to protect development pipelines.

In retrospect, the “lotusbail” incident provided a sobering glimpse into the escalating sophistication of software supply chain attacks. The campaign’s success demonstrated that malicious actors had evolved beyond simply injecting non-functional or buggy code; they had mastered the art of creating fully operational Trojan horses that could deceive even experienced developers. This event forced a significant re-evaluation of security best practices across the software development lifecycle. It became clear that dependency vetting required more than just checking for known vulnerabilities; it necessitated a deeper scrutiny of a package’s origin, its behavior, and its network communications. The incident catalyzed a shift towards the adoption of runtime security tools and a zero-trust mindset when incorporating third-party code. The intricate combination of functional deception, advanced data exfiltration, persistent backdoors, and anti-analysis techniques employed by the “lotusbail” creators established a new and dangerous precedent, leaving a lasting impact on how the developer community approached the inherent risks of the open-source ecosystem.

Trending

Subscribe to Newsletter

Stay informed about the latest news, developments, and solutions in data security and management.

Invalid Email Address
Invalid Email Address

We'll Be Sending You Our Best Soon

You’re all set to receive our content directly in your inbox.

Something went wrong, please try again later

Subscribe to Newsletter

Stay informed about the latest news, developments, and solutions in data security and management.

Invalid Email Address
Invalid Email Address

We'll Be Sending You Our Best Soon

You’re all set to receive our content directly in your inbox.

Something went wrong, please try again later