CVE-2015-5336
Description
Multiple cross-site scripting (XSS) vulnerabilities in the survey module in Moodle through 2.6.11, 2.7.x before 2.7.11, 2.8.x before 2.8.9, and 2.9.x before 2.9.3 allow remote authenticated users to inject arbitrary web script or HTML by leveraging the student role and entering a crafted survey answer.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Moodle survey module allowed authenticated students to inject arbitrary web script via crafted survey answers, affecting multiple versions.
Vulnerability
The survey module in Moodle contains multiple cross-site scripting (XSS) vulnerabilities. The bug is present in the output rendering of user-supplied survey answer text, where values passed to $answertext, $answer1, and $answer2 are not properly sanitized before being displayed. An attacker with a student role can craft survey answers containing malicious HTML or JavaScript. Affected versions include Moodle through 2.6.11, 2.7.x before 2.7.11, 2.8.x before 2.8.9, and 2.9.x before 2.9.3 [1][3][4]. The fix introduced the s() function (which calls htmlspecialchars()) on the answer variables [3][4].
Exploitation
An attacker must be a remotely authenticated user with the student role in a Moodle course. The attacker submits a survey with a crafted answer containing arbitrary JavaScript or HTML in the answer text field. When the teacher or other user views the survey results (e.g., via report.php or survey_user_complete()), the malicious script executes in the context of the viewer's browser. No additional privileges beyond student role are required [1][3][4].
Impact
Successful exploitation allows the attacker to inject arbitrary web script or HTML, leading to potential information disclosure, session hijacking, or other client-side attacks against users viewing the survey results. The attack is stored XSS, as the payload is persisted within the Moodle database and triggered whenever the affected report page is loaded [1].
Mitigation
The vulnerability is fixed in Moodle versions 2.7.11, 2.8.9, 2.9.3, and later releases [1]. Administrators should upgrade to a patched version immediately. There is no known workaround provided in the available references. The fix commits apply the s() output escaping function to the answer variables in mod/survey/lib.php [3][4].
AI Insight generated on May 23, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
moodle/moodlePackagist | < 2.7.11 | 2.7.11 |
moodle/moodlePackagist | >= 2.8.0, < 2.8.9 | 2.8.9 |
moodle/moodlePackagist | >= 2.9.0, < 2.9.3 | 2.9.3 |
Affected products
26cpe:2.3:a:moodle:moodle:*:*:*:*:*:*:*:*+ 24 more
- cpe:2.3:a:moodle:moodle:*:*:*:*:*:*:*:*range: <=2.6.11
- cpe:2.3:a:moodle:moodle:2.7.0:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.7.1:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.7.10:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.7.2:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.7.3:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.7.4:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.7.5:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.7.6:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.7.7:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.7.8:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.7.9:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.8.0:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.8.1:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.8.2:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.8.3:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.8.4:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.8.5:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.8.6:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.8.7:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.8.8:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.9.0:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.9.1:*:*:*:*:*:*:*
- cpe:2.3:a:moodle:moodle:2.9.2:*:*:*:*:*:*:*
- (no CPE)range: <=2.6.11, <2.7.11, <2.8.9, <2.9.3
Patches
731d0bf81af07MDL-49940 mod_survey: Fix XSS on survey module
2 files changed · +2 −2
mod/survey/lib.php+1 −1 modified@@ -189,7 +189,7 @@ function survey_user_complete($course, $user, $mod, $survey) { } else { $answertext = "No answer"; } - $table->data[] = array("<b>$questiontext</b>", $answertext); + $table->data[] = array("<b>$questiontext</b>", s($answertext)); } echo html_writer::table($table);
mod/survey/report.php+1 −1 modified@@ -356,7 +356,7 @@ $OUTPUT->user_picture($a, array('courseid'=>$course->id)), "<a href=\"report.php?id=$id&action=student&student=$a->userid\">".fullname($a)."</a>", userdate($a->time), - $answer1, $answer2); + s($answer1), s($answer2)); } }
12c232df7688MDL-49940 mod_survey: Fix XSS on survey module
2 files changed · +2 −2
mod/survey/lib.php+1 −1 modified@@ -189,7 +189,7 @@ function survey_user_complete($course, $user, $mod, $survey) { } else { $answertext = "No answer"; } - $table->data[] = array("<b>$questiontext</b>", $answertext); + $table->data[] = array("<b>$questiontext</b>", s($answertext)); } echo html_writer::table($table);
mod/survey/report.php+1 −1 modified@@ -358,7 +358,7 @@ $OUTPUT->user_picture($a, array('courseid'=>$course->id)), "<a href=\"report.php?id=$id&action=student&student=$a->userid\">".fullname($a)."</a>", userdate($a->time), - $answer1, $answer2); + s($answer1), s($answer2)); } }
fd14d2902fabMDL-49940 mod_survey: Fix XSS on survey module
2 files changed · +2 −2
mod/survey/lib.php+1 −1 modified@@ -189,7 +189,7 @@ function survey_user_complete($course, $user, $mod, $survey) { } else { $answertext = "No answer"; } - $table->data[] = array("<b>$questiontext</b>", $answertext); + $table->data[] = array("<b>$questiontext</b>", s($answertext)); } echo html_writer::table($table);
mod/survey/report.php+1 −1 modified@@ -358,7 +358,7 @@ $OUTPUT->user_picture($a, array('courseid'=>$course->id)), "<a href=\"report.php?id=$id&action=student&student=$a->userid\">".fullname($a)."</a>", userdate($a->time), - $answer1, $answer2); + s($answer1), s($answer2)); } }
b4f4232e1cf7MDL-49940 mod_survey: Fix XSS on survey module
2 files changed · +2 −2
mod/survey/lib.php+1 −1 modified@@ -189,7 +189,7 @@ function survey_user_complete($course, $user, $mod, $survey) { } else { $answertext = "No answer"; } - $table->data[] = array("<b>$questiontext</b>", $answertext); + $table->data[] = array("<b>$questiontext</b>", s($answertext)); } echo html_writer::table($table);
mod/survey/report.php+1 −1 modified@@ -358,7 +358,7 @@ $OUTPUT->user_picture($a, array('courseid'=>$course->id)), "<a href=\"report.php?id=$id&action=student&student=$a->userid\">".fullname($a)."</a>", userdate($a->time), - $answer1, $answer2); + s($answer1), s($answer2)); } }
f03ec4ce85b3MDL-49940 mod_survey: Escape user comments
1 file changed · +1 −1
mod/survey/report.php+1 −1 modified@@ -303,7 +303,7 @@ foreach ($aaa as $a) { $contents .= "<tr>"; $contents .= '<td class="fullnamecell">'.fullname($a).'</td>'; - $contents .= '<td valign="top">'.$a->answer1.'</td>'; + $contents .= '<td valign="top">'.s($a->answer1).'</td>'; $contents .= "</tr>"; } }
48d8989f13a6MDL-49940 mod_survey: Escape user comments
1 file changed · +1 −1
mod/survey/report.php+1 −1 modified@@ -303,7 +303,7 @@ foreach ($aaa as $a) { $contents .= "<tr>"; $contents .= '<td class="fullnamecell">'.fullname($a).'</td>'; - $contents .= '<td valign="top">'.$a->answer1.'</td>'; + $contents .= '<td valign="top">'.s($a->answer1).'</td>'; $contents .= "</tr>"; } }
86cec86942c1MDL-49940 mod_survey: Escape user comments
1 file changed · +1 −1
mod/survey/report.php+1 −1 modified@@ -303,7 +303,7 @@ foreach ($aaa as $a) { $contents .= "<tr>"; $contents .= '<td class="fullnamecell">'.fullname($a).'</td>'; - $contents .= '<td valign="top">'.$a->answer1.'</td>'; + $contents .= '<td valign="top">'.s($a->answer1).'</td>'; $contents .= "</tr>"; } }
Vulnerability mechanics
Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
10- github.com/advisories/GHSA-grvw-qq2j-r898ghsaADVISORY
- moodle.org/mod/forum/discuss.phpnvdVendor AdvisoryWEB
- nvd.nist.gov/vuln/detail/CVE-2015-5336ghsaADVISORY
- github.com/moodle/moodle/commit/12c232df76885effa5ebac08e3094d6db5aa9223ghsaWEB
- github.com/moodle/moodle/commit/31d0bf81af079bc285ea439ac5160f9e45697c88ghsaWEB
- github.com/moodle/moodle/commit/48d8989f13a6320c54b05f7d3ea552356cf85ed6ghsaWEB
- github.com/moodle/moodle/commit/86cec86942c1cfcb92b840afd18deed9b9a34951ghsaWEB
- github.com/moodle/moodle/commit/b4f4232e1cf76334e4b8dda9cf68962b121e6bc0ghsaWEB
- github.com/moodle/moodle/commit/f03ec4ce85b3d361429d9f66dbbb478a353640c9ghsaWEB
- github.com/moodle/moodle/commit/fd14d2902fab15fa6affecc427bb11d3869d9afeghsaWEB
News mentions
0No linked articles in our index yet.