[Bounty $200] security: shopify OAuth callback never verifies signatures — forged callbacks rebind grants to any uid
Summary
/auth/shopify/callback in plugins/omi-shopify-app/main.py trusts every query parameter without any verification:
verify_shopify_hmac()exists but is never called — thehmacShopify signs the redirect with is accepted and ignored.stateis the raw uid (uid = state), so anyone can point the flow at a uid they don't own.
Impact
- Unsigned state → grant rebinding (login CSRF). An attacker initiates
/auth/shopify?uid=<victim>&shop=<attacker>.myshopify.com, completes OAuth for their own shop, and the resulting valid callback binds the attacker's shop access token under the victim's uid. The victim's app then reads/writes the attacker's store. - No Shopify HMAC check → forged callbacks. Anyone can hit the callback with arbitrary
code/state/shop. Combined with the missing*.myshopify.comvalidation (tracked separately in #13656), the code exchange POSTsclient_id+client_secretto an attacker host. Even with the domain fix, unverified callbacks still let a foreign grant overwrite a user's shop binding. - The existing
verify_shopify_hmacalso re-encodes params withurlencode, which mismatches Shopify's documented signing scheme (decodedkey=valuepairs, sorted,&-joined) and would reject legitimate callbacks — it was presumably abandoned rather than fixed.
Fix
- Call
verify_shopify_hmacin the callback and reject forged/unsigned requests before the token exchange. - Sign
stateat initiation (_oauth_state_for(uid)→uid:hmac_sig) and verify it in the callback (_oauth_state_uid), so only flows this server started can bind a uid. - Correct
verify_shopify_hmacto match Shopify's signing scheme. - Hermetic regression tests: forged hmac, missing hmac, foreign-state rebinding, tampered state, and the valid round-trip.
PR with fix + tests follows. cc @kodjima33 @Git-on-my-level
Fix + regression tests: #14443
@josancamon19 @kodjima33 — fix is up and verified with regression tests; if this qualifies under the paid-bounty program I would be glad to take it on.
Closing as already fixed on current main.
Current main shopify_callback calls verify_shopify_hmac and binds uid via _oauth_state_uid(state) (signed state, not raw uid)
Hi @kodjima33 @josancamon19 — following up on the payout for this one.
PR #14612 was merged on 19 Sep and this issue closed as completed, with the fix (_signing_secret() fail-closed, corrected verify_shopify_hmac scheme, signed OAuth state) now on main.
Could you point me at how the $200 bounty is paid out — is there a form, an Algora/Stripe claim, or an address you need from me? Happy to follow whatever process you use.
Thanks for the quick review either way.
Hi @kodjima33 @josancamon19,
Following up on the security fix for this issue across the related PRs (#14443, #14548, and merged #14612).
In PR #14548, I submitted key structural improvements to the Shopify HMAC verification and state binding (including signature param removal, query multi-value joining, and empty-HMAC guards), which reviewer @Git-on-my-level validated and noted:
"Mechanically this PR is slightly better on a few points... credit is due to both authors either way."
Given that the final landed solution integrated insights from the earlier PRs (#14443 and #14548), could the maintainers consider a split bounty reward among the contributing authors?
Thank you for your consideration and for reviewing our contributions!