[Server] Restrict FileSessionStore::gc() to owned session files (#479)

This commit is contained in:
Christopher Hertel 2026-08-25 00:43:08 +02:00 • committed by GitHub
commit c36e805086
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -128,6 +128,11 @@ class FileSessionStore implements SessionStoreInterface
continue;
}
// Only delete files this store owns: sessions are named by their RFC 4122 UUID
if (!Uuid::isValid($entry)) {
continue;
}
$path = $this->directory.\DIRECTORY_SEPARATOR.$entry;
if (!is_file($path)) {
continue;
@ -136,11 +141,7 @@ class FileSessionStore implements SessionStoreInterface
$mtime = @filemtime($path) ?: 0;
if (($now - $mtime) > $this->ttl) {
@unlink($path);
try {
$deleted[] = Uuid::fromString($entry);
} catch (\Throwable) {
// ignore non-UUID file names
}
$deleted[] = Uuid::fromString($entry);
}
}