Must the authorization response return the state parameter the client sent?

state returned exactly in the authorization code responseRFC 6749 §4.1.2REQUIREDRoles: authorization_server

Requirement as recorded in the ProtocolSoup registry

state REQUIRED if the "state" parameter was present in the client authorization request. The exact value received from the client.

Read §4.1.2 in RFC 6749

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 response this requirement constrains is the authorization response, which answers the End-User's sign-in. A capture does not record the sign-in: how the resource owner authenticates is the authorization server's own business, not an OAuth 2.0 message.

Failing exchange

Not captured: The response this requirement constrains is the authorization response, which answers the End-User's sign-in. A capture does not record the sign-in: how the resource owner authenticates is the authorization server's own business, not an OAuth 2.0 message.

Run it live

Looking Glass runs the flow that sends the message this requirement governs, against the same server, and decodes each exchange as it happens.

Open the flow in Looking Glass

Tests

Implementation

Explainer

What this requires

Yes: the authorization response returns the state parameter the client sent, whenever the request had one, and exactly. state belongs to the client. Section 4.1.1 calls it "An opaque value used by the client to maintain state between the request and callback." The server's whole duty is to hand it back unchanged in the redirect that carries the code. It does not interpret it, shorten it or normalize it, and it does not add one when the request had none.

Exact means the client gets the same string after decoding the redirect's query. A state with spaces, +, &, =, % or non-ASCII characters has to survive, which is a matter of encoding it correctly when building the Location header.

Why it exists

The client uses state to tie the response to the browser session that started the flow. Section 10.12 describes the protection: "The binding value enables the client to verify the validity of the request by matching the binding value to the user-agent's authenticated state." The client compares what comes back with what it stored. If the server alters the value in any way, a correct client rejects its own legitimate response.

What non-compliance looks like

Double encoding or decoding is the usual cause: a + returned as a space, or %20 returned as a literal percent sequence. Truncating long values and dropping state on some code paths are others. The symptom on the client is a state mismatch error for a flow nobody tampered with.

How ProtocolSoup tests it

The server stores the state with the pending authorization request and sets it on the redirect with a standard query encoder. TestAuthorizationResponseReturnsTheExactState sends a state made of a space, +, &, =, /, a literal %20, ?, #, a double quote, angle brackets and a non-ASCII letter. After sign-in the redirect's query must contain exactly one state whose decoded value equals what was sent, next to the code. A request without state must produce a redirect without one.

There is no captured exchange for this row. The response it constrains answers the End-User's sign-in, and a capture does not record the sign-in. The error-response counterpart, which a single request can show, is captured under OA-024.

Related requirements

All RFC 6749 requirements · OAuth 2.0 protocol page

Must the authorization response return the state parameter the client sent? · RFC 6749 §4.1.2 | ProtocolSoup