CheckWebSecurity Brand Logo

Article

Why an exposed phpinfo() page is a real problem (and how to find yours)

Published 2026-11-10

Why an exposed phpinfo() page is a real problem (and how to find yours)

Most of the security advice about phpinfo() is one sentence long: "disable it". The reasoning behind that sentence is worth knowing, because the same reasoning applies to a whole family of leaks that are less famous but just as common. A phpinfo page is not a hole someone breaks in through. It is a free reconnaissance report you hand to whoever asks.

This guide covers what the page actually reveals, why those specific details matter to an attacker, how to find out whether your server answers one, and what to do about the versions you cannot delete outright.

What phpinfo() actually outputs

Call phpinfo() anywhere in a PHP file and the response is a full status report of the PHP environment:

<?php phpinfo();

That one line prints, among other things:

  • The exact PHP version, down to the patch level.
  • Every loaded extension and its version: curl, OpenSSL, imagemagick, the database drivers.
  • The full server and environment variables. On a badly configured host this includes paths, sometimes internal hostnames, and occasionally credentials that someone carelessly exported.
  • All $_SERVER values, which contain your document root and often the real filesystem path behind the website.
  • Every php.ini setting, resolved: which extensions are on, what the memory limit is, whether file uploads are allowed and how big.
  • Which modules expose dangerous functions, like the exact path to sendmail or the enabled PDO drivers.

None of that is a secret in itself. But assembled on one page it answers most of the recon questions an attacker would otherwise have to guess at.

Why the details matter to an attacker

The value is in the combination. Three examples:

Exact versions. PHP 8.1.2 tells an attacker which known bugs exist for your runtime. Public CVE databases let anyone filter by version. The same goes for the extension list: an old curl or an unpatched OpenSSL shows up with its version number too. You do not need to believe that every version disclosure is exploited daily to accept that it removes the guessing step from someone's research.

Paths. The document root is often visible in the $_SERVER section. On shared hosting, the path reveals the account name (/home/something/public_html), which is exactly what an attacker needs if they later find a local file inclusion bug or an upload endpoint that trusts paths. If an exploit can read files, knowing where to point it halves the work.

Configuration decisions. disable_functions empty? Then system commands are available to any code execution bug. display_errors On in production? Error messages will leak database queries and paths to anyone who can trigger a warning. The page states all of it, plainly, to anyone who loads it.

There is also a quieter problem: phpinfo pages get archived. Crawl everything you have ever deployed and you will sometimes find old ones Google indexed years ago and nobody noticed. That is why the fix is not "hope it was not seen" but "stop serving it".

How to check whether your site has one

The fastest check is a scan. Point CheckWebSecurity at your domain and it looks for phpinfo.php, info.php, test.php and similar files among the common paths, the same way an attacker's tooling does. That covers the forgotten files.

The thorough check is on the server itself, because a scan can only find files it guesses at:

# grep for the function call across the docroot
grep -r "phpinfo" /var/www --include="*.php" -l

# Composer projects: check vendor noise too
grep -r "phpinfo" ./vendor --include="*.php" -l

On a WordPress site, also check the theme and plugin directories, and look at anything in wp-content/uploads with a .php extension. A phpinfo file in uploads is either leftover from an old debug session or a marker that someone was already inside.

One nuance worth knowing: some CMS installers leave a check file behind (for example install.php in a CMS root, or a hosting panel's auto-generated phpinfo.php in the web root). Those get forgotten because "the file was already there".

How to fix each version of the problem

The standalone file. Delete it. This is the whole fix for the classic phpinfo.php in the web root. If you need the page back someday you can recreate it in thirty seconds; there is no reason to keep it served.

The diagnostic call inside an application. Remove the call, or gate it so it can never run in production:

<?php
if (app()->environment('local')) {
    phpinfo();
}

In Laravel, php artisan about prints most of the same information on the command line, without ever producing a web response. In WordPress there is Site Health (Tools → Site Health → Info tab), which shows PHP version and key settings to logged-in admins only.

The function itself. If you administer the server and want the safety net, disable the function in php.ini:

disable_functions = phpinfo

Then restart PHP-FPM (systemctl restart php8.2-fpm on most current setups). Note that disable_functions is one of the settings that must match across CLI and web SAPIs if you want consistent behavior, and a php.ini that has been changed on the wrong SAPI is a classic way this fix silently does nothing. Verify it took effect after the restart:

php -r 'var_dump(function_exists("phpinfo"));'

That should print bool(false) on the web SAPI. If it prints bool(true), you edited the wrong ini file. Which ini file is actually loaded is the first line of any phpinfo output — the irony being you need the page once, locally, to be sure it can never load again.

Access restriction when you genuinely must keep one. Some teams keep an info page behind basic auth or an IP allowlist for debugging. If you do, name it something that is not in every dictionary of scanner paths, put it outside the docroot of the public site where possible, and treat the restriction as the only thing standing between it and the public internet. A "restricted" phpinfo page that returns 200 to everyone who knows the URL is the worst of both worlds.

What to check after you think it is gone

Deleting the file is step one. Two follow-ups matter:

Search engines and archives. If the page was publicly reachable long enough, it may be indexed or archived. Google Search Console lets you request removal of a URL from results. Internet Archive copies you cannot remove, but knowing they exist tells you how much of the old output is effectively public forever.

Your headers and general exposure. A phpinfo page is one item on a longer list of things a site unintentionally reveals: version headers, directory listing, verbose errors. Removing it does nothing about the others. An external assessment covers the whole list, which is the honest way to answer "what does my site leak" without guessing.

None of these fixes cost anything or require any tool beyond shell access. If you would rather have someone verify your site's external exposure — headers, TLS, forgotten files like this one — that is what CheckWebSecurity does: it checks what your site answers to the outside world and reports findings with plain-language explanations. Start a free check.


Related: WordPress security scanning without plugins · How website security checks work