PT-2026-35315 · Npm · Node-Oauth2-Server
Published
2026-04-16
·
Updated
2026-04-16
CVSS v3.1
5.9
Medium
| Vector | AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N |
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:
http
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
text
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.
Fix
Improper Restriction of Excessive Authentication Attempts
Found an issue in the description? Have something to add? Feel free to write us 👾
Related Identifiers
Affected Products
Node-Oauth2-Server