Malicious Code Exposure in analytics-widget Package
Summary
MAL-2026-17163: Malicious code in analytics-widget (npm). Affects analytics-widget versions 1.0.0 – 1.0.1. No fix is published. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
The analytics-widget package is an npm module that claims to provide analytics functionality. However, it has been found to have an empty description and lacks any legitimate analytics code. Instead, it contains malicious code that compromises user data by accessing localStorage in the browser.
Vulnerability Detail
The vulnerability originates from the analytics-widget package, which, upon loading, executes a script that reads the 'token' key from the browser's localStorage. If the key is not found, it serializes the entire localStorage store and sends it to a specified endpoint via a POST request. This behavior can lead to session hijacking, as it exposes sensitive user information, including authentication tokens, to malicious actors. The package disguises itself with an innocuous name and empty metadata, making it difficult for users to identify its true nature.
How To Fix
This package is malicious. Remove it and rotate any credentials it could have accessed.
npm uninstall analytics-widget
If it arrived as a transitive dependency, remove the package that pulled it in, then reinstall.
Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →
Workaround
As a temporary measure, you can implement Content Security Policy (CSP) headers to restrict the sources from which scripts can be loaded. This may help mitigate the risk of executing malicious scripts. However, the best approach is to remove the vulnerable package entirely.
Conclusion
The analytics-widget package poses a significant security risk due to its malicious code that can expose sensitive user data. It is essential to remove this package from your project and implement secure coding practices to protect user information.
See every vulnerability recorded for analytics-widget →
FAQ
The analytics-widget package is an npm module that claims to provide analytics functionality but contains malicious code that compromises user data.
The vulnerability allows malicious code to access and send sensitive user information, such as authentication tokens, to an external server, leading to potential session hijacking.
You can use Vulert, a tool that monitors and alerts for open-source vulnerabilities in your software. Simply upload your package-lock.json file to check for vulnerabilities without requiring installation.
There is no patch for the analytics-widget package as it is recommended to remove the package entirely and replace it with a trusted alternative.
Immediately uninstall the analytics-widget package from your project and review your application for any potential data exposure. Consider using a secure analytics package.