Skip to content

Commit bd825eb

Browse files
author
Stanislav Idolov
authored
ENGCOM-2656: [Backport] Use constant time string comparison in FormKey validator #17108
2 parents 5a07347 + cce5feb commit bd825eb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/internal/Magento/Framework/Data/Form/FormKey/Validator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Magento\Framework\Data\Form\FormKey;
77

8+
use Magento\Framework\Encryption\Helper\Security;
9+
810
class Validator
911
{
1012
/**
@@ -29,9 +31,7 @@ public function __construct(\Magento\Framework\Data\Form\FormKey $formKey)
2931
public function validate(\Magento\Framework\App\RequestInterface $request)
3032
{
3133
$formKey = $request->getParam('form_key', null);
32-
if (!$formKey || $formKey !== $this->_formKey->getFormKey()) {
33-
return false;
34-
}
35-
return true;
34+
35+
return $formKey && Security::compareStrings($formKey, $this->_formKey->getFormKey());
3636
}
3737
}

0 commit comments

Comments
 (0)