Join our Newsletter — 33% off our NHI Course
Home› Glossary› Architecture & Implementation› Cgi.fix_pathinfo
Architecture & Implementation

Cgi.fix_pathinfo

← Back to Glossary
By NHI Mgmt Group Updated November 25, 2026 Domain: Architecture & Implementation

Cgi.fix_pathinfo is a CGI runtime setting that controls how PHP resolves script paths when a requested filename does not exactly match a real file. When enabled, the interpreter may continue searching for a nearby script, which can alter request routing and create file execution exposure if path handling is weak.

What the setting changes in PHP-CGI

Cgi.fix_pathinfo affects how PHP-CGI interprets a request when the target filename does not exactly map to an existing script. If the setting allows path traversal-style fallback, the runtime may continue resolving a nearby file instead of stopping at the requested path, which changes how requests are routed to executable code.

This matters because CGI and PHP are not just serving static content, they are deciding which file path becomes executable. A weakly constrained path-resolution step can let an apparently harmless request reach a script the operator did not intend to expose.

Why path resolution can become a security boundary

The security issue is not PHP itself but the gap between a web request path and the filesystem path that the interpreter ultimately executes. When that mapping is permissive, an attacker can sometimes influence whether a file is treated as content or as code, especially where upload handling, rewrite rules, or partial path matching are involved.

That is why this setting sits in the same practical conversation as request routing, script exposure, and least-surprise file handling. The risk is strongest when the web server, PHP handler, and application all make slightly different assumptions about what should be executable.

Operational contexts where it matters most

Cgi.fix_pathinfo is most important in environments that still rely on CGI or PHP-CGI style execution rather than a more tightly controlled application server boundary. It becomes more sensitive when the document root contains user-writable paths, when files are uploaded into web-accessible locations, or when path rewriting can reshape the request before it reaches the interpreter.

In those setups, a small configuration choice can determine whether the interpreter rejects a non-exact path or keeps searching for a script that matches nearby. The latter behaviour can widen the attack surface if the application assumes the request path and executed path are always identical.

How to think about safe handling

The safest mental model is to treat file-to-code resolution as part of the trust boundary, not a cosmetic runtime convenience. If the application depends on exact script targeting, the configuration should be paired with strict filesystem permissions, careful upload placement, and clear separation between static content and executable code.

When reviewing a deployment, the question is not only whether the site works, but whether the path the user requested is the same path the interpreter can execute. If those two paths can diverge, the configuration deserves the same attention as any other request-routing control.

Risk and Threat Considerations

Permissive path resolution can create file execution exposure when an attacker can make PHP-CGI resolve a different script than the one originally requested. That is especially dangerous in web stacks where uploaded or attacker-influenced files sit near executable paths, because the weakness turns a path-handling quirk into code execution potential.

Failure mechanism: The interpreter follows a nearby executable path after the requested filename fails to match exactly, which can turn routing ambiguity into unintended script execution.

Impact: Attackers may be able to reach code paths they should not control, expand initial access into remote code execution, or abuse misrouted requests to trigger application behaviour outside the intended request flow.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

NIST SP 800-53 Rev 5, CIS Controls v8 and OWASP ASVS set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
NIST SP 800-53 Rev 5AC-3 — Access EnforcementControls which executable paths and request outcomes are permitted.
CM-6 — Configuration SettingsCgi.fix_pathinfo is a security-relevant runtime configuration choice.
SI-10 — Information Input ValidationPath handling here depends on how request input is interpreted and mapped to files.
Recommendation — Enforce exact script-access rules so only intended server paths can execute. Standardize and review the PHP-CGI setting as part of hardened configuration. Validate request paths so ambiguous filenames cannot redirect execution.
CIS Controls v8CIS-16 — Application Software SecurityHardening application runtimes and reducing unsafe execution paths fits secure software configuration.
CIS-4 — Secure Configuration of Enterprise Assets and SoftwareThe setting is a server software configuration that should be securely managed.
CIS-12 — Network Infrastructure ManagementWeb request routing and exposure are affected by how the server layer is managed and segmented.
Recommendation — Harden the web application stack to prevent unintended script execution paths. Baseline PHP and web server settings to remove unsafe path resolution behaviour. Place web execution paths behind controlled infrastructure and reduce exposure to the internet.
OWASP ASVSV13 — ConfigurationASVS configuration controls apply to runtime settings that alter request handling and script execution.
Recommendation — Verify that runtime configuration prevents ambiguous file-to-script resolution.

Practitioner Guidance

What to watch for: Review any deployment that still uses PHP-CGI-style handling for exact path semantics, especially where uploads, rewrites, or legacy CGI compatibility are involved. The key question is whether the runtime can ever execute a different file than the one the application expects.

Governance implication: Treat this setting as part of secure web server ownership, not a minor PHP preference. Configuration should be documented, reviewed alongside file permissions and upload controls, and validated whenever the hosting model or request-routing layer changes.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on November 25, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org