Skip to content

Fix user/password split for percent-encoded Redis URI credentials - #4617

Merged
ggivo merged 7 commits into
redis:masterfrom
insaf021:uri-raw-userinfo-decode
Sep 23, 2026
Merged

ggivo merged 7 commits into
redis:masterfrom
insaf021:uri-raw-userinfo-decode

Conversation

@insaf021

@insaf021 insaf021 commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4728

redis://us%3Aer:pw@host  ->  getUser="us", getPassword="er:pw"
                             (want user "us:er", password "pw")

getUser/getPassword read uri.getUserInfo(), which percent-decodes the userinfo before the user:password split. A %3A in the username decodes to a literal : first, so split(":", 2) lands on it and the credentials are cut at the wrong point, sending the wrong ACL identity to AUTH.

Splitting uri.getRawUserInfo() keeps the encoded colon as %3A, so only the real separator is a literal :, and each half is decoded after the split. + is kept literal since userinfo is not form data, so passwords already containing + are unaffected.


Note

Medium Risk
Changes how URI credentials are parsed for Jedis client setup and AUTH; behavior shifts only for percent-encoded userinfo edge cases, but incorrect parsing previously sent wrong ACL identities.

Overview
Fixes incorrect user/password extraction when Redis connection URIs contain percent-encoded characters in the userinfo segment (e.g. %3A in a username).

getUser and getPassword now split on getRawUserInfo() instead of getUserInfo(), so encoded colons do not become literal : before the split and move the boundary. Each side is UTF-8 percent-decoded after the split via a new decode helper; + is treated as literal (not form-style space) by escaping it before URLDecoder.

Tests cover encoded colons in usernames and encoded specials / plus signs in passwords.

Reviewed by Cursor Bugbot for commit 0b20113. Bugbot is set up for automated code reviews on this repo. Configure here.

@ggivo ggivo added the waiting-for-triage Still needs to be triaged label Jul 14, 2026
@ggivo

ggivo commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the fix β€” we'll take a closer look shortly.

@insaf021

insaf021 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Filed #4728 with the repro so this has a tracked issue. Also merged master in: the red SDR job was the xinfo expected 2 / got 1 failure that hit every PR between 4 and 7 August and has since been fixed in the workflow, nothing in this diff goes near streams.

@atakavci atakavci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@@ -53,9 +56,9 @@ public static HostAndPort getHostAndPort(URI uri) {
* @return the user as a String, or null if user is empty or {@link URI#getUserInfo()} info is missing

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

javadoc remains to reference to getUserInfo

@ggivo ggivo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@ggivo ggivo removed the waiting-for-triage Still needs to be triaged label Sep 17, 2026
@ggivo ggivo changed the title split raw userinfo before decoding redis URI credentials Fix user/password split for percent-encoded Redis URI credentials Sep 17, 2026
@ggivo
ggivo merged commit ca96ebb into redis:master Sep 23, 2026
14 checks passed
@ggivo ggivo added the bug label Oct 26, 2026
@ggivo ggivo added this to the 8.1.0 milestone Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Percent-encoded colon in URI username shifts the user/password split

3 participants