Critical Vulnerability Patched in PHP Package Repository
31.8.18 securityweek Vulnerebility
A critical remote code execution vulnerability was recently addressed in packagist.org, a large PHP package repository, a security researcher reveals.
An open source project, Packagist is the default package server behind Composer, a tool for dependency management in PHP, as it aggregates public PHP packages installable with the utility. The packagist.org site helps users search for packages and lets Composer know where to get the code from.
Statistics on the website show that Packagist has delivered billions of packages since its inception in 2012, and that it is currently serving around 400 million package installs per month.
What security researcher Max Justicz discovered was that there was a “big text field on the site” that allowed anyone to type $(execute me), which would result in the command being executed in a shell.
The issue, Justicz says, resided in the package repository’s functionality that allows users to upload packages.
“You upload packages to Packagist by providing a URL to a Git, Perforce, Subversion, or Mercurial repository. To identify what kind of repository the URL points to, Packagist shells out to git, p4, svn, and hg, with application-specific commands that include this URL as an argument,” the researcher notes.
However, when checking the provided URL, Packagist was improperly escaping input. Any commands an attacker would have provided were executed twice.
“The Packagist team quickly resolved this issue by escaping the relevant parameters in the Composer repository,” Justicz reveals.
The security researcher, who over the past year discovered multiple issues on popular repositories, warns of the high probability that package manager servers could be compromised in the future.
“The flaw could have been easily avoided by setting parameters on what users can input into text boxes. Without parameters, text boxes become entry points for bad actors to execute malicious commands in order to access the server and, once there, potentially gain access to credentials that will let them hop from one server to another while harvesting sensitive information,” Mike Bittner, Digital Threat Analyst for The Media Trust, told SecurityWeek in an emailed comment.
“Developers should make security a priority all throughout a product's lifecycle stages, from concept to manufacturing to retirement. Website operators should police all their website third-party code providers to ensure their activities align with policies, and scan their sites to identify and obstruct unauthorized code,” Bittner concluded.