CVE-2024-42476
Description
In the OAuth library for nim prior to version 0.11, the Authorization Code grant and Implicit grant both rely on the state parameter to prevent cross-site request forgery (CSRF) attacks where a resource owner might have their session associated with protected resources belonging to an attacker. When this project is compiled with certain compiler flags set, it is possible that the state parameter will not be checked at all, creating a CSRF vulnerability. Version 0.11 checks the state parameter using a regular if statement or doAssert instead of relying on a plain assert. doAssert will achieve the desired behavior even if -d:danger or --assertions:off is set.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Nim OAuth library prior to 0.11 uses assert for state parameter validation, which is omitted in release builds with -d:danger or --assertions:off, causing CSRF vulnerability.
Vulnerability
Overview
In the OAuth library for Nim prior to version 0.11, the Authorization Code grant and Implicit grant both rely on the state parameter to prevent cross-site request forgery (CSRF) attacks. However, the library checks this parameter using a plain assert statement (see [1], [2]). According to Nim's documentation, assertions are disabled when compiling with -d:danger or --assertions:off, which are typical for release builds. Consequently, no code is generated for the assert statement, meaning the state parameter is never validated ([3]).
Exploitation
An attacker can exploit this vulnerability by crafting a CSRF attack that does not require a valid state parameter. Since the state check is entirely omitted in release builds, the resource owner's session can be associated with protected resources belonging to the attacker. This attack is particularly effective in a cross-origin context, where the attacker tricks the victim into completing an OAuth flow without proper state validation.
Impact
Successful exploitation allows an attacker to perform actions on behalf of the victim without their consent, potentially compromising the victim's account or sensitive data. The vulnerability has a CVSS score of 6.5 (Medium), indicating a significant risk in scenarios where release builds are deployed.
Mitigation
The issue is fixed in version 0.11 of the library. The maintainers replaced the assert with a regular if statement or doAssert, which are not affected by compiler flags that disable assertions ([3]). Users should update to version 0.11 or later to eliminate the CSRF vulnerability.
- oauth/src/oauth2.nim at b8c163b0d9cfad6d29ce8c1fb394e5f47182ee1c · CORDEA/oauth
- oauth/src/oauth2.nim at b8c163b0d9cfad6d29ce8c1fb394e5f47182ee1c · CORDEA/oauth
- state parameter for authz code and implicit grants is checked using assert. This will be omitted in -d:danger and --assertions:off builds leading to a CSRF vulnerability
AI Insight generated on May 20, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected products
1Patches
1ec2e058fc46fVulnerability mechanics
Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
3News mentions
0No linked articles in our index yet.