From c23ca0574ec1149993476632ffd66643aec6aac2 Mon Sep 17 00:00:00 2001 From: Jyri-Petteri Paloposki Date: Thu, 25 Jul 2024 14:53:04 +0300 Subject: [PATCH 1/2] Fix reflected XSS vulnerability on the stats page --- app/views/stats/show_selection_from_chart.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/stats/show_selection_from_chart.html.erb b/app/views/stats/show_selection_from_chart.html.erb index 29e9dfdbb..abe7f04b1 100644 --- a/app/views/stats/show_selection_from_chart.html.erb +++ b/app/views/stats/show_selection_from_chart.html.erb @@ -4,8 +4,8 @@ unless @further -%> <%= raw t('stats.click_to_show_actions_from_week', - :link => link_to("here", show_actions_from_chart_path(:id=>"#{params[:id]}_end", :index => params[:index])), - :week => params[:index]) + :link => link_to("here", show_actions_from_chart_path(:id=>"#{params[:id].to_i}_end", :index => params[:index].to_i)), + :week => params[:index].to_i) -%> <% end From b0d288d2efd0f8020d04ca95b8e0738a9eab6c51 Mon Sep 17 00:00:00 2001 From: Jyri-Petteri Paloposki Date: Thu, 25 Jul 2024 15:34:44 +0300 Subject: [PATCH 2/2] Fix reflected XSS vulnerabilities in some views --- app/controllers/todos_controller.rb | 6 ++++-- app/views/layouts/application.html.erb | 12 ++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index 1c852420e..05b7a95a8 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -863,8 +863,10 @@ def get_params_for_tag_view end @single_tag = @tag_expr.size == 1 && @tag_expr[0].size == 1 - @tag_name = @tag_expr[0][0] - @tag_title = @single_tag ? @tag_name : tag_title(@tag_expr) + + # These are used in the templates, sanitise to prevent XSS. + @tag_name = sanitize(@tag_expr[0][0]) + @tag_title = sanitize(@single_tag ? @tag_name : tag_title(@tag_expr)) end def filter_format_for_tag_view diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 31e5808e9..4640637a8 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -7,14 +7,14 @@ <%= javascript_include_tag "application" %> <%= csrf_meta_tags %>