Fix stored XSS in renderer (mdlshield finding) - #138
Open
marcusgreen wants to merge 1 commit into
Open
Conversation
Escape teacher-authored answer text before emitting it into HTML. Three paths in renderer.php rendered raw content to students: setup_answeroptions() draggable list and get_aftergap_text() right-answer display are now escaped with s(), and get_feedback() runs strip_tags output through clean_text() to remove event-handler attributes and javascript: URLs that strip_tags leaves on allowed tags. Add walkthrough regression tests asserting an <img onerror> payload is escaped in the draggable list and the after-gap right-answer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a stored XSS reported by the mdlshield automated review (HIGH severity). Teacher-authored gap content and correct-answer display text were concatenated into HTML in
renderer.phpwithout escaping, so a payload such as[<img src=x onerror=...>]executed in any student's browser.Three paths fixed:
setup_answeroptions()- draggable answer list now built withhtml_writer::tag+s().get_aftergap_text()- right-answer display now escaped withs().get_feedback()-strip_tagsleft event-handler attributes (onclick,onerror,javascript:hrefs) on allowed tags; the output now runs throughclean_text()which strips them.Tests: added two walkthrough regression tests asserting an
<img onerror>payload is escaped (raw payload absent,s()-escaped form present) in both the draggable list and the after-gap right-answer display. Full gapfill suite passes:walkthrough_test24/24, plusquestion_test,questiontype_test,backup_testgreen.