Skip to content

Fix OAuth2PushedAuthorizationRequestUri parsing - #19445

Merged
jzheaux merged 2 commits into
spring-projects:7.0.xfrom
therepanic:gh-19444
Jul 31, 2026
Merged

Fix OAuth2PushedAuthorizationRequestUri parsing#19445
jzheaux merged 2 commits into
spring-projects:7.0.xfrom
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

@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.

jzheaux and others added 2 commits July 31, 2026 12:55
Adds baseline test coverage for OAuth2PushedAuthorizationRequestUri,
which previously had none: a round-trip via create()/parse() and an
explicit parse() case on a hand-constructed request URI.

See spring-projectsgh-19444.

Signed-off-by: Josh Cummings <3627351+jzheaux@users.noreply.github.com>
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>
@jzheaux
jzheaux merged commit e4fafce into spring-projects:7.0.x Jul 31, 2026
6 checks passed
@jzheaux

jzheaux commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Thanks, @therepanic, for the PR! This is now merged into 7.0.x and main and will go out in the next release.

@jzheaux jzheaux self-assigned this Jul 31, 2026
@jzheaux jzheaux added type: bug A general bug in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) type: bug A general bug

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

3 participants