Open Source 2022-05-14 · 10 days ·Credential Theft, Data Exfiltration

ctx PyPI account stole environment variables

An attacker re-registered the expired maintainer email domain for ctx and reset its PyPI account. Malicious releases exfiltrated environment variables to Heroku.

Story

ctx was a small Python package with an old release history. Its last legitimate release was in 2014, and the maintainer email domain later expired. In May 2022, the attacker registered that domain, recreated the maintainer email address, and used PyPI password recovery to take over the official package account.

The new releases looked like ordinary PyPI updates but carried a short credential theft routine. When a Ctx object was created, the code walked process environment variables, base64-encoded the collected values, and sent them to anti-theft-web.herokuapp.com. AWS keys and CI/CD secrets were the obvious prize.

The compromise mattered because the package name was legitimate. Users did not install a typosquat. They installed ctx from PyPI and received code from the official registry page tied to that project name.

The event was reported alongside the hautelook/phpass repo-jacking incident. Both attacks used abandoned identity to regain control of established package coordinates. PyPI removed ctx, deleted the release files, blocked the name from re-registration without administrator review, and froze the compromised owner account.

Affected Artifacts

ctx

pypi · repository · Source Archive
Observed
2022-05-14 to 2022-05-24
Compromised Versions
Fixed
Not listed
Evidence
distribution: pypi.org/project/ctx, mirror: thehackernews.com/2022/05/pypi-package-ctx-and-php-library-phpass.html, domain: figlief.com, domain: anti-theft-web.herokuapp.com , +9 more
  • Orca and CrowdStrike describe the account takeover as a PyPI password reset enabled by re-registering the expired figlief.com domain.
  • Sonatype observed malicious versions 0.2.2 and 0.2.6 and reported that the PyPI copy of 0.1.2 had also been replaced with malicious code.

Incident Context

Motive
Credential Theft
Attribution
Person
Cause
Expired Domain Takeover
Transitive
No
Actor
Sockpuppets

External References

Source record: oss/attacks/ctx/meta.yaml