Restriction by installed plugin
availability_plugin
Availability condition (availability_plugin) that restricts activities, resources and sections depending on whether a given Moodle plugin (by frankenstyle name) is installed on the site. Includes a YUI form module with autocompletion of installed plugin names, offered only to users holding availability/plugin:addinstance.
No security or code-quality defects were found after reading all of the PHP, JavaScript, test and metadata files and checking them against Moodle 5.3 core.
- The user-supplied plugin name is escaped with
s()before it goes into the HTML condition description. In the YUI form it is escaped withY.Escape.html(). - The installed-plugin check uses core APIs (
core_component::normalize_component(),get_component_directory(),get_config()). These run no raw SQL and do no filesystem work on user input. - The list of installed plugins is sent to the browser only when
has_capability()passes for the editing context. - The Privacy API is implemented correctly as a null provider, and unit and Behat tests cover the main behaviour.
One behaviour remains: core does not re-check the capability at save time, so users who can already edit an activity can add the condition anyway. This comes from core's availability design, the README documents it clearly, and it only reveals low-sensitivity plugin inventory. It is recorded as a note rather than a finding.
availability_plugin is a very small availability condition, with three classes, a capability definition, a YUI form module and tests. It lets course editors show or hide content depending on whether a named Moodle plugin is installed on the site.
The security posture is clean. The only user-controlled value is the plugin name in the condition JSON. It is type-checked in the constructor, HTML-escaped with s() in get_description() and escaped with Y.Escape.html() in the YUI form. On the server it only ever reaches core lookup APIs (core_component and the cached get_config()), never SQL or filesystem calls. The autocompletion list of installed plugins is only sent to users who pass the availability/plugin:addinstance check.
There are no findings. One design point is worth knowing, and the plugin's README already states it: the capability only controls the editor UI. An editing teacher could still submit the condition by changing the form JSON and use it to work out whether a particular plugin is installed. This is a core architectural limitation with low-sensitivity impact.
Findings
Capability is UI-only, as documented. In core, core_availability\tree::__construct() creates any enabled condition type found in the submitted JSON and does no per-plugin capability check. This means availability/plugin:addinstance does not stop a user who can already edit an activity or section from adding this condition through edited form data. They could then use it, for example via Switch role to student, to test whether a named plugin is installed. The README says this explicitly. The impact is limited to disclosing the plugin inventory, which is largely visible through other course-editing UIs anyway.
User-list semantics. The condition does not override is_applied_to_user_lists(), so core ignores it when it filters user lists (e.g. for notifications and grading lists). Because the result does not depend on the user, this is a reasonable design choice, and it matches how core's own date condition behaves. Site admins should still know that unmet conditions of this type do not remove users from those lists.