jwt-go allows excessive memory allocation during header parsing
golang-jwt jwt
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| github.com/golang-jwt/jwt/v5 Go |
|
|
| github.com/golang-jwt/jwt/v4 Go |
|
|
| github.com/golang-jwt/jwt Go |
golang-jwt jwt
| Product | Affected | Fixed in |
|---|---|---|
| github.com/golang-jwt/jwt/v5 Go |
|
|
| github.com/golang-jwt/jwt/v4 Go |
|
|
| github.com/golang-jwt/jwt Go |
|
| No fix yet |
golang-jwt is a Go implementation of JSON Web Tokens. Starting in version 3.2.0 and prior to versions 5.2.2 and 4.5.2, the function parse.ParseUnverified splits (via a call to strings.Split) its argument (which is untrusted data) on periods. As a result, in the face of a malicious request whose Authorization header consists of Bearer followed by many period characters, a call to that function incurs allocations to the tune of O(n) bytes (where n stands for the length of the function's argument), with a constant factor of about 16. This issue is fixed in 5.2.2 and 4.5.2.
From the CVE record · GitHub_M
golang-jwt’s parse.ParseUnverified allocates excessive memory when splitting an untrusted token containing many periods. An attacker can trigger this behavior by sending a malicious Bearer token in an Authorization header if the application passes it to that function; the input does not specify whether authentication is required.
Check applications using Go packages github.com/golang-jwt/jwt/v5 from 5.0.0-rc.1 up to but not including 5.2.2, github.com/golang-jwt/jwt/v4 before 4.5.2, or github.com/golang-jwt/jwt versions 3.2.0 through 3.2.2.