Summary
OpenCATS prior to commit 3002a29 contains a PHP code injection flaw in the installer's AJAX endpoint that processes the databaseConnectivity action parameter without proper sanitization.
An unauthenticated attacker can inject PHP statements that are written into config.php, causing malicious code to persist and execute on every subsequent page load while the installation wizard remains incomplete.
Affected context
This vulnerability affects OpenCATS instances that are running the installation wizard and have not yet completed the setup process.
In this state, the installer AJAX endpoint accepts parameters such as databaseConnectivity and writes them into config.php within a define() string context.
Because user-controlled data is embedded into PHP source without robust escaping or validation, an attacker who can reach the installer endpoint over HTTP can influence the generated configuration file.
Exploit preconditions
- Attack surface: Public-facing or network-accessible OpenCATS installation wizard.
- Required access: No authentication is required; attacker only needs HTTP access to the installer AJAX endpoint.
- Trigger point: Submission of crafted input to the
databaseConnectivityaction parameter, which is then incorporated intoconfig.php. - Why exploitation is possible: The installer concatenates untrusted user input into a PHP
define()call inconfig.phpusing string delimiters without enforcing strict escaping or validation. By injecting a single quote and a statement terminator, the attacker breaks out of the string and appends arbitrary PHP code that will be evaluated on subsequent requests.
Why this happens
The core issue is direct embedding of untrusted input into executable PHP source during configuration generation.
The installer builds config.php by concatenating user-provided values into define() statements, assuming they are inert strings. This violates separation between data and code: when input is not correctly escaped or restricted, control characters like quotes and semicolons allow the injected content to escape the string context and introduce new PHP statements.
This behavior maps to CWE-94: Improper Control of Generation of Code (Code Injection), where dynamic code generation uses attacker-controlled data without adequate validation, escaping, or a safe templating mechanism.
Potential impact
- Execution of arbitrary PHP code with the privileges of the web server process.
- Installation of backdoors or web shells that persist across requests.
- Compromise of application data, including candidate records and user accounts.
- Lateral movement within the hosting environment or access to other applications on the same server.
- Abuse of the compromised server as a platform for further attacks or spam campaigns.
General mitigation guidance
Effective mitigation relies on eliminating direct code generation from untrusted input and constraining what configuration values are allowed:
- Use non-executable configuration formats (e.g., JSON, INI, or environment variables) instead of generating PHP code with user data.
- Where PHP-based config files must be used, treat user input as data only: ensure all values are strictly validated against expected patterns (e.g., hostnames, ports, booleans) and safely escaped before insertion.
- Avoid concatenating raw user input into PHP constructs; use fixed templates with placeholders and a minimal whitelist of allowed characters for each field.
- Restrict access to the installer endpoints so they are not exposed on production systems once installation is complete.
- Run the web server and application under least-privilege accounts and limit filesystem write permissions to reduce the blast radius of any misconfiguration.
How teams detect issues like this
Detection typically combines code-level analysis and runtime monitoring:
- Static analysis and code review:
- Flag locations where application code dynamically writes or generates PHP files using user-controlled data.
- Look for patterns of string concatenation building PHP constructs (
define(),eval,includepaths) from request parameters. - Enforce review policies requiring strict validation of installer and setup logic that manipulates configuration files.
- Policy enforcement:
- Require use of non-executable configuration formats for new components.
- Add CI checks or automated tools to identify new code that writes executable configuration from HTTP parameters.
- Runtime monitoring:
- Monitor for unexpected changes to
config.phpand other critical configuration files. - Use file integrity monitoring (FIM) to alert on modifications during or after installation.

