CVE-2024-51744: Github.com/golang jwt/jwt/v4 Bad Documentation Of Error Handling Vulnerability
LOWCVE-2024-51744 is a LOW (CVSS 3.1) bad documentation of error handling vulnerability (CWE-755: Improper Handling of Exceptional Conditions) affecting Github.com/golang jwt/jwt/v4 libraries in the Go ecosystem. The issue involves bad documentation of error handling in parsewithclaims can lead to potentially dangerous situations. Remediation is available by upgrading affected packages to version 4.5.1.
CVE-2024-51744 at a Glance
Security Impact
CVSS: 3.1
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N).
How to Fix CVE-2024-51744
To remediate this vulnerability, upgrade all affected Github.com/golang jwt/jwt/v4 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade github.com/golang-jwt/jwt/v4 to 4.5.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for github.com/golang-jwt/jwt/v4
How to Check if You Are Affected
To determine whether your application is affected by CVE-2024-51744, inspect your project dependencies for Github.com/golang jwt/jwt/v4:
inspect dependencies for github.com/golang-jwt/jwt/v4
Analyze the terminal output to locate any version of Github.com/golang jwt/jwt/v4 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.5.1), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-755: Improper Handling of Exceptional Conditions, where the product does not handle or incorrectly handles an exceptional condition. In Github.com/golang jwt/jwt/v4, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2024-51744 Affected Github.com/golang jwt/jwt/v4 Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
github.com/golang-jwt/jwt/v4
|
Go |
< 4.5.1
|
4.5.1
|
References
Frequently Asked Questions
What is CVE-2024-51744?
Which Github.com/golang jwt/jwt/v4 versions are affected?
What version fixes CVE-2024-51744?
Is github.com/golang-jwt/jwt/v4 affected?
What is the CVSS score of CVE-2024-51744?
What CWE is associated with CVE-2024-51744?
How can I check Go dependencies for CVE-2024-51744?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-29wx-vh33-7x7r",
"modified" : "2024-11-12T21:32:34Z",
"published" : "2024-11-04T23:22:41Z",
"aliases" : [ "CVE-2024-51744" ],
"summary" : "Bad documentation of error handling in ParseWithClaims can lead to potentially dangerous situations",
"details" : "### Summary\n\nUnclear 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.\n\n### Fix\n\nWe have back-ported 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.\n\n### Workaround \n\nWe 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.\n\n```Go\ntoken, err := /* jwt.Parse or similar */\nif token.Valid {\n\tfmt.Println(\"You look nice today\")\n} else if errors.Is(err, jwt.ErrTokenMalformed) {\n\tfmt.Println(\"That's not even a token\")\n} else if errors.Is(err, jwt.ErrTokenUnverifiable) {\n\tfmt.Println(\"We could not verify this token\")\n} else if errors.Is(err, jwt.ErrTokenSignatureInvalid) {\n\tfmt.Println(\"This token has an invalid signature\")\n} else if errors.Is(err, jwt.ErrTokenExpired) || errors.Is(err, jwt.ErrTokenNotValidYet) {\n\t// Token is either expired or not active yet\n\tfmt.Println(\"Timing is everything\")\n} else {\n\tfmt.Println(\"Couldn't handle this token:\", err)\n}\n```",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Go",
"name" : "github.com/golang-jwt/jwt/v4"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "4.5.1"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/golang-jwt/jwt/security/advisories/GHSA-29wx-vh33-7x7r"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-51744"
}, {
"type" : "WEB",
"url" : "https://github.com/golang-jwt/jwt/commit/7b1c1c00a171c6c79bbdb40e4ce7d197060c1c2c"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/golang-jwt/jwt"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-347", "CWE-755" ],
"severity" : "LOW",
"github_reviewed" : true,
"github_reviewed_at" : "2024-11-04T23:22:41Z",
"nvd_published_at" : "2024-11-04T22:15:03Z"
}
}