Skip to content

Commit 07fc5e4

Browse files
committed
Fix MDQ expiration and possible object injection
1 parent a478ca0 commit 07fc5e4

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

  • src/SimpleSAML/Metadata/Sources

src/SimpleSAML/Metadata/Sources/MDQ.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
use function array_key_exists;
1919
use function error_get_last;
2020
use function is_array;
21-
use function serialize;
21+
use function json_decode;
22+
use function json_encode;
2223
use function sha1;
2324
use function sprintf;
2425
use function strval;
2526
use function time;
26-
use function unserialize;
2727
use function urlencode;
2828

2929
/**
@@ -188,7 +188,7 @@ private function getFromCache(string $set, string $entityId): ?array
188188
));
189189
}
190190

191-
$data = unserialize($rawData);
191+
$data = json_decode($rawData);
192192
if ($data === false) {
193193
throw new Exception(
194194
sprintf('%s: error unserializing cached data from file "%s".', __CLASS__, strval($file))
@@ -223,7 +223,7 @@ private function writeToCache(string $set, string $entityId, array $data): void
223223
Logger::debug(sprintf('%s: Writing cache [%s] => [%s]', __CLASS__, $entityId, $cacheFileName));
224224

225225
/** @psalm-suppress TooManyArguments */
226-
$this->fileSystem->appendToFile($cacheFileName, serialize($data), true);
226+
$this->fileSystem->appendToFile($cacheFileName, json_encode($data), true);
227227
}
228228

229229

@@ -285,7 +285,7 @@ public function getMetaData(string $entityId, string $set): ?array
285285
}
286286

287287
if (isset($data)) {
288-
if (array_key_exists('expires', $data) && $data['expires'] < time()) {
288+
if (array_key_exists('expire', $data) && $data['expire'] < time()) {
289289
// metadata has expired
290290
$data = null;
291291
} else {

0 commit comments

Comments
 (0)