mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-09-24 10:27:52 +02:00
Self service: fix timing attack
Compare icinga_host.api_key ("known_string") via hash_equals().
This commit is contained in:
parent
5ce23b2cbf
commit
301455f5ed
@ -585,13 +585,15 @@ class IcingaHost extends IcingaObject implements ExportInterface
|
||||
$query = $db->getDbAdapter()
|
||||
->select()
|
||||
->from('icinga_host')
|
||||
->where('api_key = ?', $key);
|
||||
->where('api_key IS NOT NULL')
|
||||
->query();
|
||||
|
||||
$result = self::loadAll($db, $query);
|
||||
if (count($result) !== 1) {
|
||||
throw new NotFoundError('Got invalid API key "%s"', $key);
|
||||
foreach ($query as $row) {
|
||||
if (hash_equals($row->api_key, $key)) {
|
||||
return (new static())->setConnection($db)->setDbProperties($row);
|
||||
}
|
||||
}
|
||||
|
||||
return current($result);
|
||||
throw new NotFoundError('Got invalid API key "%s"', $key);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user