5.9medium
@node-oauth/oauth2-server: PKCE code_verifier ABNF not enforced in token exchange allows brute-force redemption of intercepted authorization codes
- Severity
- 5.9medium CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.27% (higher than 20% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-jhm7-29pj-4xvf
Description
@node-oauth/oauth2-server is a module for implementing an OAuth2 server in Node.js. The token exchange path accepts RFC7636-invalid code_verifier values (including one-character strings) for S256 PKCE flows. Because short/weak verifiers are accepted and failed verifier attempts do not consume the authorization code, an attacker who intercepts an authorization code can brute-force code_verifier guesses online until token issuance succeeds.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| node-oauth node-oauth2-server | < 5.3.0 | CVE List |
| @node-oauth/oauth2-server (npm) | before 5.3.0 | GitHub Advisory Database |
| node-oauth node-oauth/oauth2-server | before 5.3.0 | NVD |
All scores
| GitHub_M | 5.9medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N |
| GitHub | 5.9medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N |
Classification
What each source says
CVE List
@node-oauth/oauth2-server is a module for implementing an OAuth2 server in Node.js. The token exchange path accepts RFC7636-invalid code_verifier values (including one-character strings) for S256 PKCE flows. Because short/weak verifiers are accepted and failed verifier attempts do not consume the authorization code, an attacker who intercepts an authorization code can brute-force code_verifier guesses online until token issuance succeeds.
GitHub Advisory Database
Summary
The token exchange path accepts RFC7636-invalid code_verifier values (including one-character strings) for S256 PKCE flows.
Because short/weak verifiers are accepted and failed verifier attempts do not consume the authorization code, an attacker who intercepts an authorization code can brute-force code_verifier guesses online until token issuance succeeds.
Root cause
lib/pkce/pkce.js(getHashForCodeChallenge) only checks thatverifieris a non-empty string before hashing forS256; it does not enforce RFC7636 ABNF (43..128unreserved chars).lib/grant-types/authorization-code-grant-type.jscompareshash(code_verifier)to storedcodeChallengewithout validating verifier format/length.- In
AuthorizationCodeGrantType.handle, authorization code revocation happens after verifier validation. Invalid guesses fail before revoke, so the same code can be retried repeatedly.
Steps to Reproduce
Setup
- PKCE authorization code exists with:
codeChallengeMethod = "S256"codeChallenge = BASE64URL(SHA256("z"))(verifier is one character, RFC-invalid)
- Attacker has intercepted the authorization code value.
Reproduction
- Send repeated token requests with guessed
code_verifiervalues:
POST /token HTTP/1.1
Host: oauth.example
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code&
client_id=client1&
client_secret=s3cret&
code=stolen-auth-code&
redirect_uri=https://client.example/callback&
code_verifier=<guess>
- Observe invalid guesses return
invalid_grant. - Continue guessing (
a..z). - When
code_verifier=z, token issuance succeeds and returns bearer tokens.
Confirmed PoC output
BRUTE_FORCE_SUCCESS { tries: 26, guess: 'z', status: 200, tokenIssued: true }
Impact
An intercepted authorization code can be redeemed by brute-forcing low-entropy verifiers that the server should have rejected under RFC7636.
This weakens PKCE’s protection goal and allows token theft when clients generate short/predictable verifiers.
Recommended Fix
- Enforce
pkce.codeChallengeMatchesABNF(request.body.code_verifier)in authorization code token exchange before hashing/comparison. - Reject verifier values outside RFC7636 charset/length (
43..128unreserved). - Invalidate authorization codes on failed verifier attempts (or add strict retry limits) to prevent online guessing.
NVD (es)
@node-oauth/oauth2-server es un módulo para implementar un servidor OAuth2 en Node.js. La ruta de intercambio de tokens acepta valores de code_verifier inválidos según RFC7636 (incluyendo cadenas de un solo carácter) para flujos PKCE S256. Debido a que se aceptan verificadores cortos/débiles y los intentos fallidos de verificador no consumen el código de autorización, un atacante que intercepta un código de autorización puede forzar por fuerza bruta suposiciones de code_verifier en línea hasta que la emisión del token tenga éxito.
References
| https://github.com/node-oauth/node-oauth2-server/security/advisories/GHSA-jhm7-29pj-4xvf | exploit, mitigation, vendor-advisory, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2026-41213 | advisory | |
| https://github.com/node-oauth/node-oauth2-server | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-41213 changed 2026-04-25 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-jhm7-29pj-4xvf changed 2026-05-05 | CC-BY-4.0 |
| NVD | CVE-2026-41213 changed 2026-10-26 | Public domain |