[WIP] - Fix HMAC verification failure when query params contain spaces#3102
Open
byrichardpowell wants to merge 1 commit intomainfrom
Open
[WIP] - Fix HMAC verification failure when query params contain spaces#3102byrichardpowell wants to merge 1 commit intomainfrom
byrichardpowell wants to merge 1 commit intomainfrom
Conversation
URLSearchParams.toString() encodes spaces as '+' (application/x-www-form-urlencoded)
but Shopify signs using percent-encoding ('%20'), causing validateHmac() to return
false for valid OAuth requests containing space-containing parameter values.
Fixes #2701
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Contributor
Author
|
Marking as WIP as I need to test this |
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.
WHY are these changes introduced?
Fixes #2701
URLSearchParams.toString()encodes spaces as+(application/x-www-form-urlencoded format), but Shopify generates its HMAC signature using percent-encoding (%20). This mismatch causedapi.utils.validateHmac()to returnfalsefor any valid OAuth request where a query parameter value contained a space.WHAT is this pull request doing?
ProcessedQuery.stringify(), replaces+with%20after callingURLSearchParams.toString()so the canonical query string matches Shopify's signing format.+to%20in hardcoded expected query strings.'spaces in param values are percent-encoded (%20), not plus-encoded'.Type of change
Checklist
pnpm changesetto create a draft changelog entry (do NOT update theCHANGELOG.mdfiles manually)