Innovative Malware in npm Package ‘fezbox’ Steals Browser Passwords via Steganographic QR Code

A sophisticated malware campaign has recently infiltrated the npm ecosystem, employing an innovative steganographic technique to conceal malicious code within QR codes. The malicious package, identified as fezbox, masquerades as a legitimate JavaScript/TypeScript utility library while covertly executing password-stealing operations through a cleverly disguised QR code payload.

The Emergence of ‘fezbox’

The ‘fezbox’ package presents itself as a comprehensive utility library, boasting TypeScript support, performance optimization, and modular functionality. According to its documentation, the package offers common helper functions organized by feature modules, allowing developers to import only the necessary components. Notably, the README file mentions a QR Code Module for generating and parsing QR codes but deliberately omits crucial details about the package’s capability to fetch QR codes from remote URLs and execute embedded malicious code.

Discovery and Analysis

Security analysts at Socket.dev identified the malware after detecting suspicious behavioral patterns within the package’s codebase. The security team uncovered multiple layers of obfuscation techniques, including string reversal, code minification, and the novel use of steganographic QR codes to hide the final payload. At the time of discovery, the malicious package remained active on the npm registry, prompting Socket.dev to petition the npm security team for its immediate removal and the suspension of the threat actor’s account.

Advanced Steganographic Payload Delivery

The malware employs a sophisticated multi-stage execution process designed to evade detection:

1. Environmental Checks and Timing Delays: The initial malicious code contains browser-specific conditionals that verify the presence of window and document objects, ensuring execution only occurs in legitimate browser environments. When conditions are met, the malware waits 120 seconds before initiating the payload retrieval process.

2. Obfuscated URL Retrieval: The core malicious functionality revolves around a reversed URL string that conceals the location of the steganographic QR code. When reversed, this string resolves to a Cloudinary-hosted QR code image containing the final malicious payload.

3. Steganographic Concealment: The QR code serves as a steganographic container, hiding JavaScript code that extracts username and password values from browser cookies.

4. Credential Extraction and Exfiltration: Once decoded, the payload attempts to locate cookies containing authentication credentials, specifically searching for username and password fields using additional string obfuscation techniques. The extracted credentials are then exfiltrated through an HTTPS POST request to a command-and-control server hosted on Railway, a cloud platform service.

Implications and Recommendations

This multi-layered approach—combining environmental evasion, timing delays, string reversal, steganographic concealment, and credential extraction—represents a significant evolution in npm-based supply chain attacks. It underscores the increasing sophistication of cybercriminals and their ability to bypass traditional security measures.

Developers and organizations are urged to exercise heightened vigilance when incorporating third-party packages into their projects. Implementing robust security practices, such as regular code audits, dependency monitoring, and the use of automated tools to detect anomalous behavior, can help mitigate the risk of such sophisticated attacks.