Guides · ← All guides
phpinfo() in Production: The Diagnostic Page That Maps Your Server for Attackers
Published: November 14, 2026 · Last reviewed: November 14, 2026 · 7 min read
Run a free BreachHunter assessment on your site →
There is a specific archaeology to this finding. During setup or a debugging session, someone creates info.php or phpinfo.php, confirms the configuration, and means to delete it. The deployment ships. The file — small, quiet, never linked — waits. Years later a scanner asks for it by name, because scanners always ask, and the server answers with the most complete self-description it publishes anywhere.
This guide covers what an attacker does with each section of the output (version targeting, path disclosure, environment secrets), why “but nobody knows the URL” fails (the name list is short and public), and the environment hygiene — display_errors off, diagnostics gated — that keeps the next debugging session from repeating it.
What does an attacker do with phpinfo output?
Start at the top: the exact PHP version converts the public CVE database into a personal menu — the same version-targeting problem as server banners, except phpinfo adds the loaded-extension list, so the menu is filtered to what is actually installed. Then the paths: document root, include paths and temp directories turn later attacks (file inclusion, upload handling, log poisoning) from exploration into arithmetic.
The environment section is the sleeper. Servers that receive secrets through environment variables — database URLs, API keys, session secrets — print them here in full. At that point phpinfo stops being reconnaissance and becomes the credential leak itself, joining the .env class of incidents: rotate what it showed. Even without secrets, the page confirms the operating system, the web server API and the disable_functions list — a precise statement of what the attacker need not bother trying.
Why deletion, and what replaces it in a real debugging session?
Some findings are fixed by configuration; this one is fixed by absence. There is no production use case for a public page that dumps the environment — every legitimate need (checking a version, confirming an extension) is served better by the command line (php -v, php -m) or a log-gated admin tool. Password-protecting the page is the common half-measure and the wrong one: it leaves a high-value file behind a single credential on the public internet, forever on the probe lists.
The process fix is to make the file unshippable: deployment pipelines that exclude diagnostic filenames by pattern (phpinfo*, info.php, test.php), and a production configuration with display_errors off so PHP itself stops volunteering stack traces and paths on error pages — the same information-disclosure family the web audit checks. The scanner retest is trivially binary: the URL returns 404, or it does not.
Worked example: juniperinteriors.example
Juniper Interiors, a design studio with a PHP-based portfolio and client portal, had its phpinfo page created during a 2023 hosting migration to verify the new server's PHP version. It verified it for everyone, for three years:
GET /phpinfo.php -> 200 PHP Version: 8.0.30 (EOL branch) DOCUMENT_ROOT: /var/www/juniperinteriors/public env: DB_HOST, DB_NAME, DB_USER visible; DB_PASS present in environment block
Because the environment block printed real database credentials, the response ran as a credential exposure: DB password rotated, the file deleted, and the deploy pipeline given an exclusion list for diagnostic names. The migration checklist got one new line — “diagnostics live on the staging box, never in the shipped tree” — and the studio's retest showed 404 with the PHP version now undisclosed anywhere public. The HIGH finding's 8 points returned, but the owners cared more about the sentence in the retest: nothing on the public site describes the server anymore.
The five actions to take
Removing diagnostic exposure from production:
- Probe for phpinfo.php, info.php, test.php and similar names on every vhost — then delete, never just rename or protect.
- If the page was reachable, inventory what it printed (especially environment variables) and rotate any credential it exposed.
- Set display_errors off in production PHP so errors stop publishing paths and traces.
- Add diagnostic filenames to the deploy exclusion list so the file cannot ship again.
- Re-scan to confirm 404s across all probed diagnostic paths.
Run a free BreachHunter assessment on your site →
Frequently asked questions
We renamed ours to something obscure. Is that safe?
Safer than phpinfo.php, still not safe: obscure names leak through logs, referrers, repo history and directory probing, and the file's value to an attacker justifies patience. The control that works is absence. Rename plus delete-the-habit beats rename alone — but deletion beats both.
Is phpinfo exposure really HIGH if there are no secrets in the environment?
The scanner rates the standard case HIGH because the version-plus-modules-plus-paths package is a genuine attack roadmap, and the scanner cannot know from outside whether your environment section holds secrets. If yours does, the real severity is higher than the label.
What about other frameworks' diagnostic pages?
The pattern generalizes: framework debug toolbars, /_profiler, /actuator/env, server-status pages. Each ecosystem has a “developer X-ray” that must not survive to production — several have their own rows in the scanner's sensitive-path table.
How do developers check PHP config without the page?
From the shell: php -v, php -m, php --ini, or a CLI one-liner printing the single value in question. On shared hosting without shell access, create the page, read it, delete it in the same session — and let the deploy exclusion list be the backstop.
Could our host have created this file?
Some control panels and migration tools do generate diagnostic pages. That changes the conversation with your host, not the fix: delete it, and add the post-migration probe to your checklist so the next migration's leftovers get caught by you first.
Sources
Where this guide's claims come from, in citable form:
- PHP manual — phpinfo() (2025) — the function's own page, including what it prints.
- OWASP Web Security Testing Guide (2021) — fingerprinting web application framework test cases.