Hacking

A flaw in the Packagist PHP repository could have allowed supply chain attacks

Experts disclosed a flaw in the PHP software package repository Packagist that could have been exploited to carry out supply chain attacks.

SonarSource Researchers disclosed details about a now-fixed vulnerability (CVE-2022-24828) in PHP software package repository Packagist,, that could have been exploited to carry out supply chain attacks. The issue was addressed within hours by the maintainers of the impacted repository. 

“Sonar discovered and responsibly disclosed a critical vulnerability in Packagist, a central component of the PHP supply chain, to help secure developer tools.” reads the post published by SonarSource.

“This vulnerability allows gaining control of Packagist. It is used by the PHP package manager Composer to determine and download software dependencies that are included by developers in their projects.

Virtually all organizations running PHP code are using Composer, which serves 2 billion software packages every month. More than a hundred million of these requests could have been hijacked to distribute malicious dependencies and compromise millions of servers.”

The experts pointed out that an attacker can have triggered the high-severity flaw to take control of the server distributing information about existing PHP software packages, and potentially to compromise every organization that uses them. 

The CVE-2022-24828 (CVSS score: 8.8) flaw is a command injection issue and the experts explained it is linked to another command injection Composer vulnerability, tracked as CVE-2021-29472.

“During our security research, we discovered a critical vulnerability in the source code of Composer which is used by Packagist. It allowed us to execute arbitrary system commands on the Packagist.org server.” reads the post published by SonarSource in April 2021, “A vulnerability in such a central component, serving more than 100M package metadata requests per month, has a huge impact as this access could have been used to steal maintainers’ credentials or to redirect package downloads to third-party servers delivering backdoored dependencies.”

Below is the step-by-step procedure that could have allowed attackers to exploit the vulnerability against Packagist:

  • Create a project in a remote Mercurial repository;
  • Put the manifest in composer.json and add a malicious readme entry;
  • When using a payload like the one depicted above, create a file named payload.sh to perform the desired actions;
    undefined
  • Import the package on Packagist, and request an update of the package.

The researchers also published a video PoC that demonstrate the execution of arbitrary commands on the server: 

“The next step would be to modify the definition of a package to point to an unintended destination and compromise the application in which they are used; this is something that we’ve already demonstrated in our Insomni’hack talk and won’t be presented again in this article.” continues SonarSource. “The exploitability of this vulnerability on the production instance, packagist.org, was also demonstrated with a non-destructive command.”

Experts highlighted that backend services perform the association between the name of a package and where the package manager should download it from. This means that an attacker can compromise these services to force users to download backdoored software dependencies the next time they do a fresh install or an update of a Composer package based on data from 2021. The issue can impact most open-source and commercial PHP projects because Composer is the standard package manager for PHP.

Composer versions 1.10.26, 2.2.12, and 2.3.5 addressed the issue, the good news is that at this time there is no evidence the vulnerability has been exploited in the wild.

“We demonstrated how we discovered an argument injection in the backend services of the PHP package manager Composer and could successfully exploit it to compromise any PHP software dependency.” concludes the report.

Follow me on Twitter: @securityaffairs and Facebook

[adrotate banner=”9″][adrotate banner=”12″]

Pierluigi Paganini

(SecurityAffairs – hacking, Log4Shell)

[adrotate banner=”5″]

[adrotate banner=”13″]

Pierluigi Paganini

Pierluigi Paganini is member of the ENISA (European Union Agency for Network and Information Security) Threat Landscape Stakeholder Group and Cyber G7 Group, he is also a Security Evangelist, Security Analyst and Freelance Writer. Editor-in-Chief at "Cyber Defense Magazine", Pierluigi is a cyber security expert with over 20 years experience in the field, he is Certified Ethical Hacker at EC Council in London. The passion for writing and a strong belief that security is founded on sharing and awareness led Pierluigi to find the security blog "Security Affairs" recently named a Top National Security Resource for US. Pierluigi is a member of the "The Hacker News" team and he is a writer for some major publications in the field such as Cyber War Zone, ICTTF, Infosec Island, Infosec Institute, The Hacker News Magazine and for many other Security magazines. Author of the Books "The Deep Dark Web" and “Digital Virtual Currency and Bitcoin”.

Recent Posts

Fintech firm Figure disclosed data breach after employee phishing attack

Fintech firm Figure confirmed a data breach after hackers used social engineering to trick an…

19 hours ago

U.S. CISA adds a flaw in BeyondTrust RS and PRA to its Known Exploited Vulnerabilities catalog

The U.S. Cybersecurity and Infrastructure Security Agency (CISA) adds a flaw in BeyondTrust RS and…

20 hours ago

Suspected Russian hackers deploy CANFAIL malware against Ukraine

A new alleged Russia-linked APT group targeted Ukrainian defense, government, and energy groups, with CANFAIL…

1 day ago

New threat actor UAT-9921 deploys VoidLink against enterprise sectors

A new threat actor, UAT-9921, uses the modular VoidLink framework to target technology and financial…

2 days ago

Attackers exploit BeyondTrust CVE-2026-1731 within hours of PoC release

Attackers quickly targeted BeyondTrust flaw CVE-2026-1731 after a PoC was released, enabling unauthenticated remote code…

2 days ago

Google: state-backed hackers exploit Gemini AI for cyber recon and attacks

Google says nation-state actors used Gemini AI for reconnaissance and attack support in cyber operations.…

2 days ago

This website uses cookies.