HTMLPurifier to all input fields

HTMLPurifier to all input fields

av András Égler -
Antall svar: 2
Hi,

I'm testing my Moodle site (2.7.2) due to security reasons. There's a strange issue that I've found: the HTMLPurifier filter library is filtering some input fields, but doesn't filter some others. E.g.: I created a "Database" module and I added a new field. In "field description" input I could save a JS code and unfortunately if I'm checking this field I can see the XSS alert message.

Is it possible to filter ALL input fields in Moodle?

Thanks,
Andrew


Gjennomsnittlig vurdering: -
Som svar til András Égler

Re: HTMLPurifier to all input fields

av Davo Smith -
Bilde av Core developers Bilde av Peer reviewers Bilde av Plugin developers

This first thing to check is if the javascript is being allowed via the 'trustcontent' capability ( https://docs.moodle.org/en/Capabilities/moodle/site:trustcontent ). This is specifically to allow trusted users to add javascript (and any other potentially unsafe content) to text areas within Moodle (see the above link for one situation in which this is desirable).

It is, however, entirely possible that this is a text area that has just been missed in terms of being cleaned at all. In which case, it should be reported as a bug in Moodle tracker.

Som svar til Davo Smith

Re: HTMLPurifier to all input fields

av Tim Hunt -
Bilde av Core developers Bilde av Documentation writers Bilde av Particularly helpful Moodlers Bilde av Peer reviewers Bilde av Plugin developers

trustcontent is not the only mechanism.

Generally speaking, anywhere in Moodle where only teachers can input content, JavaScript is allowed through on the grounds that

  1. There are useful educational things you can do using snippets of JavaScript; and
  2. you trust your teachers.

It is a compromise, but a reasonable one.

Of course, in Moodle there is not necessarily any such thing as a 'Teacher' becuase roles can be re-defined. On the define roles page, you will see 'risk' icons next to each capability. One of those icons is 'Risk XSS'. It is the 'Risk XSS' capabilities that let you input JavaScript.

Gjennomsnittlig vurdering:Useful (1)