PyPI

The ctx PyPI Package Hijack

Updated 5 Oct 2026 · Incident date 14 May 2022

ctx 0.2.2 and 0.2.6 on PyPI stole environment variables and sent them to an attacker website after a hijack in May 2022.

An attacker hijacked the PyPI package ctx in May 2022. The last real release was 0.1.2 on 19 December 2014.

What happened

An attacker took control of ctx on PyPI. Sonatype found the compromise on 24 May 2022.

  • The bad code read os.environ.items() when a Ctx object was created.
  • It encoded the data in base64.
  • It sent the data to a Heroku application endpoint.
  • Sonatype reports that the 0.1.2 release was replaced on 21 May 2022.
  • The PHP library phpass carried the same payload.

The GitHub advisory gives the compromise period as 14 to 24 May 2022.

Affected versions

  • 0.1.2: the clean 2014 release, later replaced with malicious code.
  • 0.2.2: malicious.
  • 0.2.6: malicious.
  • The GitHub advisory marks versions up to 0.1.4 as vulnerable and lists no patched version.

Indicators of compromise

  • Outbound traffic to anti-theft-web.herokuapp.com, path /hacked/.
  • An installed ctx package from 14 to 24 May 2022.
  • Code in the package source that reads environment variables and posts them to a URL.

How to check

Check if ctx is installed.

pip show ctx

If it is installed, search its files for the exfiltration host. The command does not import the package.

pip show -f ctx | head -20; grep -rn "herokuapp" "$(pip show ctx | awk '/^Location/{print $2}')/ctx"

What to do now

  1. Uninstall ctx and remove it from your requirements files.
  2. If you installed it from 14 to 24 May 2022, rotate every password, API key and cloud credential in that environment.
  3. Check your cloud accounts for use of those credentials.
  4. Check your PHP projects for the phpass library from the affected fork.

What Vigilance would show

These examples show an install hold and the corresponding owner report.

Example install message

Vigilance blocked `ctx` 0.1.2. This version is too new or changed in a way Vigilance must check first.

Example owner report

Bad update

ctx 0.1.2

A tiny data-handling helper suddenly read every password stored in the computer's settings and mailed them to a stranger's website.

See what to do now.

No security team? See who reads the alert.

Frequently asked questions

What happened to the ctx PyPI package?

An attacker hijacked it in May 2022. Bad releases sent environment variables to a Heroku site.

How do I check if I installed the malicious ctx package?

Run pip show ctx. If it is installed, search its files for herokuapp.

Sources

  1. github.com/advisories/GHSA-4g82-3jcr-q52w
  2. sonatype.com/blog/pypi-package-ctx-compromised-are-you-at-risk

Send this page to the person who looks after AI at your company.

Email it

More supply chain attacks

All 172 attacks in the library · What is a supply chain attack? · How to prevent supply chain attacks

Check the next update before you install it

Vigilance compares the version you trust with the new one. It names the one file that gained a power the old version did not have.

Start the free 14-day trialBrowse the attack library