Skip to content

Commit 502a74d

Browse files
committed
Compare the API key with a timing safe function
1 parent f2109fa commit 502a74d

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

api/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
if (isset($_GET['apikey'])) {
1515
$matchkey = 0;
1616
foreach($cfg['stats_api_keys'] as $apikey => $desc) {
17-
if ($apikey == $_GET['apikey']) $matchkey = 1;
17+
if (hash_equals($apikey, $_GET['apikey'])) $matchkey = 1;
1818
}
1919
if ($matchkey == 0) {
2020
$json = array(
@@ -494,4 +494,4 @@
494494
}
495495

496496
echo json_encode($json);
497-
?>
497+
?>

0 commit comments

Comments
 (0)