Skip to content

Commit 8b12445

Browse files
committed
Detect invalid Base64 encoding in signature
1 parent dccf163 commit 8b12445

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/JWT.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ public static function decode($jwt, $key, $allowed_algs = array())
8585
if (null === $payload = static::jsonDecode(static::urlsafeB64Decode($bodyb64))) {
8686
throw new UnexpectedValueException('Invalid claims encoding');
8787
}
88-
$sig = static::urlsafeB64Decode($cryptob64);
89-
88+
if (false === ($sig = static::urlsafeB64Decode($cryptob64))) {
89+
throw new UnexpectedValueException('Invalid signature encoding');
90+
}
91+
9092
if (empty($header->alg)) {
9193
throw new UnexpectedValueException('Empty algorithm');
9294
}

0 commit comments

Comments
 (0)