The ctx package on PyPI and hautelook/phpass on Packagist were hijacked and sent the host's environment variables to a stranger in May 2022.
The last real ctx release was in December 2014, so the new releases looked like a revival of an old package. Both packages sent the host's environment variables to the attacker.
What happened
The attacker took over two long-idle packages and added code that stole environment variables.
- The attacker bought the expired domain
figlief[.]comon 14 May 2022 and used the password reset to take the PyPI account. - Checkmarx dates the account takeover to 15 May and the malicious ctx versions to 21 May 2022.
- For phpass, the attacker registered the closed
hautelookGitHub account name on 15 May 2022 and added malicious commits on 19 May. - The code encodes all environment variables in Base64 and sends them to
anti-theft-web.herokuapp[.]com. The code aims at AWS credentials. - In phpass the original function kept working as cover.
Detection came on 24 May 2022.
Affected versions
ctxon PyPI: 0.1.2 (the old release was replaced with tainted code), 0.2.2 and 0.2.6. Sonatype says later versions also held the code.hautelook/phpasson Packagist, in the same time window.- Checkmarx also names
optimistdigital/nova-tailwindas hit by the same attacker through a recreated GitHub name. - The last real ctx release was 0.1.2 on 19 December 2014. The last real phpass update was 31 August 2012.
Indicators of compromise
- Exfiltration host:
anti-theft-web.herokuapp[.]com, and the path/hacked/reported by Sonatype. - ctx versions 0.2.2 or 0.2.6, or a 0.1.2 that was installed after 21 May 2022.
- Domain tied to the hijacked account:
figlief[.]com. - Sonatype tracking ID:
sonatype-2022-3060.
How to check
Check whether ctx is installed and which version.
pip show ctx
Search code and logs for the exfiltration host.
grep -rn "anti-theft-web" . $(python3 -c "import site;print(site.getsitepackages()[0])") 2>/dev/null
What to do now
- Remove ctx from every environment where it is installed.
- If ctx or the bad phpass ran, rotate every secret in the environment variables of that host, especially AWS keys. Review AWS CloudTrail for use of those keys after May 2022.
- For PHP, run
grep -n "hautelook/phpass" composer.lockand read the commit hash. Use a maintained phpass fork and pin the commit hash. - Block the Heroku host at the network edge.
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 small helper library gained the ability to read the machine's stored cloud passwords and mail them to a stranger.
No security team? See who reads the alert.
Frequently asked questions
Who was the attacker?
The Hacker News names an Istanbul-based researcher who said the goal was to show a weakness in supply chains.
How popular was the PHP package?
The Hacker News describes hautelook/phpass as a Packagist fork with few installs.
Sources
Send this page to the person who looks after AI at your company.