{"id":"CVE-2026-41213","aliases":["CVE-2026-41213","GHSA-jhm7-29pj-4xvf"],"related":[],"kind":"vulnerability","state":"published","title":"@node-oauth/oauth2-server: PKCE code_verifier ABNF not enforced in token exchange allows brute-force redemption of intercepted authorization codes","summary":"@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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"@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.","source":"cvelist"},{"lang":"en","text":"## Summary\n\nThe token exchange path accepts RFC7636-invalid `code_verifier` values (including one-character strings) for `S256` PKCE flows.  \nBecause 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.\n\n\n\n### Root cause\n\n1. `lib/pkce/pkce.js` (`getHashForCodeChallenge`) only checks that `verifier` is a non-empty string before hashing for `S256`; it does not enforce RFC7636 ABNF (`43..128` unreserved chars).\n2. `lib/grant-types/authorization-code-grant-type.js` compares `hash(code_verifier)` to stored `codeChallenge` without validating verifier format/length.\n3. In `AuthorizationCodeGrantType.handle`, authorization code revocation happens **after** verifier validation. Invalid guesses fail before revoke, so the same code can be retried repeatedly.\n\n## Steps to Reproduce\n\n### Setup\n\n- PKCE authorization code exists with:\n  - `codeChallengeMethod = \"S256\"`\n  - `codeChallenge = BASE64URL(SHA256(\"z\"))` (verifier is one character, RFC-invalid)\n- Attacker has intercepted the authorization code value.\n\n### Reproduction\n\n1. Send repeated token requests with guessed `code_verifier` values:\n\n```http\nPOST /token HTTP/1.1\nHost: oauth.example\nContent-Type: application/x-www-form-urlencoded\n\ngrant_type=authorization_code&\nclient_id=client1&\nclient_secret=s3cret&\ncode=stolen-auth-code&\nredirect_uri=https://client.example/callback&\ncode_verifier=<guess>\n```\n\n2. Observe invalid guesses return `invalid_grant`.\n3. Continue guessing (`a`..`z`).\n4. When `code_verifier=z`, token issuance succeeds and returns bearer tokens.\n\n### Confirmed PoC output\n\n```text\nBRUTE_FORCE_SUCCESS { tries: 26, guess: 'z', status: 200, tokenIssued: true }\n```\n\n## Impact\n\nAn intercepted authorization code can be redeemed by brute-forcing low-entropy verifiers that the server should have rejected under RFC7636.  \nThis weakens PKCE’s protection goal and allows token theft when clients generate short/predictable verifiers.\n\n## Recommended Fix\n\n1. Enforce `pkce.codeChallengeMatchesABNF(request.body.code_verifier)` in authorization code token exchange before hashing/comparison.\n2. Reject verifier values outside RFC7636 charset/length (`43..128` unreserved).\n3. Invalidate authorization codes on failed verifier attempts (or add strict retry limits) to prevent online guessing.","format":"markdown","source":"ghsa"},{"lang":"es","text":"@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.","source":"nvd"}],"published":"2026-04-16T21:09:50.000Z","modified":"2026-10-26T21:10:00.170Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N","score":5.9,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N","score":5.9,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N","score":5.9,"rating":"MEDIUM"}],"cwes":["CWE-307","CWE-1289"],"affected":[{"ranges":[{"version":"< 5.3.0","status":"affected"}],"vendor":"node-oauth","product":"node-oauth2-server","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"5.3.0"}],"ecosystem":"npm","package":"@node-oauth/oauth2-server","purl":"pkg:npm/%40node-oauth/oauth2-server","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"5.3.0"}],"vendor":"node-oauth","product":"node-oauth/oauth2-server","cpe":"cpe:2.3:a:node-oauth:node-oauth\\/oauth2-server:*:*:*:*:*:node.js:*:*","source":"nvd"}],"references":[{"url":"https://github.com/node-oauth/node-oauth2-server/security/advisories/GHSA-jhm7-29pj-4xvf","tags":["exploit","mitigation","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-41213","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/node-oauth/node-oauth2-server","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-04-25T01:23:23.060Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-41213","url":"https://www.cve.org/CVERecord?id=CVE-2026-41213","licence":"CVE Terms of Use","modified":"2026-04-25T01:23:58.715Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-jhm7-29pj-4xvf","url":"https://github.com/advisories/GHSA-jhm7-29pj-4xvf","licence":"CC-BY-4.0","modified":"2026-05-05T16:11:45.707Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-41213","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-41213","licence":"Public domain","modified":"2026-10-26T21:10:00.170Z"}],"updatedAt":"2026-11-25T22:59:19.407Z","epss":{"score":0.00269,"percentile":0.204,"date":"2026-12-01T12:00:22.000Z"}}