Skip to content

Commit 52a7948

Browse files
Merge commit from fork
Fix: Strict validation of session cookie tag
2 parents 8ae123b + 5fbf6db commit 52a7948

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Store/CookieStore.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use function is_array;
1414
use function is_int;
1515
use function is_string;
16+
use function strlen;
1617

1718
/**
1819
* This class provides a layer to persist transient auth data using cookies.
@@ -39,6 +40,11 @@ final class CookieStore implements StoreInterface
3940
*/
4041
public const VAL_CRYPTO_ALGO = 'aes-128-gcm';
4142

43+
/**
44+
* @var int
45+
*/
46+
public const VAL_CRYPTO_TAG_LENGTH_BYTES = 16;
47+
4248
/**
4349
* When true, CookieStore will not setState() itself. You will need manually call the method to persist state to storage.
4450
*/
@@ -123,7 +129,7 @@ public function decrypt(
123129
$iv = base64_decode($data['iv'], true);
124130
$tag = base64_decode($data['tag'], true);
125131

126-
if (! is_string($iv) || ! is_string($tag)) {
132+
if (! is_string($iv) || ! is_string($tag) || self::VAL_CRYPTO_TAG_LENGTH_BYTES !== strlen($tag)) {
127133
return null;
128134
}
129135

0 commit comments

Comments
 (0)