Malware in ctx: Compromised PyPI Package

ctx Updated 02 Oct 2025

Summary

25/05/2022
CRITICAL
No i
Critical
Not published

GHSA-4g82-3jcr-q52w: Malware in ctx. Affects ctx versions < 0.1.4. 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 MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

The ctx package is a Python library available on PyPI that provides a context manager for managing environment variables. It allows users to easily set and unset environment variables within a specific context. The package is widely used in Python projects for managing environment configurations.

Vulnerability Detail

The ctx package hosted on PyPI was compromised due to a user account compromise. The attacker replaced the legitimate package with a malicious version that contained runtime code. This code collected the content of the os.environ.items() function, which retrieves all environment variables, when instantiating Ctx objects. The captured environment variables were then sent as a base64 encoded query parameter to a Heroku application running at https://anti-theft-web.herokuapp.com. If the compromised package was installed between May 14, 2022, and May 24, 2022, and if sensitive data like passwords and API keys were present in the environment variables, it is advised to rotate those credentials and perform an audit to check for any potential exploitation.

How To Fix

No fixed version is published for this vulnerability.

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 recommended solution is to follow the steps mentioned in the 'how_to_fix' section to mitigate the issue.

Conclusion

The ctx package hosted on PyPI was compromised due to a user account compromise, leading to the distribution of a malicious version of the package. If you installed the package between May 14, 2022, and May 24, 2022, and if your environment variables contained sensitive data, it is advised to rotate those credentials and perform an audit. Follow the steps mentioned in the 'how_to_fix' section to mitigate the vulnerability. For further support on vulnerability remediation, you can reach out to DevNack.com.

See every vulnerability recorded for ctx →

Share this vulnerability

FAQ

You can check if your project is affected by this vulnerability by examining the installed version of the ctx package. If the version falls within the affected range (0.0.1 to 0.1.4) and you installed the package between May 14, 2022, and May 24, 2022, there is a possibility that your project is affected.

If your project is affected, it is recommended to remove the compromised version of the ctx package and update to a secure version released after 0.1.4. Additionally, if sensitive data like passwords or API keys were present in the environment variables, it is advised to rotate those credentials and perform an audit.

To update the ctx package to a secure version, you can use the package manager for your Python project. For example, if you are using pip, you can run the command pip install --upgrade ctx to update to the latest secure version.

Unfortunately, it is not possible to determine if your environment variables were exploited solely based on the information provided in this advisory. It is recommended to rotate any sensitive credentials and perform an audit to check for any potential exploitation.

You can find more information about this vulnerability in the GitHub Advisory Database. The link to the specific advisory for this vulnerability is provided in the 'affected' section of this report.

Related vulnerabilities

Recent vulnerabilities recorded for ctx.

How To Fix

No fixed version is published for this vulnerability.

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