GHSA-8rh5-4mvx-xj7j: CI4MS Vulnerable to Post-Installation Re-entry via Cache-Dependent Install Guard Bypass
SummaryThe 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.DetailsThe `InstallFilter::before()` method at `modules/Install/Filters/InstallFilter.php:13` implements the install guard: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: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: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`copyEnvFile()` (line 70) overwrites the existing `.env` by copying from the `env` template`updateEnvSettings()` (line 70) writes attacker-controlled values including database hostnameNo database connection is needed — the `index()` action only performs filesystem operationsAdditionally, CSRF protection is explicitly disabled for all install routes in `modules/Install/Config/InstallConfig.php:7-10`: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.ImpactWhen 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 sessionsThe 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 FixReplace the volatile cache-based install guard with a persistent filesystem lock:Create the lock file at the end of successful installation in `Install::dbsetup()`:Additionally, add validation for the `host` parameter in `Install::index()`:
CVSS v3.1: 8.1