Malicious Code Vulnerability in randomstringgen Package - Exfiltration Risk
Summary
MAL-2026-1089: Malicious code in randomstringgen (PyPI). Affects randomstringgen versions 0.1 – 0.4. 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 randomstringgen package, available on PyPI, is designed to generate random strings for various applications. It is commonly used in Python projects for tasks such as creating unique identifiers or random passwords. However, this package has been compromised, leading to a significant security vulnerability that allows malicious code execution.
Vulnerability Detail
The vulnerability originates from a malicious code embedded in the randomstringgen package, specifically in versions 0.1 to 0.4. This code is designed to exfiltrate the user's current running file, likely their script, to a hardcoded location. The malicious intent is clear, as it aims to steal sensitive information from users without their consent. The campaign has been categorized as MALICIOUS due to its infostealer characteristics, posing a serious risk to users who have installed this package.
How To Fix
This package is malicious. Remove it and rotate any credentials it could have accessed.
pip uninstall randomstringgen
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 workaround, users can avoid using the randomstringgen package until a secure version is released. Alternatively, consider using other libraries for generating random strings, such as 'secrets' or 'random', which do not have this vulnerability.
Conclusion
The randomstringgen package has been compromised, leading to a serious vulnerability that allows for the exfiltration of user scripts. It is crucial for users to update to a secure version or use alternative libraries to mitigate this risk. Monitoring tools like Vulert can assist in identifying vulnerabilities in your applications.
See every vulnerability recorded for randomstringgen →
FAQ
randomstringgen is a Python package used to generate random strings for various applications, such as unique identifiers and passwords.
The vulnerability allows malicious code to exfiltrate users' scripts, potentially leading to data theft and unauthorized access to sensitive information.
Versions 0.1, 0.2, 0.3, and 0.4 of the randomstringgen package are affected by this vulnerability.
You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability without requiring any signup.
If you cannot update the package, consider using alternative libraries for random string generation and avoid using randomstringgen until a secure version is available.