What I learned today: auto_prepend_file auto_prepend_file is a standard PHP conf...
Stephan Berger @malmoeb@infosec.exchange
What I learned today: auto_prepend_file
auto_prepend_file is a standard PHP configuration directive. It names a file that PHP parses automatically before the script that was actually requested. Point it at a payload, and that payload executes on every single PHP request to the site.
.user.ini is how that directive gets set without server access. When PHP runs as FastCGI or PHP-FPM, which is the normal configuration on modern shared and cPanel hosting, PHP reads a per-directory .user.ini file that any account with file-write access can create. No root, no control-panel login, and no server configuration change is required. Write access to the web directory is enough, which is precisely what we encountered on a recent Incident Response engagement.
But a .user.ini file does not automatically mean your server is compromised.
In our case, we identified several such files in different directories. However, when you find a .user.ini with the content "auto_prepend_file = hpzgadna.php" (spot the random filename?), then you might want to have a closer look.
More information here:
https://wpserverguard.com/guides/user-ini-auto-prepend-file-malware/