fix: decode percent-encoded password in parseRedisUrl#1952
Open
heavenly999 wants to merge 1 commit intodocmost:mainfrom
Open
fix: decode percent-encoded password in parseRedisUrl#1952heavenly999 wants to merge 1 commit intodocmost:mainfrom
heavenly999 wants to merge 1 commit intodocmost:mainfrom
Conversation
|
|
The WHATWG URL parser percent-encodes '=' as '%3D' in the userinfo section of URLs. Cloud Redis providers like Azure and AWS use base64 access keys that contain '='. Without decoding, ioredis sends the percent-encoded password to Redis AUTH, which rejects it with WRONGPASS. This adds decodeURIComponent() to the parsed password before returning the RedisConfig.
747cab9 to
8ce5b2a
Compare
Member
|
If you don't mind, can you finish the CLA step so I can review? |
Author
|
@Philipinho hey, yes, I did that already but nothing happened. I clicked on the link, logged in with my Github account, redirected back to Github, but the badge didn't change. Tried the recheck button as well. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
parseRedisUrl()returns the password fromnew URL().passwordwithout decoding it. The WHATWG URL spec mandates that=is percent-encoded as%3Din the userinfo section.Cloud Redis providers (Azure Managed Redis, AWS ElastiCache, etc.) use base64 access keys that end with
=. When these keys are placed in aredis://URL, the parser encodes them:url.passwordthen returns...4N5CpAzCaJdAF4g%3D, which ioredis sends verbatim to RedisAUTH→WRONGPASS.Verified in Node.js:
Fix
Add
decodeURIComponent()to the parsed password before returningRedisConfig. This is safe for passwords that don't contain percent-encoded characters (decoding a string without%XXsequences is a no-op).Testing
Tested against Azure Managed Redis with a base64 access key ending in
=. Before fix:WRONGPASS. After fix: connects successfully.