[WIP] - Fix app proxy HMAC validation dropping duplicate query parameters#3101
Open
byrichardpowell wants to merge 3 commits intomainfrom
Open
[WIP] - Fix app proxy HMAC validation dropping duplicate query parameters#3101byrichardpowell wants to merge 3 commits intomainfrom
byrichardpowell wants to merge 3 commits intomainfrom
Conversation
Object.fromEntries(searchParams.entries()) silently collapsed repeated query params before HMAC validation, producing a different string than Shopify signed and causing spurious 400s. Replace with searchParamsToQuery() which preserves duplicates as arrays, matching the comma-join behaviour already expected by stringifyQueryForAppProxy. Fixes #2374 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ring[] AuthQuery only accepts string | undefined values. Pre-join duplicate params with commas in searchParamsToQuery so the type satisfies AuthQuery. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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 #2374
authenticate.public.appProxy()throws a spurious 400 for requests where a query parameter appears more than once.Object.fromEntries(searchParams.entries())silently drops duplicate keys before HMAC validation, producing a different string than Shopify signed.stringifyQueryForAppProxyinhmac-validator.tsalready handles arrays by joining with commas, but never received arrays becauseObject.fromEntriescollapsed them first.WHAT is this pull request doing?
Adds a
searchParamsToQuery()helper that iteratesURLSearchParamsentries preserving duplicates as arrays, and replaces all threeObject.fromEntries(searchParams.entries())calls insidevalidateAppProxyHmacin bothshopify-app-remixandshopify-app-react-router.Also fixes the
createAppProxyHmactest helper which had the same bug (masking the issue in tests), and adds a regression test for the duplicate-parameter case.Type of change
Checklist
pnpm changesetto create a draft changelog entry (do NOT update theCHANGELOG.mdfiles manually)