Path
Home / Security / CVE-2024-38276
Class
Cross-site request forgery (CSRF)
Published
19 Jun 2024
Severity
Serious

CVE-2024-38276: CSRF through misused confirm_sesskey() in Moodle

In several places Moodle checked the CSRF token but discarded the result. A third-party web page could trigger actions on behalf of logged-in users.

1Summary

Advisory
MSA-24-0024
System
Moodle
Component
Course download, LTI tools, MoodleNet import, assignment (core_course, enrol_lti, tool_moodlenet, mod_assign)
Class
Cross-site request forgery (CSRF)
Severity
Serious

Moodle protects state-changing actions with a session key, the sesskey. There are two functions to check it: require_sesskey() stops on a missing or wrong key, confirm_sesskey() only returns true or false and leaves the decision to the caller.

In several places confirm_sesskey() stood alone on a line and its result was never used. The check ran but had no effect. Affected were the course content download, the configuration of LTI tools, the MoodleNet import and the fix for rescaled grades in the assignment activity.

Reported by Vincent Schneider through the Moodle security process, published as MSA-24-0024.

2Who is affected

Logged-in users who open a prepared page. The action runs with their permissions.

An attack needs a prepared web page and a person who opens it while logged in to Moodle. Their browser sends the session cookie along, and Moodle takes the request for their own.

What can be triggered this way depends on that person's permissions in Moodle.

3Impact

Depending on the place, a third-party page could start an import from MoodleNet into a course, configure an LTI tool, start a download of course content or have an assignment's grades recalculated.

4Fix

Affected versions
4.4.0, 4.3.0 to 4.3.4, 4.2.0 to 4.2.7, 4.1.10 and earlier
Fixed in
4.4.1, 4.3.5, 4.2.8, 4.1.11
Published
19 Jun 2024
Fix in the source
40b2fb9, db2f97a

Where confirm_sesskey() used to be called without consequence, the code now uses require_sesskey() or evaluates the result. Without a valid key, Moodle stops the action.

If you maintain your own plugins, search for confirm_sesskey() calls whose return value nobody checks. The same mistake creeps back in easily when new pages are written.

We check for this class of flaw in every project we build or audit. For third-party code as a security audit.

5 / Contact

Should we review your Moodle plugins?

Describe your project in three short steps. We usually reply within one business day.