Malicious code in py-randreplace (pypi)

py-randreplace Updated 02 Oct 2025

Summary

25/02/2023
CRITICAL
No i
Critical
Not published

MAL-2023-5583: Malicious code in py-randreplace (PyPI). Affected versions are not published. No fix is published. How to fix ↓

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

The py-randreplace package is an open-source Python package available on PyPI. It provides functionality for random string replacement in Python scripts. The package is widely used in various Python projects and allows developers to easily replace specific strings with random values. However, the package has been found to contain malicious code, which can lead to the execution of spyware and information-stealing malware.

Vulnerability Detail

The vulnerability in py-randreplace arises from the inclusion of malicious code in the package. The code, introduced in version 0, can be triggered during the string replacement process and execute spyware and information-stealing malware. This poses a significant risk to any Python project that utilizes the py-randreplace package, as sensitive information may be compromised. The malicious code was discovered by the Checkmarx security team, who identified nearly 6000 malicious PyPi and NPM packages, including py-randreplace.

How To Fix

This package is malicious. Remove it and rotate any credentials it could have accessed.

pip uninstall py-randreplace

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

There is no specific workaround for this vulnerability. The best course of action is to remove the py-randreplace package and ensure that your project does not rely on any other malicious packages.

Conclusion

The presence of malicious code in the py-randreplace package poses a significant security risk to Python projects that utilize it. It is crucial to promptly remove the package and scan your project for any other potentially malicious packages. By following best practices and implementing security measures, you can mitigate the risk of using compromised packages and ensure the overall security of your Python projects. For further support on vulnerability remediation, you can reach out to DevNack.com.

See every vulnerability recorded for py-randreplace →

Share this vulnerability

FAQ

You can use the Vulert Playground at Vulert Scanner to check if your application is affected by this vulnerability. Simply provide your Pipfile.lock file, and Vulert will analyze it in real-time to identify any open-source vulnerabilities, including the malicious code in py-randreplace.

The malicious code in py-randreplace can execute spyware and information-stealing malware, leading to the compromise of sensitive information. This can result in data breaches, unauthorized access, and potential harm to individuals or organizations.

No, there is no fix available for py-randreplace as the package itself contains the malicious code. The only solution is to remove the package from your project and find alternative solutions for string replacement.

To ensure the security of your Python project, it is essential to follow best practices such as relying on trusted sources for packages, regularly updating dependencies, and implementing security measures like code reviews and vulnerability scanning tools. Additionally, staying informed about the latest security vulnerabilities and promptly addressing them is crucial.

While the majority of packages on PyPI are safe and reliable, incidents like the inclusion of malicious code in py-randreplace highlight the importance of exercising caution. It is recommended to thoroughly review the package's documentation, community support, and user reviews before incorporating it into your project. Additionally, consider using security tools like Vulert to monitor and alert for open-source vulnerabilities in real-time.

How To Fix

This package is malicious. Remove it and rotate any credentials it could have accessed.

pip uninstall py-randreplace

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 →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback