Skip to content

A platform for community discussion. Free, open, simple.

SECURITY: Prevent webhook payload disclosure on event redelivery

Joffrey JAFFEUX788523def7ed
diff --git a/app/jobs/scheduled/redeliver_web_hook_events.rb b/app/jobs/scheduled/redeliver_web_hook_events.rb
index be094033d6c..09fd4cf745f 100644
--- a/app/jobs/scheduled/redeliver_web_hook_events.rb
+++ b/app/jobs/scheduled/redeliver_web_hook_events.rb
@@ -56,6 +56,7 @@ module Jobs
type: type,
web_hook_event: AdminWebHookEventSerializer.new(web_hook_event, root: false).as_json,
},
+ group_ids: [Group::AUTO_GROUPS[:staff]],
)
end
end
diff --git a/spec/jobs/redeliver_web_hook_events_spec.rb b/spec/jobs/redeliver_web_hook_events_spec.rb
index 97421a066f3..4d1b2d3be62 100644
--- a/spec/jobs/redeliver_web_hook_events_spec.rb
+++ b/spec/jobs/redeliver_web_hook_events_spec.rb
@@ -43,6 +43,20 @@ RSpec.describe Jobs::RedeliverWebHookEvents do
expect(messages.first.data).to include(type: "redelivered")
end
+ it "restricts the redelivery MessageBus publish to the staff group" do
+ stub_request(:post, web_hook.payload_url).to_return(status: 200, body: "", headers: {})
+
+ messages =
+ MessageBus.track_publish("/web_hook_events/#{web_hook.id}") do
+ job.execute(web_hook: web_hook, web_hook_event: web_hook_event1)
+ end
+
+ expect(RedeliveringWebhookEvent.count).to eq(0)
+ expect(messages.size).to eq(1)
+ expect(messages.first.data).to include(type: "redelivered")
+ expect(messages.first.group_ids).to eq([Group::AUTO_GROUPS[:staff]])
+ end
+
context "when there is a redelivering_webhook_event in process" do
fab!(:redelivering_webhook_event_in_process) do
Fabricate(