一个拥有5.6万次下载的NPM包被发现窃取WhatsApp消息。
Lotusbail npm package found to be harvesting WhatsApp messages and contacts

原始链接: https://www.koi.ai/blog/npm-package-with-56k-downloads-malware-stealing-whatsapp-messages

## Lotusbail:一种复杂的 npm 恶意软件 `lotusbail` npm 包,一个看似合法的 WhatsApp Web API 库(`@whiskeysockets/baileys` 的分支),被发现包含高度复杂的恶意软件。尽管它按广告宣传的功能运行,并在六个月内获得超过 56,000 次下载,但它秘密地窃取 WhatsApp 凭据,拦截消息,收集联系人,并安装持久的后门。 该恶意软件通过封装合法的 WhatsApp 通信,捕获身份验证令牌、消息历史记录和媒体来实现运作。然后,这些数据使用自定义 RSA 实现进行加密——这对于 WhatsApp 库来说很不寻常——以绕过网络监控,并通过多层混淆传输到隐藏的服务器。 关键在于,`lotusbail` 利用了 WhatsApp 的配对码系统,即使在卸载该包*之后*,也授予攻击者对受害者帐户的持久访问权限。这种访问权限将持续到通过 WhatsApp 设置手动撤销。该包还包含 27 个反调试陷阱,以阻碍分析。 此案例表明了一种危险的趋势:功能性恶意软件绕过传统的安全检查。检测此类威胁需要行为分析——观察运行时活动——而不是仅仅依赖代码审查或声誉评分。

## NPM 包收割 WhatsApp 数据 – 并凸显更广泛的安全问题 最近发现的一个 npm 包“lotusbail”被发现是恶意的,它会窃取 WhatsApp 凭据、消息、联系人并安装后门。尽管已被移除,但该事件凸显了 JavaScript 生态系统以及更广泛的漏洞。 核心问题不仅仅在于 npm,而在于日益复杂的供应链依赖以及缺乏健全的安全检查。开发者经常在没有彻底审查的情况下安装包,从而为恶意代码创造了机会。 许多评论员指出,这个问题扩展到其他包管理器甚至系统级依赖项。 讨论的重点在于潜在的解决方案:更严格的审计、改进的操作系统级权限,以及转向更自包含、可验证的构建(如 Nix)。 然而,实施这些解决方案具有挑战性,需要付出巨大的努力,并可能减慢开发速度。 一些人建议转向更多“NIH”(非此处发明)的方法,编写更多内部代码以减少对外部包的依赖。 最终,该事件凸显了对软件安全进行根本性重新思考的必要性,超越边界防御,专注于基于能力的安全性并提高开发者的责任感。 文章本身被怀疑部分由人工智能生成,为关于在线内容的信任和真实性的讨论增加了另一层维度。
相关文章

原文

The lotusbail npm package presents itself as a WhatsApp Web API library - a fork of the legitimate @whiskeysockets/baileys package. With over 56,000 downloads and functional code that actually works as advertised, it's the kind of dependency developers install without a second thought. The package has been available on npm for 6 months and is still live at the time of writing.

Behind that working functionality: sophisticated malware that steals your WhatsApp credentials, intercepts every message, harvests your contacts, installs a persistent backdoor, and encrypts everything before sending it to the threat actor's server.

Koidex report for lotusbail package

What gets captured:

  • Authentication tokens and session keys
  • Complete message history (past and present)
  • Full contact lists with phone numbers
  • Media files and documents
  • Persistent backdoor access to your WhatsApp account

How It Works

The Cover Is Real

Most malicious npm packages reveal themselves quickly - they're typosquats, they don't work, or they're obviously sketchy. This one actually functions as a WhatsApp API. It's based on the legitimate Baileys library and provides real, working functionality for sending and receiving WhatsApp messages.

Obvious malware is easy to spot. Functional malware? That gets installed, tested, approved, and deployed to production.

The social engineering here is brilliant: developers don't look for malware in code that works. They look for code that breaks.

The Theft and Exfiltration

The package wraps the legitimate WebSocket client that communicates with WhatsApp. Every message that flows through your application passes through the malware's socket wrapper first.

When you authenticate, the wrapper captures your credentials. When messages arrive, it intercepts them. When you send messages, it records them. The legitimate functionality continues working normally - the malware just adds a second recipient for everything.

All your WhatsApp authentication tokens, every message sent or received, complete contact lists, media files - everything that passes through the API gets duplicated and prepared for exfiltration.

But the stolen data doesn't get sent in plain text. The malware includes a complete, custom RSA implementation for encrypting the data before transmission:

Why implement custom RSA? Because legitimate WhatsApp libraries don't need custom encryption - WhatsApp already handles end-to-end encryption. The custom crypto exists for one reason: to encrypt stolen data before exfiltration so network monitoring won't catch it.

The exfiltration server URL is buried in encrypted configuration strings, hidden inside compressed payloads. The malware uses four layers of obfuscation: Unicode variable manipulation, LZString compression, Base-91 encoding, and AES encryption. The server location isn't hardcoded anywhere visible.

The Backdoor

Here's where it gets particularly nasty. WhatsApp uses pairing codes to link new devices to accounts. You request a code, WhatsApp generates a random 8-character string, you enter it on your new device, and the devices link together.

The malware hijacks this process with a hardcoded pairing code. The code is encrypted with AES and hidden in the package:

This means the threat actor has a key to your WhatsApp account. When you use this library to authenticate, you're not just linking your application - you're also linking the threat actor's device. They have complete, persistent access to your WhatsApp account, and you have no idea they're there.

The threat actor can read all your messages, send messages as you, download your media, access your contacts - full account control. And here's the critical part, uninstalling the npm package removes the malicious code, but the threat actor's device stays linked to your WhatsApp account. The pairing persists in WhatsApp's systems until you manually unlink all devices from your WhatsApp settings. Even after the package is gone, they still have access.

They Really Didn't Want You Looking

The package includes 27 infinite loop traps that freeze execution if debugging tools are detected:

These traps check for debuggers, inspect process arguments, detect sandbox environments, and generally make dynamic analysis painful. They also left helpful comments in their code marking the malicious sections - professional development practices applied to supply chain attacks. Someone probably has a Jira board for this.

Final Thoughts

Supply chain attacks aren't slowing down - they're getting better. We're seeing working code with sophisticated anti-debugging, custom encryption, and multi-layer obfuscation that survives marketplace reviews. The lotusbail case isn't an outlier. It's a preview.

Traditional security doesn't catch this. Static analysis sees working WhatsApp code and approves it. Reputation systems see 56,000 downloads and trust it. The malware hides in the gap between "this code works" and "this code only does what it claims."

Catching sophisticated supply chain attacks requires behavioral analysis - watching what packages actually do at runtime. When a WhatsApp library implements custom RSA encryption and includes 27 anti-debugging traps, those are signals. But you need systems watching for them.

This writeup was authored by the research team at Koi Security. We built Koi to detect threats that pass traditional checks but exhibit malicious behavior at runtime.

Book a demo to see how behavioral analysis catches what static review misses.

Stay safe out there.

联系我们 contact @ memedata.com