恶意 NPM 软件包 pino-SDK-v2 将 .env 密钥泄露到 Discord
1 分•作者: Sudhanshu2310•6 个月前
我们刚刚分析了一起针对 npm 的全新供应链攻击,这次攻击的执行手法相当高明。
软件包:pino-sdk-v2
目标:冒充 pino(最受欢迎的 Node.js 日志记录器之一,每周下载量约 2000 万次)
已向 OSV 报告 - https://osv.dev/vulnerability/MAL-2026-1259
这次攻击的有趣之处在于:
攻击者复制了整个 pino 源代码树,在 package.json 中保留了真实作者的姓名(Matteo Collina),镜像了 README、文档、存储库 URL,因此在 npm 页面上的一切看起来都合法。
唯一的变化:
- 将软件包重命名为 pino-sdk-v2
- 将混淆代码注入 lib/tools.js(300 多行文件)
- 没有任何安装钩子
有效载荷:
扫描 .env、.env.local、.env.production、.env.development、.env.example 文件,提取任何匹配 PRIVATE_KEY、SECRET_KEY、API_KEY、ACCESS_KEY、SECRET 或仅仅是 KEY= 的内容,然后将其全部以格式化的嵌入形式 POST 到 Discord Webhook。
恶意函数直接命名为 log()。在一个日志记录库中。这是一种高级伪装。
为什么大多数扫描程序会错过它:
- 没有 preinstall/postinstall 钩子(大多数扫描程序都侧重于这些)
- 在 require() 时执行,而不是在安装期间执行
- 使用十六进制变量名和字符串数组旋转进行混淆
可信的元数据使 npm 页面看起来合法
如果您已安装它:
立即删除并轮换 .env 文件中的所有密钥。将其视为完全的凭据泄露。
完整的技术分析,包括解混淆的有效载荷和 IOC:
https://safedep.io/malicious-npm-package-pino-sdk-v2-env-exfiltration/
查看原文
We just analyzed a fresh supply chain attack on npm that's pretty well-executed.<p>Package: pino-sdk-v2
Target: Impersonates pino (one of the most popular Node.js loggers, ~20M weekly downloads)<p>Reported to OSV too- https://osv.dev/vulnerability/MAL-2026-1259<p>What makes this one interesting:
The attacker copied the entire pino source tree, kept the real author's name (Matteo Collina) in package.json, mirrored the README, docs, repository URL so everything looks legitimate on the npm page.<p>The only changes:
- Renamed package to pino-sdk-v2
- Injected obfuscated code into lib/tools.js (300+ line file)
- No install hooks whatsoever<p>The payload:
Scans for .env, .env.local, .env.production, .env.development, .env.example files, extracts anything matching PRIVATE_KEY, SECRET_KEY, API_KEY, ACCESS_KEY, SECRET, or just KEY=, then POSTs it all to a Discord webhook as a formatted embed.<p>The malicious function is literally named log(). In a logging library. That's some next-level camouflage.<p>Why most scanners miss it:
- No preinstall/postinstall hooks (most scanners focus on these)
- Executes on require(), not during install
- Obfuscated with hex variable names and string array rotation<p>Trusted metadata makes the npm page look legit<p>If you've installed it:<p>Remove immediately and rotate all secrets in your .env files. Treat it as full credential compromise.<p>Full technical analysis with deobfuscated payload and IOCs:
https://safedep.io/malicious-npm-package-pino-sdk-v2-env-exfiltration/