CVE-2024-42475 Overview
CVE-2024-42475 affects the OAuth library for Nim (CORDEA/oauth) prior to version 0.11. The generateState function produces state values without sufficient entropy and does not use a cryptographically secure pseudorandom number generator (CSPRNG). An attacker can guess the state parameter and perform a Cross-Site Request Forgery (CSRF) attack against the OAuth authorization flow. A successful attack associates the victim's session with the attacker's protected resources. The weakness is classified under [CWE-330: Use of Insufficiently Random Values].
Critical Impact
Attackers can guess OAuth state values to bind a victim's session to attacker-controlled resources through CSRF against the OAuth callback endpoint.
Affected Products
- CORDEA oauth library for Nim, all versions prior to 0.11
- Applications built on the vulnerable Nim OAuth client
- OAuth 2.0 authorization code flows relying on the library's default generateState
Discovery Timeline
- 2024-08-15 - CVE-2024-42475 published to NVD
- 2026-06-17 - Last updated in NVD database
Technical Details for CVE-2024-42475
Vulnerability Analysis
The OAuth 2.0 state parameter binds an authorization request to the client session that initiated it. When the authorization server redirects back to the client, the client verifies that the returned state matches the value it originally issued. This check defends the callback endpoint against CSRF attacks that would otherwise let an attacker inject their own authorization code into a victim's session.
In the CORDEA Nim oauth library prior to 0.11, the generateState function relies on a non-cryptographic random source and emits values with limited entropy. An attacker who can predict or brute force these values can craft an authorization request, obtain a valid callback URL, and trick a victim into completing the flow. The result is session fixation against the OAuth linkage: the victim's browser session becomes linked to the attacker's account at the identity provider or resource server.
Version 0.11 reimplements generateState to draw at least 128 bits of entropy from a CSPRNG, eliminating the guessability of issued values.
Root Cause
The root cause is the use of an insufficiently random source to generate a security-sensitive token. generateState did not draw from a CSPRNG and produced values whose search space was small enough to guess. Security controls that rely on unpredictability, including the OAuth state parameter, must be generated with cryptographic randomness even when they are not themselves cryptographic keys.
Attack Vector
Exploitation is network-based and requires user interaction. The attacker initiates their own OAuth flow, predicts or captures a state value the vulnerable client will accept, and delivers a crafted callback link to the victim. When the victim's browser follows the link while authenticated to the client, the client accepts the response and binds the attacker's authorization grant to the victim's session. See the GitHub Security Advisory GHSA-332c-q46h-fg8f and the vulnerable oauth2.nim code for the pre-patch implementation.
Detection Methods for CVE-2024-42475
Indicators of Compromise
- OAuth callback requests where the returned state value repeats across unrelated sessions or falls within a narrow numeric range.
- Multiple failed or successful callbacks arriving at the same client from disparate IP addresses within short time windows.
- Unexpected linking of external identity provider accounts to end-user sessions without a matching, user-initiated authorization request.
Detection Strategies
- Inventory Nim applications and dependency manifests (.nimble files) for the CORDEA oauth package and flag any version below 0.11.
- Instrument the OAuth callback handler to log the entropy and format of accepted state values and alert on low-entropy patterns.
- Correlate authorization request and callback events by session ID to identify callbacks that arrive without a corresponding outbound request.
Monitoring Recommendations
- Forward web server and application logs covering OAuth authorization and callback endpoints to a centralized analytics platform.
- Monitor identity provider audit logs for account link or grant events that do not align with user-initiated activity on the client.
- Track dependency updates in CI to detect regressions to pre-0.11 versions of the library.
How to Mitigate CVE-2024-42475
Immediate Actions Required
- Upgrade the CORDEA Nim oauth library to version 0.11 or later in all affected applications.
- Rebuild and redeploy dependent services and invalidate any active OAuth sessions issued by vulnerable builds.
- Review recent OAuth account linkages and revoke grants that cannot be attributed to a legitimate user action.
Patch Information
Version 0.11 of the CORDEA oauth library replaces generateState with an implementation that produces at least 128 bits of entropy using a CSPRNG. Details are available in the GitHub Security Advisory GHSA-332c-q46h-fg8f.
Workarounds
- Override or wrap generateState in application code to source state values from a CSPRNG such as sysrand with at least 128 bits of entropy.
- Add server-side validation that binds each authorization request to the initiating session and rejects callbacks whose state was not issued for that session.
- Enforce short expiration windows on issued state values to reduce the window for guessing or replay.
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
