Skip to content

Commit 4efa4da

Browse files
authored
Fix IDOR in webhook activation endpoint (#2431)
The webhook activation controller was using account-scoped lookup instead of board-scoped lookup, allowing users to reactivate webhooks on boards they don't have access to. This was an oversight when board-scoping was added to the main webhooks controller - the activations controller was missed in that update. The fix adds the BoardScoped concern to properly restrict webhook activation to boards the user has explicit access to.
1 parent 16745e8 commit 4efa4da

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

app/controllers/webhooks/activations_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
class Webhooks::ActivationsController < ApplicationController
2+
include BoardScoped
3+
24
before_action :ensure_admin
35

46
def create
5-
webhook = Current.account.webhooks.find(params[:webhook_id])
7+
webhook = @board.webhooks.find(params[:webhook_id])
68
webhook.activate
79

810
redirect_to webhook

test/controllers/webhooks/activations_controller_test.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,20 @@ class Webhooks::ActivationsControllerTest < ActionDispatch::IntegrationTest
1616

1717
assert_redirected_to board_webhook_path(webhook.board, webhook)
1818
end
19+
20+
test "cannot activate webhook on board without access" do
21+
logout_and_sign_in_as :jason
22+
webhook = webhooks(:inactive) # on private board, jason has no access
23+
24+
post board_webhook_activation_path(webhook.board, webhook)
25+
assert_response :not_found
26+
end
27+
28+
test "non-admin cannot activate webhook" do
29+
logout_and_sign_in_as :jz # member with writebook access, but not admin
30+
webhook = webhooks(:active) # on writebook board
31+
32+
post board_webhook_activation_path(webhook.board, webhook)
33+
assert_response :forbidden
34+
end
1935
end

test/controllers/webhooks_controller_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,13 @@ class WebhooksControllerTest < ActionDispatch::IntegrationTest
121121

122122
assert_redirected_to board_webhooks_path(webhook.board)
123123
end
124+
125+
test "cannot access webhooks on board without access" do
126+
logout_and_sign_in_as :jason
127+
128+
webhook = webhooks(:inactive) # on private board, jason has no access
129+
130+
get board_webhooks_path(webhook.board)
131+
assert_response :not_found
132+
end
124133
end

0 commit comments

Comments
 (0)