CVE-2024-51744 Bad documentation of error handling in ParseWithClaims can lead to potentially dangerous situations in golang-jwt

Low 3.1 Published Updated

Developers using golang-jwt may accept invalid tokens if they only check for expiration errors, bypassing signature validation.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
A user has to click or open something
Fix
Available

What is CVE-2024-51744?

CVE-2024-51744 is a low-severity authentication bypass vulnerability in golang-jwt jwt, published on 4 Nov 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

Official description

golang-jwt is a Go implementation of JSON Web Tokens. Unclear documentation of the error behavior in `ParseWithClaims` can lead to situation where users are potentially not checking errors in the way they should be. Especially, if a token is both expired and invalid, the errors returned by `ParseWithClaims` return both error codes. If users only check for the `jwt.ErrTokenExpired ` using `error.Is`, they will ignore the embedded `jwt.ErrTokenSignatureInvalid` and thus potentially accept invalid tokens. A fix has been back-ported with the error handling logic from the `v5` branch to the `v4` branch. In this logic, the `ParseWithClaims` function will immediately return in "dangerous" situations (e.g., an invalid signature), limiting the combined errors only to situations where the signature is valid, but further validation failed (e.g., if the signature is valid, but is expired AND has the wrong audience). This fix is part of the 4.5.1 release. We are aware that this changes the behaviour of an established function and is not 100 % backwards compatible, so updating to 4.5.1 might break your code. In case you cannot update to 4.5.0, please make sure that you are properly checking for all errors ("dangerous" ones first), so that you are not running in the case detailed above.

Weakness: CWE-755

Which versions are affected by CVE-2024-51744?

3 open source packages ship an affected version, including github.com/golang-jwt/jwt/v4.

PackageAffectedFixed in
github.com/golang-jwt/jwt/v4 GoAll versions4.5.1
github.com/golang-jwt/jwt/v4 GoAll versions4.5.1
github.com/golang-jwt/jwt/v4 GoAll versions4.5.1
Linux distribution packages (11)
golang-github-prometheus-prometheus SUSE:Linux Enterprise Module for Package Hub 15 SP6All versions2.53.3-150100.4.23.1
golang-github-prometheus-prometheus SUSE:Manager Proxy Module 4.3All versions2.53.3-150100.4.23.1
coredns SUSE:Package Hub 15 SP6All versions1.12.1-bp156.4.6.5
coredns openSUSE:Leap 15.6All versions1.12.1-bp156.4.6.5
golang-github-prometheus-prometheus openSUSE:Leap 15.6All versions2.53.3-150100.4.23.1
coredns openSUSE:TumbleweedAll versions1.11.3+git129.387f34d-1.1
govulncheck-vulndb openSUSE:TumbleweedAll versions0.0.20241112T145010-1.1
grafana openSUSE:TumbleweedAll versions11.5.1-1.1
rclone openSUSE:TumbleweedAll versions1.68.1-2.1
traefik openSUSE:TumbleweedAll versions3.2.1-1.1
traefik2 openSUSE:TumbleweedAll versions2.11.14-1.1

How do I fix CVE-2024-51744?

Upgrade github.com/golang-jwt/jwt/v4 to 4.5.1 or later.

Upgrade, and rotate credentials and sessions that may have been exposed. More about Authentication bypass.

Is CVE-2024-51744 being exploited?

There is no known exploitation of CVE-2024-51744 in the wild and no public exploit code.

Sources

Also known as AZL-52171, AZL-52174, AZL-52180, AZL-52183, AZL-52186, AZL-52189 and 62 more.

Is CVE-2024-51744 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free