Skip to content

Commit 32f91e4

Browse files
committed
Fix XSS vulnerability in the list view
Refs. GHSA-8qgm-g2vv-vwvc
1 parent 4e7bd09 commit 32f91e4

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

.rubocop_todo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Lint/ReturnInVoidContext:
2121
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
2222
# IgnoredMethods: refine
2323
Metrics/BlockLength:
24-
Max: 1097
24+
Max: 1107
2525

2626
# Offense count: 1
2727
# Configuration parameters: Max, CountKeywordArgs.

app/views/rails_admin/main/index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
<% end %>
134134
<% properties.map{ |property| property.bind(:object, object) }.each do |property| %>
135135
<% value = property.pretty_value %>
136-
<td class="<%= [property.sticky? && 'sticky', property.css_class, property.type_css_class].select(&:present?).join(' ') %>" title="<%= strip_tags(value.to_s) %>">
136+
<td class="<%= [property.sticky? && 'sticky', property.css_class, property.type_css_class].select(&:present?).join(' ') %>" title="<%= value %>">
137137
<%= value %>
138138
</td>
139139
<% end %>

spec/integration/actions/index_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,18 @@
674674
visit index_path(model_name: 'team')
675675
expect(find('tbody tr:nth-child(1) td:nth-child(4)')).to have_content(@players.sort_by(&:id).collect(&:name).join(', '))
676676
end
677+
678+
it 'does not allow XSS for title attribute' do
679+
RailsAdmin.config Team do
680+
list do
681+
field :name
682+
end
683+
end
684+
@team = FactoryBot.create :team, name: '" onclick="alert()" "'
685+
visit index_path(model_name: 'team')
686+
expect(find('tbody tr:nth-child(1) td:nth-child(2)')['onclick']).to be_nil
687+
expect(find('tbody tr:nth-child(1) td:nth-child(2)')['title']).to eq '" onclick="alert()" "'
688+
end
677689
end
678690

679691
context 'when no record exists' do

0 commit comments

Comments
 (0)