Summary
Cockpit CMS before release 364 exposes a path traversal and local file inclusion flaw in how it constructs filesystem paths from URL data.
By injecting crafted path segments into the request URL, an unauthenticated attacker can read arbitrary files or trigger execution of local PHP files under certain server configurations.
Affected context
The vulnerability affects Cockpit CMS deployments running versions prior to release 364 where routing logic uses PATH_INFO derived from REQUEST_URI to construct filesystem paths.
It becomes relevant when user-controlled URL segments are concatenated into paths pointing into the application's "spaces" or similar content directories without normalizing and constraining the final path.
Environments using the PHP built-in server or permissive/non-default Nginx configurations that allow interpreted PHP files in the targeted directories are particularly exposed to the local file inclusion behavior.
Exploit preconditions
- Attack surface: HTTP interface of the Cockpit CMS instance.
- Required access: No authentication required; attacker only needs network access to the web endpoint.
- Trigger point: Specially crafted URLs containing
../-style segments in PATH_INFO that are incorporated into the filesystem path used to locate content. - Why exploitation is possible: The application uses REQUEST_URI-derived PATH_INFO to build a filesystem path without robust normalization or containment checks, allowing traversal outside the intended directory.
If the resolved path ends in .php and the server configuration executes such files, the application passes this path into include(), enabling local file inclusion.
Why this happens
The core issue is improper neutralization of path traversal sequences when mapping web request paths to filesystem locations.
Cockpit CMS directly incorporates PATH_INFO derived from REQUEST_URI into a filesystem path, assuming it will remain within a designated directory (such as a "spaces" folder) but failing to normalize and validate the final resolved path.
As a result, ../-style sequences can escape the intended root and point to arbitrary files elsewhere on the server.
In cases where the computed path ends with .php, the code routes it into PHP's include(), effectively allowing an attacker to make the runtime execute local PHP files, turning a directory traversal (CWE-22) into a local file inclusion pattern.
Potential impact
- An attacker may read sensitive local files accessible to the PHP process (e.g., configuration files, credentials, or application source).
- An attacker could include and execute existing PHP files on the server, potentially chaining with other weaknesses for code execution.
- Application data confidentiality can be compromised through disclosure of environment, database, or secret keys.
- System-level security may be weakened by exposing internal paths, server configuration details, and other reconnaissance data.
General mitigation guidance
Effective mitigation focuses on strict path handling and controlled inclusion of server-side resources:
- Normalize and canonicalize any user-influenced path segments before use, resolving
.and..components and rejecting paths that escape the intended root directory. - Enforce a hard root (chroot-like behavior) by verifying that the final resolved path always remains within a predefined base directory for content.
- Use allowlists of valid logical identifiers or resource names instead of directly mapping URL segments to arbitrary filesystem paths.
- Avoid passing unvalidated, computed paths directly into
include()or similar functions; prefer mapping to pre-defined templates or using routing tables. - Where possible, isolate content and executable code into separate directories so that user-controlled paths cannot reach executable PHP files.
- Run the application with least-privilege file system permissions so that even if traversal occurs, access to sensitive system files is limited.
How teams detect issues like this
Detection typically combines static analysis, configuration review, and runtime monitoring:
- Use static analysis rules to flag concatenation of REQUEST_URI or PATH_INFO into filesystem paths, especially when used with functions like
include,require,file_get_contents, or directory listing APIs. - During code review, look for routing logic that does not normalize and validate paths, lacks checks against directory traversal sequences, or does not enforce a fixed base directory.
- Implement application-level logging of suspicious request paths containing
../or unusual patterns, and monitor logs for repeated traversal attempts. - Employ web application firewalls (WAFs) or reverse proxies with rules to detect and optionally block traversal patterns in URLs.
- In automated security testing pipelines, include checks that attempt to access known sensitive files (e.g.,
/etc/passwd, application config files) via crafted paths and alert when responses indicate traversal.

