HIGH integer overflowjwt tokens

Integer Overflow with Jwt Tokens

How Integer Overflow Manifests in JWT Tokens

Integer overflow in JWT tokens occurs when numeric claims exceed the maximum value representable by their data type. JWTs use 64-bit integers for certain claims like exp (expiration time) and iat (issued at time), but many JWT libraries and implementations use 32-bit integers internally for timestamp calculations.

The most common overflow scenario involves the exp claim. JWT expiration times are represented as Unix timestamps (seconds since epoch). The maximum 32-bit signed integer is 2,147,483,647, which corresponds to January 19, 2038 at 03:14:07 UTC. Any expiration time beyond this value will overflow in 32-bit systems, potentially wrapping to a negative number or an earlier date.

 

JWT Tokens-Specific Detection

Detecting integer overflow in JWT tokens requires examining both the token structure and the verification implementation. Start by decoding the token and checking numeric claims against safe ranges:

 

Frequently Asked Questions

How can I test if my JWT implementation is vulnerable to integer overflow?
Create JWT tokens with expiration times set to values above 2,147,483,647 (2038-01-19 03:14:07 UTC) and test if your system accepts them. Use middleBrick's black-box scanning to automatically test your JWT endpoints with crafted overflow payloads, or manually decode tokens and check if numeric claims exceed 32-bit signed integer ranges.
Which JWT claims are most susceptible to integer overflow attacks?
The exp (expiration), iat (issued at), and nbf (not before) claims are most vulnerable since they use Unix timestamps. Claims that use integers for permissions, quotas, or sequence numbers can also be exploited. Any numeric claim that might be processed by 32-bit systems is at risk.