Rapport om kompromiss av git-repositoriet och användardatabasen för PHP-projektet.

De första resultaten av analysen av incidenten angående upptäckten av två skadliga commits med en bakdörr i Git-repositoriet för PHP-projektet har offentliggjorts. Bakdörren aktiveras vid en begäran med en speciellt utformad User Agent-header. Under studiet av angriparnas aktivitet drogs slutsatsen att servern git.php.net, där Git-repositoriet var placerat, inte hade blivit hackad, men databasen med utvecklarnas konton hade blivit komprometterad.

Det utesluts inte att angriparna kunde ha laddat ner användardatabasen som lagrades i databasen på servern master.php.net. Innehållet på master.php.net har redan flyttats till den nya servern main.php.net, som har installerats från grunden. Alla lösenord för utvecklarna, som användes för att få tillgång till php.net-infrastrukturen, har återställts, och processen för att byta lösenord har initierats via en speciell återställningsformulär. Repositorierna git.php.net och svn.php.net förblir tillgängliga i skrivskyddat läge (utvecklingen har flyttats till GitHub).

Efter upptäckten av den första skadliga commit som genomfördes via kontot av Rasmus Lerdorf, grundaren av PHP, gjordes antagandet att hans konto hade blivit hackat och Nikita Popov, en av de nyckelutvecklare inom PHP, rullade tillbaka ändringarna och blockerade commit-rättigheterna för det problematiska kontot. Efter en tid insåg man att blockeringen var meningslös, eftersom utan verifiering av commits genom digitala signer, kunde varje deltagare med tillgång till php-src-repositoriet göra en ändring genom att använda ett falskt författarnamn.

Sedan skickade angriparna en skadlig commit i namn av Nikita själv. Genom att analysera loggarna från gitolite-tjänsten, som används för att organisera tillgång till repositorier, gjordes ett försök att identifiera den deltagare som faktiskt hade gjort ändringarna. Trots att alla commits registrerades fanns det inga loggar för de två skadliga ändringarna. Det blev klart att infrastrukturen hade komprometterats, eftersom commits hade lagts till direkt, utan att gå igenom anslutningen via gitolite.

Server git.php.net was promptly disabled, and the primary repository was moved to GitHub. In the rush, it was overlooked that there was another access method to the repository besides SSH with gitolite, allowing commits to be sent via HTTPS. In this case, the git-http-backend was used for interaction with Git, and authentication was handled by the Apache2 HTTP server, which validated credentials by querying a database hosted in the DBMS on servern master.php.net. Access was permitted not only by keys but also with a regular password. An analysis of the HTTP server logs confirmed that malicious changes were made through HTTPS.

Upon examining the logs, it was found that the attackers did not connect on their first attempt; initially, they tried to guess the username, but after determining it, they logged in successfully on the first try, indicating that they already knew the passwords of Rasmus and Nikita, but not their usernames. If the attackers gained access to the DBMS, it's unclear why they did not immediately use the correct username given there. This inconsistency lacks a credible explanation. The hacking of master.php.net is considered the most likely scenario, as on this  servern an outdated code and an obsolete OS were used, which had not been updated for a long time and had unpatched vulnerabilities.

Among the actions taken, the reinstallation of the server environment for master.php.net and the migration of scripts to the new PHP 8 version were noted. The code for working with the DBMS has been rewritten to use parameterized queries, complicating SQL injection attempts. The bcrypt algorithm is now employed for storing password hashes in the database (previously, passwords were stored using the unreliable MD5 hash). Existing passwords have been reset, and a new password can be set through the password recovery form. Since access to the repositories git.php.net and svn.php.net over HTTPS was tied to MD5 hashes, it was decided to leave git.php.net and svn.php.net in read-only mode and to migrate all remaining PECL extension repositories to GitHub, following the same method as the main PHP repository.

Källa: opennet.ru

Köp pålitlig webbhotell med DDoS-skydd, VPS VDS-servrar 🔥 Köp pålitlig webbhotell med DDoS-skydd, VPS VDS-servrar | ProHoster