Vulnerability analysis
A stored cross-site scripting (XSS) vulnerability existed in Moodle's Feedback activity because user-supplied text was HTML-encoded on input but then decoded during rendering, allowing an attacker to inject malicious scripts. An authenticated student could exploit this to take over other users' accounts, including teachers and administrators, and potentially trigger a blind server-side request forgery (SSRF) to interact with internal services.
When managing a course in Moodle, it's possible to add a 'Feedback' activity. This activity-type allows enrolled students to provide feedback to different questions created by the teacher.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the input sanitisation used HTML entity encoding, but the rendering process decoded those entities, effectively undoing the protection and allowing stored XSS.
Impact
An authenticated attacker with the least privilege (student) could inject HTML/JavaScript via a crafted feedback response, leading to stored XSS and blind SSRF; successful exploitation could allow takeover of Moodle users including teachers and administrators, or perform actions on their behalf, and the SSRF could enable interaction with internal services and possibly RCE in some setups.
What the attacker needed
Authenticated as a student; access to a Feedback activity
The fix
The vulnerability was fixed in a new release.
How it was found
- A student submits a feedback text answer containing HTML entities that encode a malicious script.
- The input is processed with the s() function, which HTML-encodes characters, but the entities remain encoded.
- The answer is stored in the database.
- When the feedback response is rendered, the stored value is passed through html_entity_decode, converting the entities back to executable HTML/JavaScript.
- The malicious script executes in the browser of anyone viewing the feedback, such as a teacher or administrator.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
When a student submits feedback in Moodle, the text is supposed to be made safe by converting special characters like '<' into harmless codes. However, the system later converted those codes back into real characters when displaying the feedback, so a malicious student could sneak in a script that runs in other users' browsers. This script could then steal accounts or make the server access internal resources.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.