Wiki / Version disclosure
Warning: X-Powered-By reveals the technology
The response says which software builds the pages and, with PHP, its exact version. That is not a hole in itself, but it tells automated scanners which sites to try a version-specific exploit on. Low urgency: one setting.
What it does not mean. It does not mean PHP is outdated: that is judged by the separate report line “PHP version”, which reads the version from this very header. Switch the header off and that line disappears too, while PHP itself stays what it was.
- In our report
- Warning (yellow), category weight 0.5 of 2.0
- Time to fix
- 5 minutes plus a restart of PHP or the web server
- Can it break things
- The header controls nothing. Only a wrongly placed line breaks things (see below)
How to fix it
The most reliable place to switch it off is where it is produced: the PHP settings. The web server lines are for when php.ini is out of your reach.
PHP, php.ini (tested with 8.4.14)
expose_php = OffCan be changed in php.ini only; restart PHP-FPM or the web server afterwards. PHP ships with it on; the Ubuntu package on our test server (PHP 8.3.6) already has it off.
Without access to php.ini (tested with 8.4.14)
<?php header_remove('X-Powered-By');The line has to sit in a file every request loads and run before any output is sent.
nginx (tested on 1.26.3 with PHP 8.3.6 over FastCGI)
fastcgi_hide_header X-Powered-By;Goes into http, server or location. If nginx passes requests to another server with proxy_pass, the equivalent is proxy_hide_header X-Powered-By; (also tested).
Apache (tested on 2.4.59, also works in .htaccess)
Header always unset X-Powered-By
Header unset X-Powered-ByYou need both lines. With PHP running through PHP-FPM (mod_proxy_fcgi) or CGI, only the always line removed the header. With Apache passing requests to another server through ProxyPass, only the line without always did. Not tested with mod_php.

expose_php off, and an attempt to switch it off from code, which does not work.How to check
curl -sI https://example.com | grep -i x-powered-byExpected
(empty: the header is gone)Test an address that PHP generates, not an image or a CSS file: static files never carry this header anyway.
What can break
php_flag expose_php offin .htaccess: our test Apache withoutmod_phpanswered 500 (“Invalid command 'php_flag'”). Withmod_phpthe line would not help either, because this setting can be changed in php.ini only.ini_set('expose_php', '0')in code does nothing: the call returnedfalseand the header stayed.- A single Apache
Header unsetline withoutalwaysfails silently with PHP-FPM: no error, and the header is still there. Always check with the command below after the change.
Possible values
PHP is not the only sender. The last two rows come from the vendors' documentation; we did not test them.
| Sender | Why | Where to switch it off |
|---|---|---|
| PHP | expose_php is on by default | php.ini: expose_php = Off |
| Express (Node.js) | The header is sent by default | In the application code: app.disable('x-powered-by') |
| IIS | X-Powered-By: ASP.NET is in the default customHeaders list | web.config, the remove child of customHeaders |
Sources
- PHP manual: expose_php (php.ini directives)
- PHP manual: header_remove
- nginx documentation: fastcgi_hide_header
- nginx documentation: proxy_hide_header
- Apache documentation: mod_headers (onsuccess and always conditions)
- Express documentation: security best practices
- Microsoft: IIS customHeaders
Changes
- Page published; PHP, nginx and Apache lines tested on test servers.
