File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -352,10 +352,18 @@ public function respondToAccessTokenRequest(
352352 throw OAuthServerException::invalidRequest ('code ' , 'Cannot decrypt the authorization code ' , $ e );
353353 }
354354
355+ $ codeVerifier = $ this ->getRequestParameter ('code_verifier ' , $ request , null );
356+
357+ // If a code challenge isn't present but a code verifier is, reject the request to block PKCE downgrade attack
358+ if ($ this ->shouldCheckPkce ($ client ) && empty ($ authCodePayload ->code_challenge ) && $ codeVerifier !== null ) {
359+ throw OAuthServerException::invalidRequest (
360+ 'code_challenge ' ,
361+ 'code_verifier received when no code_challenge is present '
362+ );
363+ }
364+
355365 // Validate code challenge
356366 if (!empty ($ authCodePayload ->code_challenge )) {
357- $ codeVerifier = $ this ->getRequestParameter ('code_verifier ' , $ request , null );
358-
359367 if ($ codeVerifier === null ) {
360368 throw OAuthServerException::invalidRequest ('code_verifier ' );
361369 }
You can’t perform that action at this time.
0 commit comments