A platform for community discussion. Free, open, simple.
SECURITY: Stored XSS in staff action logs injects staff UI
Isaac Janzenfd44510b4303
diff --git a/frontend/discourse/admin/models/staff-action-log.js b/frontend/discourse/admin/models/staff-action-log.jsindex 4a323af4d1f..7f33f923593 100644--- a/frontend/discourse/admin/models/staff-action-log.js+++ b/frontend/discourse/admin/models/staff-action-log.js@@ -80,15 +80,9 @@ export default class StaffActionLog extends RestModel {];if (!this.useCustomModalForDetails) {+ lines.push(format("admin.logs.staff_actions.new_value", this.new_value));lines.push(- format("admin.logs.staff_actions.new_value", this.new_value, false)- );- lines.push(- format(- "admin.logs.staff_actions.previous_value",- this.previous_value,- false- )+ format("admin.logs.staff_actions.previous_value", this.previous_value));}diff --git a/spec/system/admin_staff_action_logs_spec.rb b/spec/system/admin_staff_action_logs_spec.rbindex ca9d7003677..d2c99eee742 100644--- a/spec/system/admin_staff_action_logs_spec.rb+++ b/spec/system/admin_staff_action_logs_spec.rb@@ -19,6 +19,16 @@ describe "Admin staff action logs" docustom_type: "update_flag",)end++ fab!(:history_with_html_value) do+ Fabricate(+ :user_history,+ action: UserHistory.actions[:change_name],+ previous_value: "Old name",+ new_value: %(<img src=x onerror="alert('xss')">),+ )+ end+let(:staff_action_logs_page) { PageObjects::Pages::AdminStaffActionLogs.new }before { sign_in(current_user) }@@ -37,6 +47,16 @@ describe "Admin staff action logs" do).and have_css("[data-link-topic-id='#{history_2.topic_id}']")end+ it "keeps staff action details as text" do+ visit "/admin/logs/staff_action_logs"++ expect(staff_action_logs_page).to have_no_injected_detail_element(history_with_html_value)+ expect(staff_action_logs_page).to have_details_text(+ history_with_html_value,+ %(<img src=x onerror="alert('xss')">),+ )+ end+it "can filter by type of action" dovisit "/admin/logs/staff_action_logs"diff --git a/spec/system/page_objects/pages/admin_staff_action_logs.rb b/spec/system/page_objects/pages/admin_staff_action_logs.rbindex a8f3809d554..d0ee171bf0f 100644--- a/spec/system/page_objects/pages/admin_staff_action_logs.rb+++ b/spec/system/page_objects/pages/admin_staff_action_logs.rb@@ -24,6 +24,14 @@ module PageObjectshas_no_css?(log_row_selector(user_history))end+ def has_no_injected_detail_element?(user_history)+ has_no_css?("#{log_row_selector(user_history)} .details img[onerror]")+ end++ def has_details_text?(user_history, text)+ has_css?("#{log_row_selector(user_history)} .details", text: text)+ end+def filter_by_action(action)filter = PageObjects::Components::SelectKit.new("#staff-action-logs-action-filter")filter.search(I18n.t("admin_js.admin.logs.staff_actions.actions.#{action}"))