//nefariousplan

CVE-2026-46491: SimpleSAMLphp casserver's Validation Endpoint Reads And Deletes Files. The Check Was Removed In A 2013 Refactor.

vendor

patterns

cve

proof of concept

SimpleSAMLphp's casserver module has shipped FileSystemTicketStore with no path-traversal check on its public CAS validation endpoint since February 22, 2013. The check existed in 2012. A commit titled removed ticket creation from ticket store removed it. The commit title named the cargo. It did not name the safety net riding along. CVE-2026-46491, scored 8.6 and patched on May 15, 2026 in v7.0.3, is what an attacker does with a CAS server that has been a path traversal sink for thirteen years.

The validation endpoint is the file primitive

A CAS server's job is to issue tickets to authenticated clients and validate them when service applications come back to verify what the redirect claimed. The validation endpoint is by specification unauthenticated. Any service the CAS server federates with calls /validate?ticket=ST-...&service=https://my-app.example.org to confirm that the bearer of ST-... is who the redirect said they were. The CAS server reads the ticket from its store, confirms the service URL matches, and responds with the username.

SimpleSAMLphp's simplesamlphp-module-casserver is the SimpleSAMLphp project's CAS server. It is the kind of component a university SSO operator picks because it is in the same codebase as the SAML stack their identity federation already runs. The ticket store is pluggable. The default backend is FileSystemTicketStore, which writes each ticket to a file under a configured directory with the ticket ID as the filename.

CVE-2026-46491 names the public concatenation. Here is getTicket as shipped through v7.0.2, the last release before the May 2026 fix:

public function getTicket(string $ticketId): ?array
{
    $filename = $this->pathToTicketDirectory . '/' . $ticketId;

    if (file_exists($filename)) {
        $content = file_get_contents($filename);

        return unserialize($content);
    } else {
        return null;
    }
}

$ticketId is the value of the ticket query parameter from the public validation endpoint. The handler concatenates it onto the configured directory, calls file_get_contents, then unserialize. There is no filter on the path. There is no allowed_classes argument to unserialize.

?ticket=../../etc/casserver/config.php reads the configured ticket directory's neighbor. ?ticket=../../../../var/lib/php/sessions/sess_aaaaa reads a session file. The file_exists check fails silently for non-targets and reads the contents of everything else.

CAS 1.0 deletes the file before it verifies the ticket

The validation endpoint that takes the worst path is the CAS 1.0 /validate. Here is the relevant block of Cas10Controller::validate:

try {
    // Get the service ticket
    // `getTicket` uses the unserializable method and Objects may throw Throwables in their
    // unserialization handlers.
    $serviceTicket = $this->ticketStore->getTicket($ticket);
    // Delete the ticket
    $this->ticketStore->deleteTicket($ticket);
} catch (Exception $e) {
    Logger::error('casserver:validate: internal server error. ' . var_export($e->getMessage(), true));
    return new Response(
        $this->cas10Protocol->getValidateFailureResponse(),
        Response::HTTP_INTERNAL_SERVER_ERROR,
    );
}

Read the ordering. getTicket runs, then deleteTicket runs, then the controller starts checking whether the ticket is real. The check that the ticket actually identifies a CAS service ticket happens after the file has already been read, unserialized, and unlinked. The two operations resolve the same path: getTicket calls $this->pathToTicketDirectory . '/' . $ticketId, deleteTicket calls $this->pathToTicketDirectory . '/' . $ticketId. Same input. Same string. Different syscall.

For deleteTicket to fire, getTicket must not have thrown. getTicket declares its return type as ?array under declare(strict_types=1), so a return value of anything other than null or array raises TypeError. unserialize on garbage returns false, which triggers TypeError and short-circuits the try block before the delete. unserialize on a serialized integer or string triggers the same. The narrow channel is files whose contents unserialize to an array, or to the literal two-byte N; (serialized null). Cached PHP application state lives in serialized arrays. Other CAS tickets in the same directory are serialized arrays. Any file written somewhere on the filesystem by a PHP application that called serialize($somearray) qualifies.

A campaign reads the disclosure primitive first to map the filesystem and find arrays-on-disk, then comes back with the same primitive to take them out. The author's comment on line 114 admits the read side of this knowingly:

// `getTicket` uses the unserializable method and Objects may throw Throwables in their
// unserialization handlers.

The comment exists because something in the pipeline kept throwing at unserialize time and crashing the validator. The author caught the throw to keep the endpoint up. They did not ask why an unserialize call on a presumed-internal ticket file was producing object handlers that threw. The presumed-internal file was not the only file being unserialized.

