Summary
Froxlor's configuration handling logic allows unescaped user input to be written directly into a PHP file that is required on every request, enabling injected data to break out of a string and become executable code.
An authenticated admin with change_serversettings permission can abuse the privileged_user parameter in the MySQL server API to inject arbitrary PHP that runs as the web server user on all subsequent page loads.
Affected context
This vulnerability affects Froxlor deployments where:
- Admin users can add or update MySQL server configurations via the API.
- The
privileged_userparameter is accepted and persisted without validation. PhpHelper::parseArrayToString()serializes configuration values into PHP code using single-quoted string literals.- The generated
lib/userdata.inc.phpfile is included viarequireinDatabase::getDB()on every request.
Under these conditions, crafted configuration values may escape the intended string literal and introduce attacker-controlled PHP code into the application runtime.
Exploit preconditions
- Attack surface: Froxlor API endpoint(s) responsible for managing MySQL servers.
- Required access: Authenticated account with
change_serversettingspermission (typically an administrative role). - Trigger point: Submission or update of the MySQL server configuration where
privileged_useris set to a value containing PHP-breaking payloads. - Why exploitation is possible: The
PhpHelper::parseArrayToString()helper writes string values into single-quoted PHP literals without escaping single quotes. This makes it possible for crafted input inprivileged_userto terminate the string, inject arbitrary PHP code, and then restore syntactic validity. The resultinglib/userdata.inc.phpis required on every request, so the injected code executes automatically.
Why this happens
The core issue is unsafe dynamic code generation: user-controlled data is directly embedded into a PHP source file without proper escaping or separation between data and executable logic.
By writing raw input into a single-quoted PHP string literal and failing to escape single quotes or other control characters, the application effectively treats configuration data as code. This aligns with CWE-94: Improper Control of Generation of Code ('Code Injection'), where external input influences the code that will later be executed. Instead of serializing configuration to a neutral data format (e.g., JSON, INI, or PHP arrays with robust encoding), the helper function constructs PHP code fragments that are then required, creating an implicit template engine without safety boundaries.
Potential impact
- Execution of arbitrary PHP code as the web server user.
- Full compromise of the Froxlor application and its data.
- Theft or manipulation of database credentials and other secrets loaded from configuration.
- Creation of persistent backdoors that run on every request.
- Lateral movement to other applications or data on the same server, depending on file system and process privileges.
- Disruption of service by injecting code that causes fatal errors or infinite loops.
General mitigation guidance
Effective mitigation focuses on eliminating the mixing of user-controlled data with executable PHP code and enforcing strict encoding for any generated configuration:
- Stop generating executable PHP from user input: Prefer data-only configuration formats (e.g., JSON, YAML, INI, environment variables, or database-stored settings) that are parsed as data rather than code.
- Use robust escaping when PHP code generation is unavoidable: If a PHP config file must be generated, use well-tested escaping routines for string literals (e.g.,
var_exportor dedicated encoding helpers) to ensure that quotes and control characters cannot break out of strings. - Introduce strict validation for configuration fields: Constrain parameters like
privileged_userto expected patterns (e.g., database username formats) using whitelisting, length limits, and character-set restrictions. - Separate privileges and configuration paths: Store configuration files in locations with restricted write access, ensuring that only trusted application paths can modify them, and enforce least-privilege on any process that generates configuration.
- Apply defense-in-depth controls: Run the web server and PHP runtime under constrained OS accounts, leverage filesystem permissions, disable dangerous PHP functions where possible, and segment the environment so that configuration compromise has limited blast radius.
How teams detect issues like this
Detection can focus on both code-level patterns and runtime behavior:
- Static analysis and code scanning:
- Flag functions or helpers that build PHP code strings from variables (e.g., concatenation into
.phpfiles, use ofeval, orrequireon generated files). - Look for serialization of user-controlled fields into PHP literals without escaping, especially where quotes and backslashes are not sanitized.
- Enforce linting rules that disallow writing configuration as executable PHP when user input is involved.
- Code review cues:
- Highlight any code that writes to
lib/userdata.inc.phpor similar configuration files that are laterrequired. - Question any pattern where configuration helpers accept raw input and output PHP code instead of neutral data.
- Review permission checks around APIs that mutate configuration and ensure that they are restricted and validated.
- Runtime and operational monitoring:
- Monitor configuration files (e.g.,
lib/userdata.inc.php) for unexpected changes using file integrity monitoring. - Inspect logs for anomalous values in configuration parameters like
privileged_user. - Use application security monitoring or WAF rules to detect suspicious payloads that contain PHP code fragments targeting configuration endpoints.

