Summary
SimpleSAMLphp's CAS server module previously constructed ticket file paths by concatenating a configured directory with attacker-controlled ticket identifiers, enabling directory traversal.
In deployments using the file-based ticket store, a remote attacker can make the server read and unserialize arbitrary files and, in some flows, delete them if filesystem permissions allow.
Affected context
The vulnerability occurs in SimpleSAMLphp-casserver deployments that:
- Use the
FileSystemTicketStorebackend for CAS tickets - Accept CAS
ticketorpgtparameters on public validation/proxy endpoints - Construct file paths by directly concatenating the ticket directory with user-provided identifiers
- Rely on serialized PHP objects stored in the ticket files
It becomes relevant when the PHP process has read and delete permissions on files reachable through directory traversal sequences from the configured ticket directory.
Exploit preconditions
- Attack surface: Public CAS 1.0/2.0 validation and proxy endpoints that accept
ticketorpgtquery parameters. - Required access: Remote, unauthenticated ability to send HTTP requests to the CAS server endpoints.
- Trigger point: The server attempts to load a ticket from the file-based ticket store using the supplied ticket identifier.
- Why exploitation is possible: The ticket file path is built via string concatenation of a base directory and unvalidated attacker-controlled input, allowing
../sequences to escape the intended directory. The resulting file is then read and unserialized, and in the CAS 1.0 flow, the same path is also used for deletion.
Why this happens
The core issue is an improper construction and validation of filesystem paths derived from user input, mapping to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Instead of normalizing and strictly enforcing that the resolved path stays within the intended ticket directory, the implementation concatenates the configured base path with the ticket or pgt parameter. This allows ../ and similar traversal patterns to reference arbitrary files accessible to the PHP process. The design is further compounded by coupling file path resolution with unserialization and deletion logic, so any reachable file may be read, unserialized, and in some flows removed, if it satisfies type expectations.
Potential impact
- Attacker-controlled path traversal may allow reading and unserializing arbitrary files accessible to the PHP process.
- Deserialization of unexpected data can expose sensitive information stored in serialized PHP structures.
- In CAS 1.0 validation flows, the same path may be used for deletion, allowing an attacker to delete arbitrary files the PHP process can remove.
- Application instability or partial denial of service if critical configuration or state files are removed.
- Expansion of impact if unserialized content influences authorization decisions or session handling.
General mitigation guidance
Effective mitigation typically focuses on tightening how filesystem paths are derived from user input and decoupling them from sensitive operations:
- Normalize and validate any derived file path, ensuring the resolved canonical path remains strictly within the configured ticket directory.
- Replace direct string concatenation with path-joining utilities that enforce directory boundaries and reject traversal sequences.
- Treat all external identifiers (e.g.,
ticket,pgt) as opaque keys, mapping them to internally generated filenames using whitelisted character sets or hashing, rather than allowing raw identifiers to influence paths. - Reduce reliance on PHP serialization for ticket storage and prefer safer, simpler data formats where possible.
- Apply least-privilege filesystem permissions so the CAS process can access only the specific directory required for ticket files and cannot delete or read unrelated paths.
How teams detect issues like this
Detection can leverage both code-centric and operational approaches:
- Static analysis rules looking for path construction patterns where user-controlled input is concatenated with directory paths before file operations such as
file_get_contents,unlink, or similar functions. - Code review checklists that flag any use of request parameters to build filesystem paths without canonicalization and directory containment checks.
- Security unit and integration tests that submit
ticketorpgtvalues containing../sequences, verifying that traversal attempts are rejected. - Runtime monitoring for unexpected filesystem access patterns from the CAS process, especially reads or deletes outside the intended ticket directory, using audit logs or host-based intrusion detection.

