Can the authorization server expose the code_challenge in what it returns to the client?

code_challenge not included where other entities can extract itRFC 7636 §4.4MUST NOTRoles: authorization_server

Requirement as recorded in the ProtocolSoup registry

The server MUST NOT include the "code_challenge" value in client requests in a form that other entities can extract.

Read §4.4 in RFC 7636

Self-test verdict

PassCommit 00bac3fEvaluated

This is ProtocolSoup's result against its own implementation at the commit shown. It is not a certification of ProtocolSoup or of any other product.

Captured from production

Captured Commit 00bac3f

Captured from the deployed ProtocolSoup at the commit shown. Every request and response is shown exactly as sent and received.

Passing exchange

Not captured: The requirement constrains what the authorization server puts in the authorization code it sends to the client. The code reaches the client in the authorization response, which answers the End-User's sign-in, and a capture does not record the sign-in. This server keeps the code_challenge in its own store and issues a random code.

Failing exchange

Not captured: The requirement constrains what the authorization server puts in the authorization code it sends to the client. The code reaches the client in the authorization response, which answers the End-User's sign-in, and a capture does not record the sign-in. This server keeps the code_challenge in its own store and issues a random code.

Tests

Implementation

Explainer

What this requires

No: the authorization server must not expose the code_challenge in what it returns to the client in a form anyone else can read. RFC 7636 Section 4.4 lets a server carry the challenge inside the authorization code, since "Typically, the "code_challenge" and "code_challenge_method" values are stored in encrypted form in the "code" itself", but the code travels through the user agent to the client and then back to the token endpoint. Whatever is inside it passes through the same channel PKCE assumes an attacker can watch. So a server that packs the challenge into the code has to encrypt it, and a server that keeps the challenge on its own side has nothing to protect.

The phrase "in client requests" covers what the client will send onward: the code it presents in its token request.

Why it exists

For S256 a leaked challenge is only a hash, but the requirement is written for both methods, and Section 7.2 states the sharp case: "If the code challenge method is "plain" and the code challenge is to be returned inside authorization "code" to achieve a stateless server, it MUST be encrypted in such a manner that only the server can decrypt and extract it." Under plain the challenge is the verifier, so a readable challenge in the code hands an interceptor both things the token endpoint asks for.

What non-compliance looks like

A stateless server that issues the code as an unencrypted or merely encoded structure, a base64 JSON object or a signed but unencrypted JWT with a code_challenge member, lets anyone who sees the redirect read the challenge out of the code parameter.

How ProtocolSoup tests it

This server's code is 32 characters from a random source and carries no data. The challenge lives in the Mock IdP's record for that code. TestCodeChallengeIsNotExposedInTheAuthorizationResponse runs a PKCE authorization to its redirect and asserts that neither the redirect nor the decoded code contains the challenge as sent or in base64url, base64 or hex. It also asserts that two requests with the same challenge get different codes, so the code is not derived from the challenge, and that the server's own record does hold it.

There is no captured exchange for this row. The code reaches the client in the authorization response, which answers the End-User's sign-in, and a capture does not record the sign-in.

Related requirements

All RFC 7636 requirements · OAuth 2.0 protocol page

Can the authorization server expose the code_challenge in what it returns to the client? · RFC 7636 §4.4 | ProtocolSoup