A platform for community discussion. Free, open, simple.
SECURITY: Private Chat Threat Message Disclosure via Chat Onebox Channel/Threat ID Mismatch
Isaac Janzendc54846f0754
diff --git a/plugins/chat/lib/chat/onebox_handler.rb b/plugins/chat/lib/chat/onebox_handler.rbindex 7098bd7c8db..4f6cf0d4c20 100644--- a/plugins/chat/lib/chat/onebox_handler.rb+++ b/plugins/chat/lib/chat/onebox_handler.rb@@ -16,7 +16,7 @@ module Chatchat_channel = Chat::Channel.find_by(id: route[:channel_id])return if !chat_channel- thread = Chat::Thread.find_by(id: route[:thread_id]) if route[:thread_id]+ thread = chat_channel.threads.find_by(id: route[:thread_id]) if route[:thread_id]endreturn if !Guardian.new.can_preview_chat_channel?(chat_channel)diff --git a/plugins/chat/spec/requests/core_ext/onebox_controller_spec.rb b/plugins/chat/spec/requests/core_ext/onebox_controller_spec.rbnew file mode 100644index 00000000000..c705e1e79b5--- /dev/null+++ b/plugins/chat/spec/requests/core_ext/onebox_controller_spec.rb@@ -0,0 +1,50 @@+# frozen_string_literal: true++RSpec.describe OneboxController do+ fab!(:current_user, :user)+ fab!(:direct_message_user_1, :user)+ fab!(:direct_message_user_2, :user)+ fab!(:direct_message_user_3, :user)+ fab!(:public_channel, :category_channel)+ fab!(:private_channel) do+ Fabricate(+ :direct_message_channel,+ users: [direct_message_user_1, direct_message_user_2, direct_message_user_3],+ threading_enabled: true,+ )+ end+ fab!(:private_original_message) do+ Fabricate(+ :chat_message,+ chat_channel: private_channel,+ user: direct_message_user_1,+ message: "private thread secret message",+ )+ end+ fab!(:private_thread) do+ Fabricate(:chat_thread, channel: private_channel, original_message: private_original_message)+ end++ before do+ SiteSetting.chat_enabled = true+ SiteSetting.chat_allowed_groups = Group::AUTO_GROUPS[:everyone]+ sign_in(current_user)+ end++ it "does not render a private thread when the URL uses a public channel id" do+ get "/chat/api/channels/#{private_channel.id}/threads/#{private_thread.id}"++ expect(response.status).to eq(403)+ expect(response.parsed_body["errors"]).to be_present++ get "/onebox.json",+ params: {+ url: "#{Discourse.base_url}/chat/c/-/#{public_channel.id}/t/#{private_thread.id}",+ refresh: "true",+ }++ expect(response.status).to eq(200)+ expect(response.body).to include(public_channel.name)+ expect(response.body).not_to include(private_original_message.message)+ end+end