Summary
Dolibarr ERP/CRM before version 23.0.2 contains an authenticated remote code execution vulnerability in the dol_eval_standard() function, which evaluates user-controlled expressions using eval() without reliably blocking dangerous constructs.
An attacker with administrator privileges can craft payloads using PHP dynamic callable syntax to bypass whitelist-based checks, resulting in arbitrary command execution on the server.
Affected context
This vulnerability appears in Dolibarr ERP/CRM deployments where:
- Administrators can define or modify computed extrafields or other evaluatable expressions
- The
dol_eval_standard()function is used to evaluate these expressions at runtime - Evaluation relies on a whitelist-mode filter that attempts to block forbidden strings
In such configurations, the application treats administrator-supplied expressions as code and executes them with PHP eval(), creating a high-impact risk if the filtering logic is incomplete or bypassable.
Exploit preconditions
- Attack surface: Web-based administrative interface for Dolibarr ERP/CRM
- Required access: Valid Dolibarr account with administrator-level privileges or equivalent rights to configure computed extrafields or other evaluated expressions
- Trigger point: Server-side execution of
dol_eval_standard()when rendering or processing a computed field or any feature that evaluates custom expressions - Why exploitation is possible: The whitelist-mode filter inside
dol_eval_standard()does not properly detect PHP dynamic callable syntax and fails to apply forbidden string checks in all cases, allowing crafted expressions to reacheval()and execute arbitrary PHP code.
Why this happens
The issue stems from using eval() on user-configurable expressions in combination with incomplete input validation.
The dol_eval_standard() function attempts to sanitize or restrict expressions via a whitelist approach and forbidden-string checks, but the logic does not cover all syntactic forms available in PHP, including dynamic callable syntax.
Because the filter focuses on direct string matches rather than a robust parsing or safe evaluation model, attackers can encode dangerous operations in forms that evade detection, mapping directly to CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code ('Eval Injection').
Potential impact
- Execution of arbitrary PHP code in the context of the web server
- Reading, modifying, or deleting application and business data managed by Dolibarr
- Installation of webshells or backdoors for persistent access
- Pivoting to the underlying operating system to run arbitrary system commands
- Lateral movement to other internal systems reachable from the Dolibarr host
- Abuse of the Dolibarr instance for data exfiltration or further compromise of the organization
General mitigation guidance
Effective mitigation focuses on eliminating dangerous dynamic evaluation paths and reducing the power of configurable expressions:
- Replace
eval()-based evaluation with a safe, domain-specific expression engine that explicitly supports only the minimal operations needed (e.g., arithmetic, simple conditionals, field references). - Implement strict parsing and allow-listing at the syntax and function level, rejecting any construct outside the supported safe subset.
- Treat administrator-supplied expressions as untrusted input, enforcing the same secure coding principles applied to regular user input.
- Apply least-privilege principles to the application runtime (e.g., restricted file system permissions, non-privileged OS users) so that, even if code execution occurs, its capabilities are constrained.
- Centralize and reuse safe evaluation routines instead of ad-hoc uses of
eval()scattered across the codebase, simplifying review and hardening.
These patterns reduce the risk of eval injection even when complex configuration features are required.
How teams detect issues like this
Detection can combine code-centric and configuration-centric approaches:
- Static analysis: Search for uses of
eval()or similar dynamic execution constructs that accept user- or admin-controlled input; flag any instance where the input is not derived solely from trusted constants or a rigorously-validated expression model. - Code review signals: Pay special attention to helper functions like
dol_eval_standard()that centralize evaluation logic; reviewers should look for whitelist-based checks, string filtering, or regex rules that attempt to secureeval()rather than replacing it. - Configuration review: Regularly review high-privilege configuration paths such as computed extrafields, custom formulae, and plugin-defined expressions to identify suspicious or unexpectedly complex logic.
- Runtime monitoring: Monitor application logs and web server logs for anomalous errors, unexpected PHP warnings, or unusual outbound connections that could indicate malicious code execution.
- Automated tooling: Integrate SAST tools or custom linters into CI pipelines to systematically detect eval-like patterns and enforce organization-wide policies that discourage dynamic code evaluation.

