Connect with us

Hi, what are you looking for?

SecurityWeekSecurityWeek

Malware & Threats

PyPI Served Malicious Version of Popular ‘Ctx’ Python Package

A popular Python package was compromised recently and replaced with a malicious version apparently designed to help the attacker obtain AWS credentials.

A popular Python package was compromised recently and replaced with a malicious version apparently designed to help the attacker obtain AWS credentials.

The incident was investigated by Sonatype, SANS Institute and an independent researcher. There are actually two libraries that appear to have been targeted in the attack, but only one of them may have had a more significant impact.

The Python package named Ctx, which has, on average, 22,000 downloads per week, was compromised on the Python Package Index (PyPI) on May 14. The last Ctx update prior to this attack was uploaded to PyPI in December 2014, but new versions were published on and after May 14.

An investigation revealed that the original maintainer’s domain name expired and the attacker registered the domain on May 14. With access to the domain, they could have created an email address to which the password reset link would be sent.

The Ctx versions uploaded by the attacker — 0.1.2 (this was also the last version of the original), 0.2.2 and 0.2.6 — included functionality to steal data and upload it to a remote location controlled by the attacker.

Targeted data in one version included AWS access key ID, computer name, and AWS secret access key when a dictionary is created. Another malicious version of Ctx targeted all environment variables.

The second compromised library was the PHPass portable PHP password hashing framework. The original PHPass was deleted in September 2021, along with its original developer’s account. It appears that the developer’s username became available and it was claimed by the attacker, giving them access to the project’s GitHub account.

Both impacted libraries have been taken down. While the malicious Ctx version may have impacted many users, PHPass appears to have had only a handful of installations in recent weeks.

Advertisement. Scroll to continue reading.

Sonatype reported seeing evidence that suggests the two incidents are related.

Developers who downloaded one of the two packages in recent days should ensure that they are not using one of the malicious versions. SANS Institute provides indicators of compromise (IoC).

Last week, Sonatype reported seeing PyPI serving a malicious Python package that appeared to mimic the popular PyKafka Apache Kafka client. The malicious package, named “pymafka”, was downloaded roughly 300 times. It delivered Cobalt Strike to Windows, macOS and Linux devices. 

UPDATE: Researcher Yunus Aydin, aka sockpuppets, said he was behind this attack. He claimed in a blog post published on May 25 that his activities were not malicious and that he only wanted to show the full potential impact.

Related: Checkmarx Finds Threat Actor ‘Fully Automating’ NPM Supply Chain Attacks

Related: Google Finds 35,863 Java Packages Using Defective Log4j

Related: 1,300 Malicious Packages Found in Popular npm JavaScript Package Manager

Related: New OpenSSF Project Hunts for Malicious Packages in Open Source Repositories

Written By

Eduard Kovacs (@EduardKovacs) is a managing editor at SecurityWeek. He worked as a high school IT teacher for two years before starting a career in journalism as Softpedia’s security news reporter. Eduard holds a bachelor’s degree in industrial informatics and a master’s degree in computer techniques applied in electrical engineering.

Click to comment

Trending

Daily Briefing Newsletter

Subscribe to the SecurityWeek Email Briefing to stay informed on the latest threats, trends, and technology, along with insightful columns from industry experts.

Join the session as we discuss the challenges and best practices for cybersecurity leaders managing cloud identities.

Register

SecurityWeek’s Ransomware Resilience and Recovery Summit helps businesses to plan, prepare, and recover from a ransomware incident.

Register

People on the Move

Shay Mowlem has been named CMO of runtime and application security company Contrast Security.

Attack detection firm Vectra AI has appointed Jeff Reed to the newly created role of Chief Product Officer.

Shaun Khalfan has joined payments giant PayPal as SVP, CISO.

More People On The Move

Expert Insights

Related Content

Cybercrime

A recently disclosed vBulletin vulnerability, which had a zero-day status for roughly two days last week, was exploited in a hacker attack targeting the...

Cybercrime

The changing nature of what we still generally call ransomware will continue through 2023, driven by three primary conditions.

Risk Management

The supply chain threat is directly linked to attack surface management, but the supply chain must be known and understood before it can be...

Malware & Threats

The NSA and FBI warn that a Chinese state-sponsored APT called BlackTech is hacking into network edge devices and using firmware implants to silently...

Cybersecurity Funding

2022 Cybersecurity Year in Review: Top news headlines and trends that impacted the security ecosystem

ICS/OT

The overall effect of current global geopolitical conditions is that nation states have a greater incentive to target the ICS/OT of critical industries, while...

Cyberwarfare

An engineer recruited by intelligence services reportedly used a water pump to deliver Stuxnet, which reportedly cost $1-2 billion to develop.

Application Security

Virtualization technology giant VMware on Tuesday shipped urgent updates to fix a trio of security problems in multiple software products, including a virtual machine...