phpinfo() Page Exposed

A page that calls phpinfo() is publicly accessible, revealing detailed PHP, server and environment information, including values that may be secret.

SeverityMedium
CVSS 3.15.3 CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N Open in the calculator
CVSS 4.06.9 CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N Open in the calculator
CWECWE-497: Exposure of Sensitive System Information to an Unauthorized Control Sphere
OWASP Top 10A01:2025 Broken Access Control
MITRE ATT&CKT1592.002 Software
CategoryInformation Disclosure

Description

A script that calls the PHP function phpinfo(), often named phpinfo.php, info.php or test.php, has been left on the server and can be requested by anyone, without authentication. The function prints a detailed report of the PHP installation: its version and build options, every loaded extension and its version, the effective settings from php.ini (such as disable_functions, open_basedir, allow_url_include and the session and upload settings), file system paths including the document root, the operating system and host name, environment variables, and the request itself, including all headers and cookies received.

The report gives an attacker an accurate picture for targeting further attacks: exact versions to match against known vulnerabilities, settings that show which exploitation techniques will work, and absolute paths that help with file inclusion and path traversal attacks. The environment variables can include database passwords and API keys, particularly where the application is configured through its environment, as is common with containers, and where they do, the disclosure leads directly to wider access.

Because the page also displays the cookies the server received, including those marked HttpOnly, it removes the protection that HttpOnly gives session cookies against cross-site scripting: a cross-site scripting flaw elsewhere on the same site can read a user's session cookie by fetching the page.

The page is found through content discovery with common file names, and most web scanners report it.

Remediation

Remove the page, and prevent similar diagnostic output in production:

  • Delete scripts that call phpinfo() from all production servers, searching the web root for the function name, and keep diagnostic scripts out of deployment packages.
  • Disable the function in production by adding it to disable_functions in php.ini, keeping any functions already listed.
  • Where diagnostic information is needed, collect it from the command line or restrict it to authenticated administrators.
  • Set expose_php = Off to stop PHP announcing its version in response headers.
  • Rotate any secrets that appeared in the page's environment variables.
; php.ini disable_functions = phpinfo expose_php = Off

Confirm the fix by requesting the page, and common alternative names for it, again: each should return 404.

References


Add This Finding to Your Library

In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.

Free trial  ·  No card required

Only need the reporting? Our reporting tool is free and open source, with the same library.


More Web Applications Findings

Every Web Applications finding