Summary
CI4MS prior to version 0.31.9.0 suffers from a stored cross-site scripting flaw in the Pages backend module, where user-supplied page content is saved and rendered without proper escaping.
Attackers who can create or edit pages can inject scripts that execute in every visitor's browser, including administrators, especially when the malicious page is promoted to the site's home page.
Affected context
This vulnerability appears in CI4MS deployments where the Pages backend module is used to manage front-end content.
The issue manifests when language-keyed page content is validated with html_purify but the un-purified POST data is persisted and later rendered via Home::index() and pages.php without esc().
It is most risky on sites where untrusted or semi-trusted users can author or edit pages, or where editorial workflows do not filter or review embedded HTML or script content.
Exploit preconditions
- Attack surface: Web application front-end, via publicly rendered pages managed by the Pages backend.
- Required access: Ability to submit or modify page content through the CI4MS administration or content-authoring interface (e.g., editor, compromised admin account, or abused integration).
- Trigger point: The vulnerable page is requested in a browser; the stored payload inside
$pageInfo->contentis emitted without escaping bypages.php. - Why exploitation is possible: The backend registers an
html_purifyvalidation rule but fails to store the purified value, and the public renderer outputs raw content withoutesc(), allowing arbitrary script execution in the client.
Why this happens
The underlying bug is a classic stored XSS pattern where untrusted input is accepted, insufficiently sanitized, and later rendered as HTML without contextual escaping.
In this case, validation rules suggest purification (html_purify), but the implementation persists the original, un-purified POST value to the database.
On the read path, Home::index() and app/Views/templates/default/pages.php emit $pageInfo->content directly, bypassing framework escaping helpers such as esc().
This maps to CWE-79: Improper Neutralization of Input During Web Page Generation, where user-controlled data is mixed into HTML output without neutralizing scripting constructs.
Potential impact
- Attacker-controlled JavaScript execution in visitors' browsers.
- Theft of session cookies and potential account takeover, including administrative accounts.
- Unauthorized actions performed on behalf of logged-in users (CSRF-like effects via XSS).
- Defacement of site content and injection of misleading or malicious UI elements.
- Distribution of malware or phishing content to all visitors, particularly if the payload is served from
/.
General mitigation guidance
Mitigation should focus on enforcing robust output encoding, aligning validation behavior with storage semantics, and constraining trust in page content.
Recommended defensive patterns include:
- Always applying context-aware output escaping (e.g., HTML, attribute, JavaScript) when rendering user-controlled content in views.
- Ensuring that any server-side purification or filtering rule (such as
html_purify) is applied to the data that is actually persisted, not merely validated. - Restricting which roles can author raw HTML content and separating fully trusted content from user-generated content.
- Implementing a defense-in-depth model where potentially active content (scripts, event handlers, inline JavaScript) is disallowed or stripped from editable page fields.
- Applying least-privilege principles to administrative accounts and content-authoring roles, reducing the blast radius of a compromised editor.
How teams detect issues like this
Detection commonly involves a mix of code inspection and automated checks aimed at identifying unescaped output in templates.
Useful strategies include:
- Static analysis rules that flag direct echoing of database-backed content without passing through escaping helpers or templating safeguards.
- Code review practices that treat any view variable originating from user input or CMS fields as untrusted and require explicit escaping.
- Pattern-based checks in CI pipelines looking for risky constructs such as
<?= $variable ?>in views instead of<?= esc($variable) ?>. - Security-focused tests that submit benign script payloads in page content and verify that they are neutralized or displayed as plain text in rendered output.
- Use of automated web scanners configured to probe CMS content fields for reflected and stored XSS behavior, followed by manual confirmation.

