Summary
Dolibarr ERP/CRM versions 22.0.0 through 22.0.4 and 24.0.0-alpha contain a code injection vulnerability that can allow remote attackers to execute arbitrary code via the core/actions_addupdatedelete.inc.php script.
When attacker-controlled input is incorporated into dynamically evaluated PHP code or similar constructs, the application's runtime can be taken over under typical web-access conditions.
Affected context
The vulnerability resides in the Dolibarr ERP/CRM PHP application, specifically in the shared action handler file htdocs/core/actions_addupdatedelete.inc.php.
It is relevant in deployments where this script is accessible through standard web routes and where user-supplied parameters can reach code paths that construct or evaluate dynamic PHP expressions or commands.
The risk is higher in multi-user environments or internet-exposed instances where untrusted or semi-trusted users can interact with add/update/delete workflows.
Exploit preconditions
- Attack surface: HTTP(S) endpoints in Dolibarr that route through
core/actions_addupdatedelete.inc.php. - Required access: Ability to send crafted web requests to the affected Dolibarr instance (often authenticated, depending on configuration and exposed modules).
- Trigger point: Invocation of add/update/delete actions that process user input and pass it into dynamically evaluated code paths within the script.
- Why exploitation is possible: The script constructs or evaluates executable PHP logic using input that is insufficiently validated, sanitized, or constrained, allowing attacker-controlled data to alter what code is executed.
Why this happens
This issue is a classic CWE-94: Improper Control of Generation of Code ('Code Injection').
The core problem is that dynamically generated code (for example, PHP evaluated strings, dynamic function calls, or include/require paths) is influenced by request parameters without applying strict validation, whitelisting, or encoding.
Instead of treating user input as data only, the implementation allows it to shape the structure of executable logic, breaking the intended separation between code and data.
Once this boundary is crossed, an attacker can craft inputs that inject additional instructions or modify control flow, resulting in arbitrary code execution under the application's runtime user.
Potential impact
- Remote execution of arbitrary PHP code within the Dolibarr application context
- Full compromise of the underlying web application, including theft or tampering of ERP/CRM data
- Installation of web shells or backdoors for persistent access
- Pivoting to underlying server resources and connected systems, subject to OS-level permissions
- Abuse of the application to exfiltrate sensitive business, financial, or customer information
General mitigation guidance
Effective mitigation focuses on preventing user data from ever being treated as executable code and on constraining dynamic behavior:
- Refactor dynamic code generation patterns to use fixed code paths and parameterized logic instead of
eval-like constructs or variable-function execution. - Apply strict whitelisting for any variable that influences function names, class names, methods, file paths, or configuration keys, rejecting unexpected values early.
- Normalize all inputs at the boundary (type casting, enumeration checks, length and character constraints) before they reach core action handlers.
- Enforce least-privilege execution for the web server and PHP runtime so that, if exploited, the attacker's capabilities on the host are minimized.
- Centralize input-handling utilities with secure-by-default helpers that encode or escape values before use in dynamic contexts.
How teams detect issues like this
Detection typically combines automated analysis with targeted review of critical action handlers:
- Use static analysis to flag use of dangerous PHP constructs (e.g.,
eval, dynamicinclude/require, variable functions, dynamic class instantiation) where inputs originate from$_GET,$_POST, or other request sources. - Implement secure coding guidelines that prohibit or tightly restrict runtime code generation and require explicit justification for any dynamic execution.
- During code review, pay special attention to shared handler files like
actions_addupdatedelete.inc.phpthat orchestrate create/update/delete operations, verifying strict parameter validation and whitelisting. - Integrate application security testing (SAST/DAST) into CI pipelines to detect anomalous behavior or tainted data flows leading to execution sinks.

