The vulnerability stems from improper handling of file downloads in Moodle's file serving mechanism. The advisory explicitly states XSS occurred because attachments were opened in the current Moodle session instead of being forced to download. The send_stored_file function in Moodle's core file handling library (lib/filelib.php) is responsible for sending files with headers. The lack of forced download headers (Content-Disposition: attachment) for these specific attachments would allow HTML/JS files to execute in the victim's browser. This matches the XSS pattern described in CWE-79 and aligns with the security notice mentioning the fix involved forcing downloads for these attachments.