Summary
Dolibarr ERP CRM 7.0.3 contains a critical code injection flaw that allows arbitrary PHP code to be written and executed via the installation workflow.
An unauthenticated attacker can inject PHP code through the db_name parameter in a POST request to install/step1.php and later execute OS-level commands through the check.php endpoint using the cmd GET parameter.
Affected context
This vulnerability manifests during the web-based installation process of Dolibarr ERP CRM 7.0.3.
It affects deployments where the install/step1.php and check.php endpoints are accessible over the network and user-supplied installation parameters (such as db_name) are processed without sufficient validation or neutralization before being written into PHP-executable context.
Environments where installation scripts remain reachable in production or exposed to the internet are particularly at risk.
Exploit preconditions
- Attack surface: HTTP(S) interface exposing the Dolibarr installation endpoints (install/step1.php and check.php).
- Required access: No authentication is required; the attacker needs only network access to the vulnerable web interface.
- Trigger point: Submission of a crafted POST request to install/step1.php with malicious PHP content in the db_name parameter, followed by a GET request to check.php with a cmd parameter to trigger the injected code.
- Why exploitation is possible: User-controlled input from db_name is incorporated into PHP-executed context without proper sanitization, encoding, or separation between data and code, enabling arbitrary PHP statements to be persisted and later executed.
Why this happens
The core issue aligns with CWE-94: Improper Control of Generation of Code ("Code Injection").
The application dynamically handles configuration values (like db_name) in a way that allows user-supplied strings to influence generated PHP code or files.
Because these values are not strictly validated, encoded, or constrained to safe characters and are subsequently interpreted by the PHP runtime, an attacker can craft input that becomes executable PHP code.
This pattern stems from mixing data and code paths, relying on dynamic PHP execution mechanisms during installation without enforcing strict separation between configuration content and executable logic.
Potential impact
- Remote execution of arbitrary PHP code on the server.
- Execution of operating system commands under the web server's privileges.
- Complete compromise of the Dolibarr application and its underlying database.
- Lateral movement within the hosting environment or network.
- Installation of persistent web shells or backdoors.
- Exfiltration or manipulation of sensitive business and customer data.
General mitigation guidance
Effective mitigation focuses on eliminating the ability for user input to influence executable code paths and reducing exposure of installation interfaces:
- Constrain installer parameters (such as db_name) to strictly validated formats, using allowlists of characters and length limits, and reject any input that does not match expected patterns.
- Avoid generating or including PHP code directly from user-supplied values; keep configuration data in non-executable formats (e.g., .ini, .env, or structured data files) that are not interpreted as code.
- Introduce strong output encoding and neutralization when user-controlled values are written into configuration files, ensuring they cannot break out into executable syntax.
- Disable or remove installation scripts (e.g., install/step1.php and related endpoints) once setup is complete, or restrict them behind administrative authentication and network-level controls.
- Run the application with least-privilege OS and database accounts so that, even if code execution occurs, its capabilities are limited.
How teams detect issues like this
Detection typically involves a combination of code-level and operational checks:
- Static analysis: Define rules or queries to identify patterns where user input is written into PHP files, concatenated into eval-like constructs, or passed into dynamic include/require statements.
- Code review: Flag any installer or configuration code that writes executable PHP files or templates using untrusted input, especially in installation or upgrade scripts.
- Configuration and deployment reviews: Verify that installation endpoints are disabled or restricted in production and that web roots do not contain writable directories for dynamic PHP generation without controls.
- Runtime monitoring: Inspect web server logs for unusual access to install/step1.php and check.php, especially with unexpected db_name or cmd parameters, and monitor for anomalous outbound connections or command execution artifacts.

