Skip to content

Commit 5316560

Browse files
ENGCOM-2183: Use constant time string comparison in FormKey validator #16518
- Merge Pull Request #16518 from gelanivishal/magento2:2.3-develop-PR-port-13509 - Merged commits: 1. 6e1beda 2. 11a95d6
2 parents d8a95c9 + 11a95d6 commit 5316560

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
/**
911
* @api
1012
*/
@@ -32,9 +34,7 @@ public function __construct(\Magento\Framework\Data\Form\FormKey $formKey)
3234
public function validate(\Magento\Framework\App\RequestInterface $request)
3335
{
3436
$formKey = $request->getParam('form_key', null);
35-
if (!$formKey || $formKey !== $this->_formKey->getFormKey()) {
36-
return false;
37-
}
38-
return true;
37+
38+
return $formKey && Security::compareStrings($formKey, $this->_formKey->getFormKey());
3939
}
4040
}

0 commit comments

Comments
 (0)