In an attempt to compromise the PHP codebase, two malicious commits were pushed to the official PHP Git repository. The incident is alarming considering PHP remains the server-side programming language to power over 79% of the websites on the Internet. In the malicious commits seen by BleepingComputer, the attackers published a mysterious change upstream, “fix typo” under the pretence this was a minor typographical correction.
However, taking a look at the added line 370 where the zend_eval_string function is called, the code actually plants a backdoor for obtaining easy Remote Code Execution (RCE) on a website running this hijacked version of PHP.
“This line executes PHP code from within the user-agent HTTP header, if the string starts with ‘zerodium’,” responded PHP developer Jake Birchall to Michael Voříšek, who had first pointed out the anomaly.
In an interview, PHP maintainer Nikita Popov added:
“The first commit was found a couple of hours after it was made, as part of routine post-commit code review. The changes were rather obviously malicious and reverted right away.”
Additionally, the malicious commit was made in the name of PHP creator, Rasmus Lerdorf.
But, that is hardly surprising as with source code version control systems like Git, it is possible to sign-off a commit as coming from anybody else locally and then upload the forged commit to the remote Git server, where it gives off the impression as if it had indeed been signed-off by the person named on it.
Although a complete investigation of the incident is ongoing, according to PHP maintainers, this malicious activity stemmed from the compromised git.php.net server, rather than a compromise of an individual’s Git account.
Following this incident, PHP maintainers have decided to migrate the official PHP source code repository to GitHub.
“While the investigation is still underway, we have decided that maintaining our own git infrastructure is an unnecessary security risk and that we will discontinue the git.php.net server.”
With this change going forward Popov insists that any code changes be pushed directly to GitHub rather than the git.php.net server from this point on.
Those interested in contributing to the PHP project will now need to be added as a part of the PHP organization on GitHub. The instructions on that are provided in the same security announcement.
BleepingComputer reached out to both Popov and the PHP security team to find out the complete extent of this compromise, and if any code was distributed downstream before the malicious commits were caught.
The PHP team has confirmed to BleepingComputer that they plan on eventually decommissioning their git server in the upcoming days and moving to GitHub permanently.