The check existed in 2012

The original FileSystemTicketStore landed on November 29, 2012, in commit d217e01, authored by Bjørn Rohde Jensen at Statsbiblioteket, the Danish state library. The first version was a single class with storeTicket and retrieveTicket methods. retrieveTicket opened with:

public function retrieveTicket($ticket, $path, $unlink = true) {
    if (!preg_match('/^(ST|PT|PGT)-?[a-zA-Z0-9]+$/D', $ticket))
        throw new Exception('Invalid characters in ticket');
    ...
}

The CAS spec says ticket IDs are alphanumeric with a ST-, PT-, or PGT- prefix. The regex enforced that. Path separators were not in the allowed character class. Two-dot sequences were not. Null bytes were not. The check was there.

A few days later, in commit a806540 titled moved logic into the ticket store super class, Bjørn extracted the regex into a helper. A commit a week after that, 98b1d1b, moved generate and validate ticket id methods to abstract super class as default implementations, moved the helper to the abstract TicketStore parent class as a default implementation, and wrapped the public methods in it:

abstract class TicketStore
{
    public function getTicket($ticket)
    {
        if ($this->validateTicketId($ticket)) {
            return $this->retrieveTicket($ticket);
        } else {
            return null;
        }
    }

    public function removeTicket($ticket)
    {
        if ($this->validateTicketId($ticket)) {
            $this->deleteTicket($ticket);
        }
    }

    protected function validateTicketId($ticket)
    {
        return preg_match('/^(ST|PT|PGT)-?[a-zA-Z0-9]+$/D', $ticket);
    }

    abstract protected function retrieveTicket($ticket);
    abstract protected function deleteTicket($ticket);
    // ...
}

This is the template method pattern. The parent class owns the public entrypoint. The public entrypoint runs the safety check, then dispatches to a protected primitive the subclass implements. The subclass's primitive does no validation, because the contract is that callers go through the parent's wrapper. FileSystemTicketStore::retrieveTicket was protected. $this->pathToTicketDirectory . '/' . $ticket was unsafe on its own. The parent class made it safe by guaranteeing nothing reached it without passing the regex first. The parent class was the gate.

The 2013 refactor removed the wrapper

On February 22, 2013, commit 564b9ac, titled removed ticket creation from ticket store, inverted the architecture. The commit moved ticket-creation responsibilities out of the store class and into a separate TicketFactory. In doing so, it collapsed the template method:

 abstract class sspmod_sbcasserver_Cas_Ticket_TicketStore
 {
-    public function getTicket($ticket) {
-        if ($this->validateTicketId($ticket)) {
-            return $this->retrieveTicket($ticket);
-        } else {
-            return null;
-        }
-    }
-    public function removeTicket($ticket) {
-        if ($this->validateTicketId($ticket)) {
-            $this->deleteTicket($ticket);
-        }
-    }
-    protected function validateTicketId($ticket) {
-        return preg_match('/^(ST|PT|PGT)-?[a-zA-Z0-9]+$/D', $ticket);
-    }
-    abstract protected function retrieveTicket($ticket);
-    abstract protected function storeTicket($ticket, $content);
-    abstract protected function deleteTicket($ticket);
+    abstract public function getTicket($ticketIdIdIdId);
+    abstract public function addTicket($ticket);
+    abstract public function removeTicket($ticketIdId);
 }

$ticketIdIdIdId. That is not a typo we introduced. The file shipped that day with the variable name literally written with three Ids stuttered onto the end of the parameter, and removeTicket($ticketIdId) with two. The refactor was fast. Names are honest.

The subclasses inverted in the same commit. FileSystemTicketStore::retrieveTicket, previously protected and called only after validateTicketId had passed, was renamed getTicket and made public. The validation step was not relocated, it was deleted. The wrapping public method that ran the check was gone. The protected primitive that did the file operations was now the public method. From this commit forward, the public entrypoint to the file store concatenated an attacker-controllable string onto a filesystem path, opened it, and unserialized it.

The commit body describes a structural change. The commit title describes ticket creation moving out. Neither names the security property the parent class had carried. The validation rode along with the architectural collapse, and was never put back. The casserver module shipped the unguarded primitive on every release for the next thirteen years.

Three sibling stores were safe by coincidence

The same refactor flattened MemCacheTicketStore, SQLTicketStore, and the later-added RedisTicketStore in the same way. All four subclasses received the same architectural treatment. None of them got their own path validator.

