Skip to content

Conversation

@drgrice1
Copy link
Member

@drgrice1 drgrice1 commented Jul 3, 2025

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.

I am suggesting this as a hotfix since this affects webwork 2.19 and was introduced in the version of webwork2. So we might as well fix this for all affected versions since that is as far back as this goes.

@drgrice1 drgrice1 changed the title Fix a potential XSS vulnerability in the past answers table (the Answer Log). Fix a potential XSS vulnerability in the past answers table (the Answer Log). (hotfix) Jul 3, 2025
taniwallach
taniwallach previously approved these changes Jul 3, 2025
Copy link
Member

@taniwallach taniwallach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the change in the WW 2.20 branch, and it fixes the XSS issue and handles the special delimiter nicely.
I do think the hotfix is warranted.

…er 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 openwebwork#1899 to make the special character `&openwebwork#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 openwebwork#1899.
@pstaabp pstaabp merged commit 8fe7336 into openwebwork:main Jul 8, 2025
2 checks passed
@drgrice1 drgrice1 deleted the past-answer-xss-hotfix branch July 8, 2025 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants