/

CVE-2026-30884

Severity:

CRITICAL RISK

(9.6)

Insecure Direct Object Reference in Moodle Custom

CVE-2026-30884

Deferred

Vulnerability type

Category:

Insecure Direct Object Reference

CWE:

CWE-639

Impact:

Cross-Context Data Disclosure and Tampering

Severity:

CRITICAL RISK

(9.6)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

The Moodle Custom Certificate plugin contains an insecure direct object reference that lets a teacher with mod/customcert:manage capability in any one course read and overwrite certificate elements from other courses.

By passing arbitrary element IDs to specific callbacks and web services, an attacker can silently access or tamper with certificates outside their authorized course context, leading to cross-course information disclosure and data integrity violations.

Affected context

This vulnerability occurs in Moodle installations using the Custom Certificate (moodle-mod_customcert) plugin where:

  • Teachers are granted the mod/customcert:manage capability in at least one course
  • The core_get_fragment callback editelement and mod_customcert_save_element web service are exposed as part of normal plugin operation
  • Backend logic assumes that a valid element ID is sufficient to authorize access, without confirming that the element belongs to the teacher's current course context

In such setups, any user with manage permissions for certificates in one course may be able to interact with certificate elements belonging to other courses.

Exploit preconditions

  • Attack surface: Moodle web UI and web service endpoints exposed by the Custom Certificate plugin.
  • Required access: An authenticated user with the mod/customcert:manage capability in at least one course.
  • Trigger point:
  • Invoking the editelement core_get_fragment callback while supplying an elementid from another course.
  • Calling the mod_customcert_save_element web service with an elementid that belongs to a different course.
  • Why exploitation is possible: The server-side handlers trust the provided elementid and do not enforce that it belongs to the course context in which the user is authorized. As a result, authorization is checked only at the capability level and not bound to the specific resource, creating an insecure direct object reference (CWE-639).

Why this happens

The core bug is a missing contextual authorization check on resource identifiers (certificate element IDs) in server-side logic.

Instead of confirming that the elementid being accessed or modified belongs to a course where the user holds the relevant capability, the code treats any valid elementid as accessible once the user has mod/customcert:manage somewhere.

This maps directly to CWE-639: Authorization Bypass Through User-Controlled Key, where object-level access control is tied to a user-supplied identifier without verifying that the object resides in a context the user is permitted to access.

The abstract pattern is: "Check who the user is and what general role they have, but fail to check which specific object they are trying to access."

Potential impact

  • A teacher may read certificate element configuration from courses they are not assigned to.
  • Certificate layouts, text, and other element data in unrelated courses can be silently overwritten.
  • Cross-course leakage of sensitive or exam-related certificate content may occur.
  • Integrity of certificates across the Moodle site can be compromised, undermining trust in issued credentials.
  • Administrative overhead due to undetected or difficult-to-trace certificate modifications in multiple courses.

General mitigation guidance

Effective mitigation focuses on enforcing strict object-level authorization and reducing reliance on user-controlled identifiers:

  • Ensure every access to a certificate element first resolves it in a context-bound way (e.g., load element, then verify it belongs to a course where the user holds the required capability before proceeding).
  • Centralize authorization checks for plugin entities so all read/write operations go through a single, well-reviewed access-control layer.
  • Avoid treating numeric or opaque IDs from the client as sufficient evidence of access; always re-derive the relevant context (course, module instance) on the server.
  • Prefer design patterns where the course or module context is derived from the session or URL structure and used to constrain the set of valid resource IDs.
  • Apply the principle of least privilege to Moodle roles and capabilities, granting mod/customcert:manage only where necessary and auditing its use regularly.

How teams detect issues like this

Organizations can detect and monitor for similar authorization weaknesses through:

  • Static analysis: Rules that flag controller or web-service functions which:
  • Accept object IDs (elementid, id, etc.) from clients.
  • Perform read/write actions on those objects without verifying their association with a context where the user has explicit capability.
  • Code review patterns: During plugin or customization reviews, look for:
  • Direct database lookups by ID followed immediately by business logic without subsequent context checks.
  • Access control that only checks roles or capabilities at a high level, not tied to the specific course or module instance.
  • Runtime monitoring: Log and periodically review cross-course access patterns such as:
  • A single user editing certificate elements associated with many unrelated courses.
  • Anomalous spikes in updates to certificate elements across courses.
  • Automated policy enforcement: Incorporate Moodle-specific security linting or general authorization-check patterns into CI pipelines so newly introduced handlers and web services are checked for object-level access control.

Sources

SourceLink
github.comgithub.com/mdjnelson/moodle-mod_customcert/commit/a1494a80fb953f187f7888a7394cbf9d13c28468
github.comgithub.com/mdjnelson/moodle-mod_customcert/commit/ddc8f01f1e19fb61202f6013a38ef757486d3ba0
github.comgithub.com/mdjnelson/moodle-mod_customcert/security/advisories/GHSA-8pjr-j7r4-ccjx

Frequently asked

questions

It is exploitable remotely through the Moodle web interface or web services, but only by authenticated users who already have the mod/customcert:manage capability in at least one course. Anonymous users cannot exploit this issue directly.

The attacker must be a legitimate user (typically a teacher or staff member) with permission to manage custom certificates in at least one course. From there, they can target certificate elements associated with other courses by manipulating the elementid parameter.

The robust fix pattern is to enforce object-level authorization: whenever a certificate element is loaded by ID, resolve its parent context (course, module instance) on the server and verify that the current user holds the appropriate capability in that exact context before allowing read or write operations.

Design APIs so that:

  • Context (course, module) is always derived server-side and used to scope object queries.
  • Capability checks are tied to specific instances and entities rather than global role checks.
  • Any endpoint using user-supplied IDs undergoes targeted security review focusing on CWE-639 and broken access control patterns, supported by automated checks in CI where possible.
Find out what's already
exploitable in your codebase.