mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
SECURITY: XSS on chat excerpts
Non-markdown tags weren't being escaped in chat excerpts. This could be triggered by editing a chat message containing a tag (self XSS), or by replying to a chat message with a tag (XSS). Co-authored-by: Jan Cernik <jancernik12@gmail.com>
This commit is contained in:
@@ -189,6 +189,34 @@ RSpec.describe "Chat channel", type: :system, js: true do
|
||||
end
|
||||
end
|
||||
|
||||
context "when replying to message that has tags" do
|
||||
fab!(:other_user) { Fabricate(:user) }
|
||||
fab!(:message_2) do
|
||||
Fabricate(
|
||||
:chat_message,
|
||||
user: other_user,
|
||||
chat_channel: channel_1,
|
||||
message: "<mark>not marked</mark>",
|
||||
)
|
||||
end
|
||||
|
||||
before do
|
||||
Fabricate(:chat_message, user: other_user, chat_channel: channel_1)
|
||||
Fabricate(:chat_message, in_reply_to: message_2, user: current_user, chat_channel: channel_1)
|
||||
channel_1.add(other_user)
|
||||
channel_1.add(current_user)
|
||||
sign_in(current_user)
|
||||
end
|
||||
|
||||
it "escapes the reply-to line" do
|
||||
chat.visit_channel(channel_1)
|
||||
|
||||
expect(find(".chat-reply .chat-reply__excerpt")["innerHTML"].strip).to eq(
|
||||
"<mark>not marked</mark>",
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context "when messages are separated by a day" do
|
||||
before do
|
||||
Fabricate(:chat_message, chat_channel: channel_1, created_at: 2.days.ago)
|
||||
|
||||
Reference in New Issue
Block a user