Repository navigation
fix(shop): v4.5.1 — require proof of access to view or pay an order by number - #220
Merged
Merged
Conversation
The customer order page looked orders up by number alone whenever no ?email= was given, and order numbers are sequential — so anyone could walk KHP-2026-00001, 00002, … and read every buyer's name, email, phone and shipping address. Any signed-in account, customers included, could do the same. The return-request action and pay-by-orderNumber had the same gap. Access now needs one of: staff (admin+), the owning account (user id, or a verified email matching the order), the order's email (receipt links and /lookup), or the browser that placed the order — checkout/ start sets an HMAC-signed cookie (keyed by BETTER_AUTH_SECRET) so a guest returning from the payment page still lands on their order. Refusals are the same 404 as a missing order. Ported from bactrack-website 70d37f5, with a generic cookie name and a verified-email requirement on the account-email path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 25, 2026
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.
Security fix
/[locale]/order/[orderNumber]looked the order up by number alone whenever?email=was absent. Order numbers are sequential, so an anonymous visitor could enumerate every customer's name, email, phone and shipping address. Any signed-in account (customers included) could too. The return-request action and pay-by-orderNumberhad the same gap; the latter let a stranger re-point someone's pending order at a new charge.Fix
src/lib/server/shop/order-access.ts:canViewOrder()allows only?email=from receipts,/lookup)checkout/startsets an HMAC-signedkhaopad_order_accesscookie, SameSite=Lax so it survives the payment provider's redirect back)Refusals render the same 404 as a missing order. Applied to the order page load, the
requestReturnaction, andcheckout/paywhen called by number.orderId(unguessable nanoid) is unchanged. The order page's retry button now sends the order email it already holds.Ported from codustry/bactrack-website
70d37f5(already live there).Verification
pnpm lint0 errors ·pnpm check0 errors · 1129/1129 tests (1114 + 15 new) · build OK · contract-guard OK · css-inventory +0wrangler devwith local D1, seeded order:?email=?email=(any case)Rollout note
Existing guests lose cookie-less access to past order pages; receipt links carry
?email=and keep working.🤖 Generated with Claude Code