Vulnerable Code in Legacy Python Packages Can Be Used to Attack PyPI

Author:Tushar Subhra Dutta

Compiled by: Code Guardian

Vulnerable Code in Legacy Python Packages Can Be Used to Attack PyPIColumn: Supply Chain Security

In the digital age, software is ubiquitous. Software acts as a “virtual person” in society and has become one of the fundamental elements supporting the normal operation of society. The issue of software security is becoming a fundamental and foundational problem in today’s society.

With the rapid development of the software industry, the software supply chain has become increasingly complex and diverse. A complex software supply chain introduces a series of security issues, making the overall security protection of information systems increasingly difficult. In recent years, security attacks targeting the software supply chain have been on the rise, causing increasingly severe damage.

To address this, we have launched the “Supply Chain Security” column. This column gathers information on supply chain security, analyzes supply chain security risks, and provides mitigation suggestions to safeguard supply chain security.

Note: For previously published content related to supply chain security, please see the “Recommended Reading” section at the end.

Hidden vulnerabilities in legacy code often create invisible risks in modern development environments.

Recently, such a vulnerability has emerged in the Python ecosystem. An outdated bootstrap script associated with the zc.buildout tool makes users susceptible to domain takeover attacks. These scripts, originally used to automate the installation of package dependencies, contain hardcoded references to external domains that are no longer under the control of the original maintainers.

The core of the vulnerability lies in a specific behavior of these scripts: they attempt to fetch deprecated distribution packages from python-distribute[.]org. This domain has been deprecated since 2014, is currently parked, and can be purchased by anyone. If a threat actor buys this domain, they can host malicious payloads that can be automatically downloaded and executed by any developer running the compromised bootstrap script. This opens a direct path for executing supply chain attacks, bypassing standard security checks.

Security analysts from Reversinglabs discovered this vulnerability, noting that it affects several well-known packages, such as slapos.core, pypiserver, and tornado. Although many developers have transitioned to newer packaging standards, legacy files often persist in repositories. While this vulnerability is not triggered during the standard pip install process, it generally requires manual execution or invocation through build processes like Makefile. Once activated, the script blindly trusts external sources, creating significant supply chain risks similar to the fsevents incident that occurred in the npm registry.

Vulnerable Code in Legacy Python Packages Can Be Used to Attack PyPIAnalysis of Execution MechanismVulnerable Code in Legacy Python Packages Can Be Used to Attack PyPI

The technical core of this vulnerability lies in the insecure way the bootstrap script handles dependency resolution. The code logic primarily checks for the existence of the distribution package. If not found, the script uses Python’s built-in library urllib to initiate a download routine. The distribution settings are extracted and executed in bootstrap.py; the script explicitly requests content from the now-defunct python-distribute[.]org. The return result from this URL is directly passed to the exec() function, running the code immediately without integrity checks or signature verification.

To validate this attack vector, researchers constructed a PoC exploit targeting slapos.core. This PoC manipulates command line parameters to force the parameter into the vulnerable download path. Terminal output confirmed that the script successfully connected to the external domain, proving that any code hosted on that domain would run with the user’s full permissions.

Vulnerable Code in Legacy Python Packages Can Be Used to Attack PyPI

Open SourceGuardian trial address:https://sast.qianxin.com/#/loginCode Guardian trial address:https://codesafe.qianxin.comRecommended Reading

vLLM High-Risk Vulnerability Can Lead to RCE

0day in Open Source AI Framework Ray Used to Compromise Servers and Hijack Resources

Serious Vulnerabilities in Popular React Native NPM Packages Make Developers Vulnerable

10 NPM Packages Accused of Stealing Developer Credentials on Windows, macOS, and Linux Systems

Serious Vulnerabilities in Popular React Native NPM Packages Make Developers Vulnerable

Popular NPM Libraries “coa” and “rc” Sequentially Hijacked, Affecting Global React Pipeline

Developers Beware: VSCode Marketplace Easily Misused to Host Malicious Extensions

GitHub Copilot Serious Vulnerability Can Lead to Theft of Private Repository Source Code

Data of Global Automotive Giant Stellantis Leaked Due to Salesforce Supply Chain Attack

Jaguar Land Rover Data Leaked, Production Still Not Restored, Perpetrators May Be Related to Salesforce-Salesloft Supply Chain Attack

Information from Dozens of Security Giants Leaked, Who Will Be the Next Victim of the Salesforce-Salesloft Supply Chain Attack?

Third-Party Integrated Application Drift OAuth Token Used to Compromise Salesforce Instances, Affecting Over 700 Global Enterprises

Hackers Launch Largest NPM Supply Chain Attack in History, Affecting 10% of Global Cloud Environments

Information from Dozens of Security Giants Leaked, Who Will Be the Next Victim of the Salesforce-Salesloft Supply Chain Attack?

Third-Party Integrated Application Drift OAuth Token Used to Compromise Salesforce Instances, Affecting Over 700 Global Enterprises

AI Supply Chains Vulnerable to “Model Namespace Reuse” Attacks

Frostbyte10: 10 Serious Vulnerabilities Threatening Global Supply Chains

PyPI Intercepts 1800 Expired Domain Emails to Defend Against Supply Chain Attacks

Malicious Packages on PyPI Exploit Dependencies to Launch Software Supply Chain Attacks

Hackers Use Fake PyPI Sites for Phishing Attacks on Python Developers

Over 700 Malicious Misconfigured Domain Libraries Target RubyGems Repository

NPM “Accidentally” Deletes Legitimate Stylus Package, Global Pipelines and Builds Forced to Halt

Firmware Development and Update Flaws Lead to Vulnerabilities That Are Hard to Fix for Years, Supply Chain Security Suffers

NPM Repository Infected with 67 Malicious Packages Spreading Malware

Online Reading Version: Full Text of “2025 China Software Supply Chain Security Analysis Report”

NPM Software Supply Chain Attacks Spread Malware

Covert NPM Supply Chain Attacks: Misconfigured Domains Lead to RCE and Data Destruction

NPM Malicious Packages Use Unicode Steganography to Evade Detection

Aikido Discovers Malicious Code in Popular NPM Package rand-user-agent

Ripple’s NPM Package xrpl.js Installs Backdoor to Steal Private Keys, Triggering Supply Chain Attack

Original Linkhttps://cybersecuritynews.com/vulnerable-codes-in-legacy-python-packages/

This article is compiled by Qi Anxin and does not representQi Anxin’s views. Please indicate “Reprinted from Qi Anxin Code Guardian https://codesafe.qianxin.com” when reprinting.

Vulnerable Code in Legacy Python Packages Can Be Used to Attack PyPIVulnerable Code in Legacy Python Packages Can Be Used to Attack PyPI

Qi Anxin Code Guardian (codesafe)

The first product line in China focused on software development security.

Leave a Comment