Repository navigation
fix(security): timing-safe webhook HMAC + clear high-severity deps (port of shopify-on-cloudflare#9) - #1
Merged
rome2o merged 1 commit intoAug 16, 2026
Conversation
… shopify-on-cloudflare-template Ports devkindhq/shopify-on-cloudflare#9 into the template: 1. Webhook HMAC verification compared the computed digest against the X-Shopify-Hmac-Sha256 header with plain !== (early-exit string compare), leaving it open to timing attacks. Replaced with crypto.subtle.timingSafeEqual (Workers runtime extension, per developers.cloudflare.com/workers/runtime-apis/web-crypto) with a constant-time XOR-fold fallback for non-Workers runtimes (vitest/Node). Adds a wrong-length-signature test covering the no-early-exit path. 2. Bumps @cloudflare/vite-plugin 1.46.0 -> 1.52.1 and wrangler 4.113.0 -> 4.123.0 (peer dep of the new vite-plugin). Clears all 8 high-severity npm audit advisories (undici chain). Remaining 6 moderates are drizzle-kit/react-router major-bump chains, documented as out of scope upstream. 3. Adds the security-audit note above registerWebhooks (verified safe: outbound registration, not inbound handling). Verified: templates lint, prettier, lockfile lint, turbo check + cf-typegen (build + deploy dry-run), vitest 21/21, wrangler types idempotent vs committed worker-configuration.d.ts.
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.
Ports the security fix from devkindhq/shopify-on-cloudflare#9 (merged 2026-08-16, after this template branch was cut) into
add-shopify-on-cloudflare-template, plus the Cloudflare-templates compliance re-check.Why
src/lifecycle/webhooks.tsverified Shopify'sX-Shopify-Hmac-Sha256webhook signature with a plain!==string comparison — early-exit, timing-attack-vulnerable. The source repo fixed exactly this today; the template still shipped the vulnerable compare.Changes
1. Timing-safe HMAC verification (the security fix)
src/lib/timingSafeEqual.ts— uses the Workers runtime'scrypto.subtle.timingSafeEqualextension (docs) with a constant-time XOR-fold fallback for non-Workers runtimes (Node/vitest). No early return on length mismatch (compares against self and negates, per the documented pattern).webhooks.ts:computedHmac !== hmacHeader→!timingSafeEqual(computedHmac, hmacHeader).registerWebhooks(audit false positive: outbound registration, not inbound handling).2. Dependency audit — 8 high → 0 high
Same
npm audit fixthe source repo shipped in cloudflare#9:@cloudflare/vite-plugin1.46.0 → 1.52.1 andwrangler4.113.0 → 4.123.0 (peer dep) — clears the undici chain (8 high advisories).package-lock.jsonregenerated viapnpm fix:lockfiles;templates.jsonpackage_json_hashupdated (sha1 of new package.json).Verification (all run on this branch)
templates lint .(check:templates)prettier . --checktemplates lint-npm-lockfilesturbo run check cf-typegen --filter=shopify-on-cloudflare-templatevitest runwrangler typesidempotency vs committedworker-configuration.d.tsnpm audit --package-lock-onlyNote:
tsc --noEmitfails on React 18/19@typesconflicts identically on the pristine branch — pre-existing pnpm-workstore hoisting artifact (standalone npm install used by Deploy-to-Cloudflare resolves a single@types/react@18), unrelated to this change. Repo CI does not run tsc for this template; its gate isturbo check(build + dry-run), which passes.Once merged, Uzair's branch can be synced to the upstream PR.