File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,16 @@ public static function decode(
127127 if (!$ payload instanceof stdClass) {
128128 throw new UnexpectedValueException ('Payload must be a JSON object ' );
129129 }
130+ if (isset ($ payload ->iat ) && !\is_numeric ($ payload ->iat )) {
131+ throw new UnexpectedValueException ('Payload iat must be a number ' );
132+ }
133+ if (isset ($ payload ->nbf ) && !\is_numeric ($ payload ->nbf )) {
134+ throw new UnexpectedValueException ('Payload nbf must be a number ' );
135+ }
136+ if (isset ($ payload ->exp ) && !\is_numeric ($ payload ->exp )) {
137+ throw new UnexpectedValueException ('Payload exp must be a number ' );
138+ }
139+
130140 $ sig = static ::urlsafeB64Decode ($ cryptob64 );
131141 if (empty ($ header ->alg )) {
132142 throw new UnexpectedValueException ('Empty algorithm ' );
@@ -172,7 +182,7 @@ public static function decode(
172182 }
173183
174184 // Check if this token has expired.
175- if (isset ($ payload ->exp ) && ($ timestamp - static ::$ leeway ) >= $ payload ->exp ) {
185+ if (isset ($ payload ->exp ) && floor ( $ payload -> exp ) && ($ timestamp - static ::$ leeway ) >= $ payload ->exp ) {
176186 $ ex = new ExpiredException ('Expired token ' );
177187 $ ex ->setPayload ($ payload );
178188 throw $ ex ;
You can’t perform that action at this time.
0 commit comments