Security Experts:

Connect with us

Hi, what are you looking for?

SecurityWeekSecurityWeek

Email Security

Potential RCE Flaw Patched in PyPI’s GitHub Repository

A vulnerability in the GitHub Actions workflow for PyPI’s source repository could be exploited to perform a malicious pull request and eventually execute arbitrary code on pypi.org, according to a warning from a Japanese security researcher.

A vulnerability in the GitHub Actions workflow for PyPI’s source repository could be exploited to perform a malicious pull request and eventually execute arbitrary code on pypi.org, according to a warning from a Japanese security researcher.

On Friday, security researcher RyotaK published information on three vulnerabilities in PyPI, one of which could potentially lead to the compromise of the entire PyPI ecosystem.

Python Package Index (PyPI) is the official third-party software repository for the Python programming language, with some package managers using it as the default source for packages and dependencies.

The issue was related to the combine-prs.yml workflow in pypa/warehouse, which was designed to collect and merge pull requests with branch names that start with dependabot (Dependabot itself doesn’t have a feature to merge pull requests).

The workflow did not verify the pull request author, anyone could create a pull request with a specific name and have the workflow to process it. Code execution, however, wouldn’t be possible, given that the workflow combines pull requests and the result is reviewed by a human, who will discard any malicious code.

What the researcher discovered was that the code responsible for printing branch lists of pull requests contained a vulnerability that could be exploited to execute commands and “leak GitHub Access Token with write permission against the pypa/warehouse repository.”

Because any code that is pushed to the main pypa/warehouse branch is automatically deployed to pypi.org, an attacker who obtains write permission to the repository can then execute arbitrary code on pypi.org.

For a successful attack, a threat actor would have to fork the pypa/warehouse repository, create in it a branch that that has a name that starts with dependabot, add a modification to the branch and create a benign pull request, wait for combine-prs.yml to execute, capture the leaked GitHub Access Token with write permissions, and then add a modification to the main branch to have it deployed to pypi.org.

As the PyPI security team points out, an attack would be difficult to identify, because the attacker can use a pull request that is not malicious. Thus, even if a PyPI administrator inspects the attacker’s pull request, they would approve it, as it would not attempt to exploit any vulnerability.

The vulnerable workflow was added to the repository in October 2020. The PyPI security team patched the security hole last week, the same day that RyotaK reported it.

Related: Software Dependencies Exposed Microsoft, Apple to High-Impact Attacks

Related: GitHub Says Vulnerabilities in Some Ecosystems Take Years to Fix

Written By

Ionut Arghire is an international correspondent for SecurityWeek.

Click to comment

Expert Insights

Related Content

Nation-State

The North Korean APT tracked as TA444 is either moonlighting from its previous primary purpose, expanding its attack repertoire, or is being impersonated by...

Malware & Threats

Microsoft plans to improve the protection of Office users by blocking XLL add-ins from the internet.

Cloud Security

VMware vRealize Log Insight vulnerability allows an unauthenticated attacker to take full control of a target system.

IoT Security

Lexmark warns of a remote code execution (RCE) vulnerability impacting over 120 printer models, for which PoC code has been published.

Mobile & Wireless

Apple rolled out iOS 16.3 and macOS Ventura 13.2 to cover serious security vulnerabilities.

Email Security

Microsoft is urging customers to install the latest Exchange Server updates and harden their environments to prevent malicious attacks.

Mobile & Wireless

Technical details published for an Arm Mali GPU flaw leading to arbitrary kernel code execution and root on Pixel 6.

Vulnerabilities

Security researchers have observed an uptick in attacks targeting CVE-2021-35394, an RCE vulnerability in Realtek Jungle SDK.