Skip to content

Commit adb2c3f

Browse files
committed
Fix a potential XSS vulnerability in the past answers table (the Answer Log).
If MathQuill is enabled and a student types `"<script>alert(1);</script>` and submits the answer, then that script is executed if an instructor views the answer on the past answers page. If MathQuill is not enabled, and a student simply enters `<script>alert(1);</script>` the same thing happens. This is due to a change in #1899 to make the special character `&#1970;` used to separate array answers (usually coming from checkbox answers) display correctly. To fix this better handling of answers with that character is needed. So this splits the student answers on that character, and now DOES html escape all other parts of the student answer again, but directly inserts the `&#9070` characters without escaping. The effect is that answers will still be displayed the same as they were before other than scripts in the answer. Those will now actually appear as text. Note that is the same as it would have been before #1899.
1 parent ecc90a6 commit adb2c3f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

templates/ContentGenerator/Instructor/ShowAnswers/past-answers-table.html.ep

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@
5353
% if ($answer eq '') {
5454
<small><i><%= maketext('empty') %></i></small>
5555
% } else {
56-
<%== $answer =%>
56+
% my @parts = split("&#9070;", $answer);
57+
% for (0 .. $#parts - 1) {
58+
<%= $parts[$_] =%>&#9070;\
59+
% }
60+
<%= $parts[-1] =%>
5761
% }
5862
</td>
5963
% }

0 commit comments

Comments
 (0)