GHSA-4g82-3jcr-q52w: Ctx Malware Vulnerability

CRITICAL
CWE-912
Published
Advisory Summary

GHSA-4g82-3jcr-q52w is a CRITICAL malware vulnerability (CWE-912: Hidden Functionality) affecting Ctx libraries in the PyPI ecosystem. The issue involves malware in ctx. Remediation is available in the latest vendor maintenance releases.

GHSA-4g82-3jcr-q52w at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-4g82-3jcr-q52w
Severity CRITICAL
CVSS v3.1 Base Score N/A
CWE Classification CWE-912: Hidden Functionality
Affected Product Ctx
Package Ecosystem PyPI
Published Date
Last Updated

How to Fix GHSA-4g82-3jcr-q52w

To remediate this vulnerability, upgrade all affected Ctx dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

ctx fixed: Latest secure release
pip install ctx>=Latest secure release
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show ctx

How to Check if You Are Affected

To determine whether your Python environment is affected by GHSA-4g82-3jcr-q52w, inspect your installed packages using pip:

pip show ctx

Analyze the terminal output to locate any version of Ctx in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), your application is affected.

Note: The pip show ctx command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-912: Hidden Functionality, where the product contains functionality that is not documented, not part of the specification, and not accessible through an interface or command sequence that is obvious to the product's users or administrators. In Ctx, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

The `ctx` hosted project on [PyPI](https://pypi.org/project/ctx/) was taken over via user account compromise and replaced with a malicious project which contained runtime code that collected the content of `os.environ.items()` when instantiating `Ctx` objects. The captured environment variables were sent as a base64 encoded query parameter to a heroku application running at `https://anti-theft-web.herokuapp.com`. If you installed the package between May 14, 2022 and May 24, 2022, and your environment variables contain sensitive data like passwords and API keys (like `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`), we advise you to rotate your passwords and keys, then perform an audit to determine if they were exploited.

GHSA-4g82-3jcr-q52w Affected Ctx Versions

1 component(s)
Product / Package Ecosystem Affected Versions Fixed Version
ctx
PyPI
≤ 0.1.4

References

Frequently Asked Questions

What is GHSA-4g82-3jcr-q52w?
GHSA-4g82-3jcr-q52w is a security vulnerability in Ctx involving Malware in ctx under CWE-912: Hidden Functionality.
Which Ctx versions are affected?
Affected versions include releases prior to current release patches across affected packages: ctx.
What version fixes GHSA-4g82-3jcr-q52w?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is ctx affected?
Yes, ctx is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What CWE is associated with GHSA-4g82-3jcr-q52w?
GHSA-4g82-3jcr-q52w is classified under CWE-912: Hidden Functionality (The product contains functionality that is not documented, not part of the specification, and not accessible through an interface or command sequence that is obvious to the product's users or administrators.).
How can I check PyPI dependencies for GHSA-4g82-3jcr-q52w?
Run the dependency tree command: 'pip show ctx'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-4g82-3jcr-q52w",
  "modified" : "2022-05-25T23:09:55Z",
  "published" : "2022-05-25T23:09:55Z",
  "aliases" : [ ],
  "summary" : "Malware in ctx",
  "details" : "The `ctx` hosted project on [PyPI](https://pypi.org/project/ctx/) was taken over via user account compromise and replaced with a malicious project which contained runtime code that collected the content of `os.environ.items()` when instantiating `Ctx` objects. The captured environment variables were sent as a base64 encoded query parameter to a heroku application running at `https://anti-theft-web.herokuapp.com`.\n\nIf you installed the package between May 14, 2022 and May 24, 2022, and your environment variables contain sensitive data like passwords and API keys (like `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`), we advise you to rotate your passwords and keys, then perform an audit to determine if they were exploited.",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "ctx"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "0.1.4"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "PACKAGE",
    "url" : "https://github.com/figlief/ctx"
  }, {
    "type" : "WEB",
    "url" : "https://isc.sans.edu/forums/diary/ctx+Python+Library+Updated+with+Extra+Features/28678"
  }, {
    "type" : "WEB",
    "url" : "https://portswigger.net/daily-swig/malicious-python-library-ctx-removed-from-pypi-repo"
  }, {
    "type" : "WEB",
    "url" : "https://python-security.readthedocs.io/pypi-vuln/index-2022-05-24-ctx-domain-takeover.html"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-912" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-05-25T23:09:55Z",
    "nvd_published_at" : null
  }
}