mirror of
https://github.com/affaan-m/ECC.git
synced 2026-12-01 12:45:15 +09:00
fix(rails-security): take the webhook replay key from the signed payload
- The HMAC covers the request body, not the headers, so deduplicating on X-Delivery-Id let a replay vary that header and queue the work again - Uses the event id parsed from the signed body as the dedupe key
This commit is contained in:
1 parent
4b8da913be
commit
36dedf4646
1 file changed
+2
-6
@@ -356,12 +356,8 @@ class WebhooksController < ApplicationController
|
||||
return head :unauthorized
|
||||
end
|
||||
|
||||
# A valid signature proves authenticity, not freshness. Dedupe on the
|
||||
# provider's delivery id so a replayed delivery does not repeat the work.
|
||||
delivery = WebhookDelivery.create_or_find_by!(
|
||||
provider: "billing",
|
||||
delivery_id: request.headers.fetch("X-Delivery-Id")
|
||||
)
|
||||
event_id = JSON.parse(request.raw_post).fetch("id")
|
||||
delivery = WebhookDelivery.create_or_find_by!(provider: "billing", delivery_id: event_id)
|
||||
return head :ok if delivery.processed_at?
|
||||
|
||||
ProcessWebhookJob.perform_later(delivery.id, request.raw_post)
|
||||
|
||||
Reference in new issue
Block a user