IgniteCore closes the security gap between end-of-life CodeIgniter 3.1.11 and modern CodeIgniter 4.7.6 inside Perfex CRM without rewriting legacy modules or breaking staff sessions. By running an isolated CI4 runtime behind a pre-boot dispatcher and 7 shared-state bridges, it combines CI4 strict typing, Laminas\Escaper, and timing-safe CSRF checks with native tblsessions single sign-on and tblstaff_permissions RBAC enforcement.
Why Perfex CRM Security Demands More Than Core Patches
Perfex CRM Classic runs on CodeIgniter 3.1.11, a framework whose official maintenance stopped after PHP 8.1. Production installations continue receiving application-level fixes from the Perfex team, yet the underlying CI3 kernel still carries architectural trade-offs inherited from an earlier PHP era.
Three core security characteristics define stock CI3 in Perfex CRM:
- Heuristic Input Filtering Over Contextual Escaping: CI3 relies heavily on
xss_clean(), a regex-based blacklist filter designed to strip suspicious tags on input rather than encoding output per HTML, attribute, JavaScript, or URL context. - No Strict Scalar Typing: Without
declare(strict_types=1)across controllers, libraries, and models, loose type coercion can silently turn malformed query parameters or null inputs into unexpected array or integer values on PHP 8.2+. - Historical Cookie and Serialization Surface: Older CI3 session and autologin patterns required manual hardening against serialized cookie payloads and timing-attack exposure when comparing security tokens.
At the same time, ripping out CI3 for a standalone CodeIgniter 4 rewrite creates a different security problem: a disconnected runtime loses direct parity with Perfex tblsessions, tblstaff_permissions, config/csrf_exclude_uris.php, and established webhook endpoints. Teams end up maintaining duplicate login cookies or custom JWT glue that widens the attack surface.
3-Way Security Comparison: Perfex CI3 vs Standalone CI4 vs IgniteCore Bridge
Evaluating security requires comparing what happens inside the framework, across HTTP boundaries, and at the server filesystem layer.
8-dimension security comparison across Perfex CI3, standalone CI4 rewrite, and IgniteCore
|
Security Dimension
|
Perfex CRM CI3 (3.1.11)
CI3 3.1.11
|
Standalone CI4 Rewrite
Custom Rewrite
|
IgniteCore Intermediate Bridge (CI4 4.7.6 + CI3)
0 Critical / 0 High
CI4 4.7.6 + CI3
|
|---|---|---|---|
| Framework Lifecycle | End-of-life upstream (official cap PHP 8.1) | Active CI4 4.x lifecycle (PHP 8.2-8.4) | Active CI4 4.7.6 on modern routes; CI3 isolated for legacy fallback |
| Type Safety & Escaping |
Dynamic types; heuristic xss_clean()
|
declare(strict_types=1) + Laminas\Escaper + prepared statements
|
declare(strict_types=1) + Laminas\Escaper + prepared statements on CI4 routes
|
| Session & SSO Parity |
Native tblsessions (INT(10) UNIX timestamp)
|
Separate CI4 session store (breaks Perfex SSO) |
PerfexDatabaseSessionHandler (idPrefix = '', INT(10) time()) + FileHandler parity
|
| CSRF Protection | Legacy CI3 CSRF cookie and token checks | Native CI4 CSRF (incompatible cookie/tab behavior with CI3) |
PerfexCsrfFilter (hash_equals(), regenerate = false, 419 AJAX, csrf_exclude_uris.php)
|
| Staff RBAC Enforcement |
has_permission() / staff_can() in CI3 controllers
|
Must rebuild user roles and ACL tables from scratch |
staffCan filter enforces tblstaff_permissions on probe_ci4, probe_csrf, bench_ci4
|
| Telemetry Exposure (CWE-200) | Depends on custom module hygiene | Standard environment flags only |
Redacts DB driver, versions, and module counts on /ignite/api/v1/health in production
|
| CLI & Direct Access Guards |
defined('BASEPATH') in module files
|
spark + public/ webroot isolation
|
PHP_SAPI!== 'cli' in spark, guarded *.orig.bak.php, 33 index.html guards, Nginx deny block
|
| Static Security Audit | Legacy patterns trigger PHP 8.2+ and audit warnings | Clean on new code if audited properly |
Verified 0 critical / 0 high findings under heraspec audit --security
|
sequenceDiagram
actor Client as Browser / API Client
participant Disp as Pre-Boot Dispatcher
participant Filter as PerfexCsrfFilter + staffAuth
participant Sess as PerfexDatabaseSessionHandler
participant Ctrl as CI4 Dual-Mode Controller
participant Outbox as tblignite_core_event_outbox
participant Cron as Perfex CI3 Cron (after_cron_run)
Client->>Disp: HTTP POST/GET + sp_session + csrf_cookie
Disp->>Filter: Dispatch Pure CI4 4.7.6 Request
Filter->>Sess: Read Raw Session ID in tblsessions (INT 10 UNIX)
Sess-->>Filter: Authenticated Staff/Client + RBAC Verified
Filter->>Filter: Validate hash_equals() CSRF & Release Lock (sessionReadOnly)
Filter->>Ctrl: Execute Strict-Typed PSR-4 Controller
Ctrl->>Outbox: Queue Domain Event (Non-Blocking)
Ctrl-->>Client: JSON/HTML Response (X-IgniteCore-Kernel: CI4-4.7.6)
Cron->>Outbox: Relay Pending Events (Batch <= 50, Retries < 5)
Cron->>Cron: Execute Legacy CI3 hooks()->do_action()
Deep-Dive: How IgniteCore Bridges Sessions, CSRF, and RBAC Without Drift
1. Single Sign-On Parity with PerfexDatabaseSessionHandler
A dual-kernel architecture fails immediately if logging into /admin under CI3 does not authenticate requests routed to /admin/ignite_core/... under CI4. CodeIgniter 4's stock database session handler expects a TIMESTAMP or DATETIME column and prefixes session IDs with keys like ci_session:. Perfex CRM's tblsessions table uses a raw unprefixed id string and stores timestamp as INT(10) unsigned UNIX epoch seconds.
PerfexDatabaseSessionHandler resolves both mismatches cleanly:
- Sets
idPrefix = ''so CI4 reads and writes the exactsp_sessionidentifier created by Perfex CI3. - Uses UNIX
time()integer values matchingINT(10)intblsessionsrather than formatted datetime strings. - Mirrors
FileHandlerbehavior when a Perfex installation runs file-based sessions instead of database sessions, preserving identical staff and client login state across both kernels.
2. Timing-Safe Validation in PerfexCsrfFilter
Multi-tab CRM workflows break when one kernel rotates a CSRF cookie on every POST request while an adjacent CI3 tab still holds the previous token. PerfexCsrfFilter bridges CI4 HTTP filters with Perfex CRM's exact CSRF contract:
- Timing-Safe Verification: Token validation runs through PHP
hash_equals()rather than loose string equality, preventing timing side-channel leaks. - Cookie, Form, and Header Alignment: Reads and validates
csrf_cookie_name,csrf_token_name, and theX-CSRF-TOKENheader seamlessly for both standard HTML forms and modernfetch()/ AJAX calls. - Concurrent Tab Stability (
regenerate = false): Keeps the active session token valid across concurrent CI3 browser tabs so staff editing an invoice in CI3 and opening a CI4 analytics tab never hit false token rejections. - Legacy Exclusion Inheritance: Automatically inherits Perfex's
config/csrf_exclude_uris.phprules so existing payment gateway callbacks and external webhooks continue working. - Explicit AJAX Failure Status: Returns HTTP
419on CSRF mismatch for AJAX requests instead of ambiguous redirects, making client-side error handling predictable.
3. staffCan RBAC Parity on Privileged Diagnostics
Authentication (staffAuth) alone is not authorization. A logged-in staff member without administrative privileges should never execute runtime probes or latency benchmarks. IgniteCore attaches the staffCan route filter directly against Perfex's tblstaff_permissions matrix. Administrative CI4 endpoints such as probe_ci4, probe_csrf, and bench_ci4 verify capability grants before the controller executes, enforcing identical least-privilege boundaries across CI3 and CI4.
Server-Level Hardening: CWE-200, CLI Guards, and Web Server Rules
Modern module security extends well beyond PHP controller filters. Because Perfex modules live inside the web-accessible /modules/ directory rather than outside public/, server and filesystem hardening are mandatory.
- Production CWE-200 Redaction on
/ignite/api/v1/health: Health endpoints are vital for uptime monitors, yet exposing PHP versions, database drivers, or active module counts to anonymous callers leaks reconnaissance data (CWE-200). WhenENVIRONMENTisproduction, IgniteCore redacts sensitive runtime details from/ignite/api/v1/health, returning minimal operational status unless an authorized diagnostic context requests detail. - Strict
PHP_SAPI !== 'cli'Guard inspark: CodeIgniter 4 includes thesparkCLI runner for commands likeignite:doctorandignite:manifest. IgniteCore enforces an explicitPHP_SAPI !== 'cli'exit guard insidesparkso any misconfigured web server attempting to executesparkover HTTP terminates immediately. - Guarded Entry Backups (
*.orig.bak.php): When IgniteCore installs its 3-lineindex.phpmarker mode, the original rootindex.phpis backed up safely with a.orig.bak.phpartifact protected by direct-access PHP guards, preventing unauthenticated browsing or accidental execution of backup files. - 33
index.htmlDirectory Guards: Every subdirectory withinmodules/ignite_core/includes a silentindex.htmlguard file to block Apache or OpenLiteSpeed directory indexing even whenOptions -Indexesis missing from virtual host configuration. - Nginx Hardening Rule: Because Nginx does not evaluate
.htaccessfiles inside module folders, IgniteCore ships an explicit Nginx location block to deny direct HTTP access to internal runtime trees, the boot shim, and the CLI binary:
location ~* ^/modules/ignite_core/(runtime/|bootstrap/boot_ci4\.php|spark$) {
deny all;
return 403;
}
Combined with strict CI4 coding standards, these controls pass heraspec audit --security with 0 critical and 0 high findings.
Frequently Asked Questions
Does IgniteCore modify Perfex CRM core files to enforce CI4 security?
No. IgniteCore keeps Perfex core files intact under Zero Core Mutation principles. Security filters, session bridges, and RBAC checks operate inside modules/ignite_core/ and the pre-boot dispatcher layer.
Can legacy CI3 modules bypass PerfexCsrfFilter or staffCan?
Legacy CI3 modules continue executing inside Perfex's existing CI3 security layer, while every CI4 route registered through ignite/manifest.php passes through IgniteCore's 6 route filters (perfexCsrf, staffAuth, staffCan, clientAuth, apiAuth, sessionReadOnly).
Why does PerfexCsrfFilter set regenerate = false?
Perfex CRM users frequently work across multiple browser tabs simultaneously. Rotating the CSRF token on every CI4 request would invalidate open forms in adjacent CI3 tabs. Keeping regenerate = false while using hash_equals() and HTTP 419 preserves both timing-safe security and multi-tab usability.
What happens if an administrator runs Nginx instead of Apache or OpenLiteSpeed?
Nginx ignores .htaccess files, so administrators should apply the provided location ~* ^/modules/ignite_core/(runtime/|bootstrap/boot_ci4\.php|spark$) deny rule in their server block and use the 3-line index.php entry marker mode.
Related Guides
- IgniteCore for Perfex CRM Product Page
- Complete IgniteCore for Perfex CRM Runtime & Architecture Guide
- Benchmark Speed & RAM: CodeIgniter 3 vs CodeIgniter 4 on Perfex CRM
- Strangler Fig Architecture: How IgniteCore Bridges CI3 and CI4 in Perfex CRM
- Guide to Install and Configure IgniteCore for Perfex CRM
Need a Custom Perfex CRM Module, Bug Fix, or CodeIgniter 4 Upgrade?
Avoid broken updates, PHP 8.2-8.4 errors, and risky core edits. HeadRandom provides custom Perfex CRM module development, upgrade, and bug-fixing services for any third-party or custom module on your Perfex CRM installation, plus upgrading Perfex CRM from CodeIgniter 3 to CodeIgniter 4 via IgniteCore for Perfex CRM.
Develop new custom modules from scratch, patch bugs or hook conflicts on existing client modules, and update legacy code for clean PHP 8.2-8.4 compatibility with zero core file hacks. View Perfex CRM module development scope.
Migrate your Perfex CRM runtime to CodeIgniter 4 (4.7.6) using IgniteCore for Perfex CRM (independent module by HeadRandom) with Dual-Mode CI3 fallback, 32% to 75% lower latency, 50% less RAM, and custom CI4 porting for third-party modules. See CI3 to CI4 upgrade options.
Combine 2+ HeadRandom services (Custom Module, IgniteCore CI4 Upgrade, or Website Care) to save 30% automatically.