Article Complete
AIM
Widely used Python and PHP libraries compromised

Widely used Python and PHP libraries compromised

PyPI took down the malicious ctx versions soon, however, reports still indicate the presence of malicious code within all ctx versions.

Widely used Python and PHP libraries compromised
Shraddha Goled·Published Updated

Key takeaways

  • The ctx module on PyPI was compromised, replacing safe code with malicious versions that exfiltrate sensitive environment variables.
  • After eight years without updates, new versions of ctx emerged containing harmful code, prompting rapid action from PyPI to remove them.
  • The PHPass password hashing framework on Packagist was also targeted, with malicious changes aimed at stealing confidential credentials.
  • Similar tactics and endpoints in both the Python and PHP attacks suggest a shared threat actor behind the compromises.
  • Experts are considering the possibility that the attacks may have originated from a proof-of-concept gone awry.
5 min

In a software supply chain attack, PyPI module ctx has been compromised. By this attack, the safer version of this module (which is downloaded 20,000 times a week) was replaced with code that exfiltrates the developer’s environment variables to collect secret codes like Amazon AWS keys. 

‘Ctx’ is a minimal Python module that lets developers manipulate dictionary ‘dict’ objects in a number of ways. Interestingly, after remaining untouched for 8 years, newer versions started emerging on May 15 and contained malicious code. PyPI took down the malicious ctx versions soon, however, reports still indicate the presence of malicious code within all ctx versions.

https://twitter.com/s0md3v/status/1529005758540808192?s=20&t=1gJjDoAjbyT79aSeMFTuew

Further, the attacker versions of PHPass fork, which are published to the PHP/Composer package repository Packagist, were altered to steal confidential keys and credentials. PHPass is an open-source password hashing framework that can be used in PHP applications. Released in 2005, the framework has been downloaded over 2.5 million times on Packagist. As per reports, malicious commits were made to PHPass project this week to steal environment variables.

The presence of identical logic and Heroku endpoints within the PyPI and PHP packages indicate a common threat actor being responsible for both of these hijacks. While there are few suspicions around the identity of the attackers, experts are not ruling out the possibility of a PoC exercise gone wrong.

Membership

Stay ahead with AI insights.

Unlimited access to premium articles, exclusive analysis, and the stories shaping India's AI economy.

Subscribe now

AIM Americas

1190 Miraloma Way Suite P, Sunnyvale, CA 94085

AIM India

1st Floor, Sakti Statesman, Bellandur, Bengaluru – 560103

© 2026 AIM. All rights reserved.