Skip to content

Fix OAuth2PushedAuthorizationRequestUri parsing#19445

Open
therepanic wants to merge 1 commit into
spring-projects:mainfrom
therepanic:gh-19444
Open

Fix OAuth2PushedAuthorizationRequestUri parsing#19445
therepanic wants to merge 1 commit into
spring-projects:mainfrom
therepanic:gh-19444

Conversation

@therepanic

Copy link
Copy Markdown
Contributor

OAuth2PushedAuthorizationRequestUri uses Base64URL encoding for the state, which can produce a value containing ___, the same sequence used as the delimiter. As a result, indexOf may locate a delimiter within the state instead of the delimiter preceding the expiration timestamp.

Use lastIndexOf to reliably locate the delimiter before the timestamp without changing the existing request URI format.

Closes gh-19444

`OAuth2PushedAuthorizationRequestUri` uses Base64URL encoding for the state, which can produce a value containing `___`, the same sequence used as the delimiter. As a result, `indexOf` may locate a delimiter within the state instead of the delimiter preceding the expiration timestamp.

Use `lastIndexOf` to reliably locate the delimiter before the timestamp without changing the existing request URI format.

Closes spring-projectsgh-19444

Signed-off-by: Andrey Litvitski <andrey1010102008@gmail.com>
@therepanic
therepanic marked this pull request as ready for review July 14, 2026 16:29
Comment on lines -60 to 61
int expiresAtStartIndex = requestUri.indexOf(REQUEST_URI_DELIMITER) + REQUEST_URI_DELIMITER.length();
int expiresAtStartIndex = requestUri.lastIndexOf(REQUEST_URI_DELIMITER) + REQUEST_URI_DELIMITER.length();
String state = requestUri.substring(stateStartIndex);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not break backward compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OAuth2PushedAuthorizationRequestUri generates URIs which cannot be parsed due to ___ delimiter in the state part

2 participants