The other three were safe anyway. MemCacheTicketStore::getTicket does this:

public function getTicket(string $ticketId): ?array
{
    $scopedTicketId = $this->scopeTicketId($ticketId);
    // ... fetches from memcache
}

private function scopeTicketId(string $ticketId): string
{
    return $this->prefix . '.' . $ticketId;
}

The scoped ID is a memcache key. .. and / in a memcache key are weird key strings, not file paths. RedisTicketStore does the same with a Redis key. SQLTicketStore binds the scoped ID as a query parameter; PDO escapes it.

The parent class's check had been defense in depth for backends that did not need it. For the one backend that did, it was load-bearing. The pluggable storage layer was supposed to let an operator choose between Memcache and Redis and SQL and the filesystem with interchangeable safety properties. The architecture made all four interchangeable in shape. The path traversal class was always specific to the filesystem. The validation gate that protected the filesystem was deleted because flattening the abstraction reads as cleanup. The three coincidentally-safe stores carried the cleanup forward. The one unsafe store stayed unsafe.

The patch puts the gate inside the file store

Commit b84f3e4, May 15, 2026, restores the check. Not by reviving the parent class's template method; the architecture stays flat. The new check lives inside FileSystemTicketStore, where the unsafe primitive lives. Each of the public methods that used to concatenate $ticketId now calls a private validateTicketPath:

private function validateTicketPath(string $ticketId): string
{
    if ($ticketId === '') {
        throw new Exception('Invalid ticketId provided.');
    }

    // Prevent directory traversal and path separators.
    // CAS tickets are typically like: ST-..., PT-..., PGT-..., etc. Hyphens are ok.
    if (
        str_contains($ticketId, '/')
        || str_contains($ticketId, '\\')
        || str_contains($ticketId, '..')
    ) {
        throw new Exception('Invalid ticketId provided.');
    }

    $baseDir = realpath($this->pathToTicketDirectory);
    if ($baseDir === false) {
        throw new Exception('Ticket storage directory is not accessible.');
    }

    // Store tickets as hashed filenames inside the ticket directory.
    return $baseDir . DIRECTORY_SEPARATOR . sha1($ticketId);
}

The patch also hardens the unserialize call:

-            return unserialize($content);
+            $result = unserialize($content, ['allowed_classes' => false]);
+            Assert::isArray($result, "Failed to unserialize ticket.");
+            return $result;

allowed_classes => false blocks PHP object injection. A serialized object becomes an __PHP_Incomplete_Class instance with no __wakeup execution. Until this commit shipped, every casserver running with the default ticket store had not just a file-read and conditional-delete primitive but a PHP object injection sink that fired on any file the read primitive could nudge content into. The patch lays in two fences at once. The bug existed for thirteen years with neither.

The commit title named the cargo

This is the part nobody is going to say. The original author wrote the check, then wrote the refactor that removed it. The check existed in retrieveTicket for two days, in a helper for one day, in the abstract parent class for a few weeks, and then disappeared in a commit titled removed ticket creation from ticket store.

A commit title is testimony. It records what the author intends a reviewer to look for. The reviewer of removed ticket creation from ticket store reads it as a refactor scope: did this commit move ticket creation out, yes, ship. The reviewer does not look for a security check the parent class used to carry, because the title does not mention one. The same is true of every static-analysis pass and every audit conducted on the casserver module between 2013 and 2026. The check had been in the parent class. The parent class no longer had a body. There was nothing in the file store's own code to grep for. This is parent-class-was-the-gate as a named class of mistake: the wrapping public method that ran the check is deleted in a refactor, the protected primitive is promoted to the public method, the safety property is lost in the architectural flattening, and the only artifact that ever named the safety property was a commit title that talked about something else.

And it is trust inversion as the meta-story. The CAS server is the federation's authorizer. The validation endpoint is the surface the federation deliberately exposes to every consumer, because the consumer's question is the only one a CAS server is supposed to answer. CVE-2026-46491 turns that exposed surface into a file read and conditional file delete primitive on the identity host. SimpleSAMLphp shipped the unguarded primitive on its public CAS validation endpoint to every identity federation deployment that picked the file-backed ticket store from 2013 to 2026. The reporter who finally noticed, kamil-sawicki, filed the bug in May 2026. The patch lands the check thirteen years late.

PoC: GHSA-jrrg-99xh-5j2q

A CAS server's job is to validate tickets. SimpleSAMLphp casserver's validation endpoint reads and deletes files.