🎨 StudioLMS - Course Designer
tiny_studiolms
TinyMCE editor plugin ("StudioLMS") that opens a canvas composer where teachers build styled content blocks (callouts, cards, accordions, tabs, tables, charts, infographics, widget markers). It also offers ready-made layouts, a personal and site-wide template library with favourites and JSON import/export, and AI generation of blocks and layouts through local_aihub or Moodle core_ai.
No exploitable security vulnerability was found. All 18 web services validate parameters, call validate_context() and require_capability('tiny/studiolms:use') against the editor's own context. Global-template operations also require tiny/studiolms:manageglobaltemplates at system context, and that capability carries RISK_XSS. Template visibility (own, global, favourites) is enforced in SQL on read, favourite and export, and every query uses placeholders.
On the client, stored template HTML is shown only in a fully sandboxed srcdoc iframe. Before it reaches the canvas it passes through a DOMParser-based sanitiser and a schema-driven data-slms-state restore. Rich fields are re-read from the sanitised DOM, URL fields are checked against an allow-list, and AI output is purified server-side with PARAM_CLEANHTML and again client-side.
The findings are all low severity:
- unbounded table dimensions read from block state can hang the editing teacher's browser tab
- a resize-listener leak in the student-facing frontend module
- a few hard-coded English strings
- AI features gated only by the general use capability, with no throttling
None of them lets one user affect another user's data or session.
tiny_studiolms is a large TinyMCE plugin: about 7,000 lines of PHP, 10,000 lines of AMD JavaScript and 80 Mustache templates. It provides a block composer, a template library (personal, official, favourites, JSON import/export) and AI generation through local_aihub or Moodle core_ai. It ships no third-party libraries, has a full Privacy API provider, and has broad PHPUnit, Behat and headless JS test coverage.
The security posture is strong. Every web service checks the editor's own context and the plugin capability. Publishing, deleting and exporting official templates is tied to a system-level capability flagged RISK_XSS. Private templates cannot be read through favourites or export, and all SQL uses placeholders. On the client, stored template HTML is previewed only in a sandboxed iframe. It is sanitised before it touches the live DOM, and block state attributes are rebuilt against each block's own schema, so injected keys or markup are dropped. AI responses are purified on the server and again in the browser.
No finding reaches medium severity. The most useful fix is to clamp the table block's rows/cols: a crafted data-slms-state in content a teacher later opens in the composer can freeze their browser tab. The other items are minor robustness, localisation and AI-governance points, listed below.
Findings
The table block's renderHtml() takes rows and cols from the block data with only a lower bound (Math.max(2, …) / Math.max(1, …)) and builds one cell object per row × column. The popup limits input to 10 columns and 50 rows, but the same data also comes from data-slms-state (via StateManager.restore(), which only checks the type is a number) and from AI-generated configs. extractDOM() overrides rows/cols only when the table has at least one row. A table element with no rows and a state of rows: 100000000 therefore makes the composer loop until the tab freezes or runs out of memory.
Low risk. The only effect is a client-side denial of service in the editing teacher's own tab, with possible loss of unsaved work. It needs the victim to open the crafted block in the composer, and it exposes no data and changes nothing on the server.
When the composer opens on an existing block, it restores that block's state from the data-slms-state attribute and redraws the block with renderHtml(). Saved templates and AI-generated configs take the same path.
const numRows = Math.max(2, parseInt(data.rows) || 4);
const numCols = Math.max(1, parseInt(data.cols) || 3);
Clamp both values to the limits the setup popup already uses:
const numRows = Math.min(50, Math.max(2, parseInt(data.rows, 10) || 4));
const numCols = Math.min(10, Math.max(1, parseInt(data.cols, 10) || 3));
focusScrollableTables() registers a window resize listener each time it runs. initIn() calls it for the initial document and again for every node in each filterContentUpdated event. In course editing mode that event fires whenever an activity is moved, shown or hidden. The listeners are never removed and each keeps its root node alive, so they pile up and every resize re-queries all the old roots. This module loads on every page for every user.
Low risk. This is a memory and performance leak on long-lived course editing pages. It has no security impact.
init() runs on every page through the before_footer_html_generation hook. It wires StudioLMS blocks found in the document and in any content core announces through filterContentUpdated.
update();
window.addEventListener('resize', update);
Register one listener at module level that re-checks every .studiolms-table-wrap in document, and have initIn() only run the immediate check on the new root. Alternatively, use a ResizeObserver per table wrap, guarded by a data- flag so each wrap is observed only once.
Two user-visible strings bypass the language system. The core_ai provider label 'Moodle AI' is returned by chat_message and shown under every assistant reply in the chat tab (aichat.js sets it as the label text). The AI generator panel also falls back to 'Error. Please try again.' when the translated error string cannot be loaded. Both should come from lang/en/tiny_studiolms.php, as the rest of the plugin's UI text does.
Low risk. This is a localisation defect only.
Everything else in the plugin's UI, including the AI error messages raised as moodle_exception, is translated. The PT-BR language pack shipped with the plugin is used in every other place.
$failure = ['success' => false, 'data' => '', 'provider' => 'Moodle AI', 'message' => '', 'attempted' => true];
Use a language string, for example get_string('provider_coreai', 'tiny_studiolms'), here and on line 184.
msg = 'Error. Please try again.';
Fall back to a core string such as getString('error', 'core'), or omit the fallback and let Notification.exception() handle the failure.
All ten AI web services (generate_*, chat_message) require only tiny/studiolms:use. That is the same capability that shows the editor button. The services then call core_ai\manager::process_action() directly. Core's own editor placement checks aiplacement/editor:generate_text and whether the placement is enabled (aiplacement_editor\utils::is_html_editor_placement_action_available()). process_action() itself checks neither, so a site that removed that core capability from teachers to restrict AI use still lets them use StudioLMS's AI tabs. The plugin does honour the course or module AI override (is_action_enabled_in_context). But it has no capability of its own for AI and no request limit, so an admin cannot keep the composer while turning off its AI features, and nothing stops repeated calls that run up provider costs.
Low risk. Only users who already hold the plugin capability can reach these services, and they send only their own text. The issue is a gap in admin control and cost governance, not a way to reach other users' data.
provider_chain::send() tries local_aihub first, then falls back to core_ai. The site's AI policy acceptance is enforced in the browser (ensureAiPolicy()), the same way core's own placements do it.
if (self::has_core_ai($context)) {
$coreresult = self::call_core_ai($system, $user, $context);
Add a dedicated capability, for example tiny/studiolms:useai (default for editingteacher/manager), and check it in provider_chain::has_ai() and in each AI web service before calling the provider chain. Consider simple per-user rate limiting as well (for example a MUC counter per minute).
require_capability('tiny/studiolms:use', $context);
Also check require_capability('tiny/studiolms:useai', $context); here and in the other nine generate_* services.
Soft dependency not available for review. When local_aihub is installed, all AI requests go through \local_aihub\ai::generate_text(), which also resolves personal and site API keys. That plugin is not in the core tree, so its outbound HTTP handling (client, TLS settings, redirects) could not be checked. StudioLMS itself makes no HTTP request and stores no key.
Optional companion filter. The Widgets tab only appears when filter_studiolms is installed with a matching widgets::CONTRACT. That filter was not available either. StudioLMS only writes plain-text markers such as [COURSEMAP current=progress] built from an allow-list, so its side of the contract is safe.
Every-page frontend module. hook_callbacks::before_footer_html_generation() loads tiny_studiolms/frontend on every page, including the login page and admin pages, for all users. The docblock explains why (accordions closed by the stylesheet must open anywhere a block can be saved), and the module exits early when the page has no block. Still worth knowing on performance-sensitive sites.
Author contact in the AI system prompt. chat::build_system_prompt() includes the author's name and e-mail address in every chat request sent to the AI provider. This is harmless but unusual. Some sites may prefer prompts that carry no personal data.