Skip to content

fix(server): don't double-encode the implicit and hybrid fragment - #5183

Merged
nabokihms merged 1 commit into
dexidp:masterfrom
shlee1223:fix-fragment-double-encoding
Nov 19, 2026
Merged

nabokihms merged 1 commit into
dexidp:masterfrom
shlee1223:fix-fragment-double-encoding

Conversation

@shlee1223

Copy link
Copy Markdown
Contributor

Overview

Hi! The implicit and hybrid flows put the encoded response values into u.Fragment, which holds the decoded form, so u.String() percent-encodes them again. A state of a/b is sent as state=a%252Fb instead of state=a%2Fb (RFC 6749 Section 4.2.2, Appendix B), and a browser client reading location.hash gets a different state than it sent.

What this PR does / why we need it

Sets u.RawFragment to the encoded values, as the code flow does with u.RawQuery. TestOAuth2ImplicitFlow now uses a state with reserved characters and checks it in the raw fragment. The test previously parsed the already-decoded u.Fragment, which hid the extra encoding.

Signed-off-by: shlee1223 <shlee1223@raoncorp.com>
@nabokihms nabokihms added the release-note/bug-fix Release note: Bug Fixes label Nov 19, 2026

@nabokihms nabokihms left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, LGTM!

@nabokihms
nabokihms merged commit c895237 into dexidp:master Nov 19, 2026
10 checks passed
kuangruan pushed a commit to kuangruan/dex that referenced this pull request Nov 25, 2026
10 commits since 60f28dd: ID-JAG audience binding and auth_time, the
allowedGroups enforcement fix, ent blocked_until NULL handling, api
username validation, LDAP startTLS port default, implicit/hybrid fragment
encoding, and connector fixes. No changes are proposed upstream.

* 'master' of https://github.com/dexidp/dex:
  feat(oauth2): let an ID-JAG policy set the client's ID at each audience (dexidp#5181)
  feat(oauth2): carry auth_time from the subject token into the ID-JAG (dexidp#5180)
  fix(connector/github): return UserNotInRequiredGroupsError when user lacks org or team access (dexidp#5100)
  fix(storage/ent): store an unset blocked_until as NULL (dexidp#5163)
  fix(api): require a username in CreatePassword (dexidp#5162)
  fix(ldap): default to port 389 when startTLS is set (dexidp#5184)
  fix(server): don't double-encode the implicit and hybrid fragment (dexidp#5183)
  fix(oidc)!: enforce allowedGroups when insecureEnableGroups is unset (dexidp#5185)
  feat(server): allow starting without connectors when the connectors API is enabled (dexidp#5061)
  fix(server): type access tokens at+jwt for clients with an ID-JAG policy (dexidp#5179)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/bug-fix Release note: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants