Sporadic errors with authorization_code and PKCE #399
-
|
Hi all, So we have an issue with sporadic errors when trying to log in. Something like 3-4 times a day from a few hundred attempts. Checking into the logs, the error message is "Transformed code verifier does not match code challenge". That is weird since at one point we started logging both verifier and challenge, and tried to test them, and we could log in. We are using .NET 6 and Duende.IdentityServer 6.3.0, client is set up for authorization_code and required PKCE. verifier: Q6pFlrnkGBaC0OYhA99WIusVmvkLy-6UkKny8LZ6xlZTq_8oLK4_shf5RbymM8Bw verifier: xxHM58pmtzHdf98rBF9O1ef84lCLJVn3FxA46_CPNy5mgCBQLCxkh_oeDkdq2GpH verifier: iLyrYkP_1-JnW_mnXtbfrw4ayEEjzyauH45BDZuCsnajtHqa__F0YPLUuSMR13_V verifier: 2__1bE5EPFQ2eWrfJ4lm5U3W9TiKTmWPx~pmnUmgg6qbakaWvUrQ7lyMfsBpZTS9 challenge: IwfoaUevTNGERh6SquqhQmw64AeWIgYfajs7qTDUKyM Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
|
We haven't seen this issue before, so I've tried to mimic your scenario by writing a small console application targeting .NET 6 and performing the logic against the verifier/challenge pairs you've provided, but the console app ran every sample flawlessly in multiple iterations (1 billion iterations). I would definitely recommend upgrading your solution to .NET 8 or higher to exclude any issues related to .NET 6 which is already out of support since November 12, 2024. |
Beta Was this translation helpful? Give feedback.
-
|
@emanuelxm We have another bug report that might be related to this. Having two reports to work on can help in cross-referencing common factors. We are currently investigating if the root cause of this could be something with the .NET version, Operating System and crypto libraries. Could you please list a bit more about your environment? .NET Version? OpenSSL version (if applicable)? OS version? Hardware? |
Beta Was this translation helpful? Give feedback.
-
|
Hi team, We are also seeing a very similar issue. Our setup: .NET 8 After the upgrade, we started getting intermittent authentication failures with the error: "Transformed code verifier does not match code challenge" This started happening suddenly after the IdentityServer upgrade. There were no changes on the client side — the way we generate and pass code_challenge, code_challenge_method, and code_verifier remains exactly the same. The failures are rare but consistent (sporadic, hard to reproduce), similar to what’s described earlier in this thread. |
Beta Was this translation helpful? Give feedback.
Hi @skoruba,
Apologies for the confusion earlier. After deeper investigation, we’ve confirmed this was not related to NextAuth.js.
The root cause was actually in our own implementation. In certain scenarios, a method responsible for initiating the authorization request was being called twice on the same page load. As a result:
Two different code_challenge values were generated
Two different code_verifier values were generated
The requests overlapped and eventually conflicted at the token exchange stage
Because of this race/duplication, the code_verifier sent during the token request did not always match the originally associated code_challenge, which caused the intermittent:
"Transformed …