Summary
Dolibarr's user extrafields feature contains a code injection flaw where attacker-controlled "computed value" expressions are passed directly into PHP's eval() function.
An authenticated administrator can abuse this behavior to execute arbitrary PHP code on the server, leading to full application compromise under affected configurations.
Affected context
This vulnerability manifests in Dolibarr deployments that use the user extrafields "computed value" capability to dynamically calculate field values.
The issue is present when the application evaluates these expressions using PHP's eval() with insufficient validation or restriction of the supplied expression string.
It is most relevant in environments where administrator accounts are shared, delegated, or exposed to untrusted users, or where an attacker can otherwise obtain administrator-level credentials.
Exploit preconditions
- Attack surface: Web application interface for configuring user extrafields
- Required access: Authenticated administrator (or any role with permission to define/modify extrafield "computed value" expressions)
- Trigger point: Saving or triggering evaluation of a crafted "computed value" that is later processed by
eval() - Why exploitation is possible: The application embeds user-provided expression text into an
eval()call without robust parsing, whitelisting, or sandboxing, allowing arbitrary PHP code to be executed in the application's runtime context.
Why this happens
The underlying issue is the direct use of PHP's eval() on data influenced by users, which is a classic code injection antipattern.
Instead of treating "computed value" content as data to be interpreted by a constrained expression engine, the application passes the raw string into the PHP interpreter, effectively granting code execution privileges to anyone who can modify that field.
This aligns with CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component, where untrusted inputs are embedded into commands or code processed by another interpreter without adequate neutralization or strict allowlisting.
Potential impact
- Arbitrary PHP code execution within the web server process
- Reading or modification of application data, including ERP and CRM records
- Creation of backdoor functionality or web shells for persistent access
- Access to sensitive configuration values, such as database credentials
- Lateral movement to other systems, depending on server privileges and network position
General mitigation guidance
Mitigation generally focuses on avoiding direct interpreter calls on user-controlled data and constraining any dynamic expression capabilities.
Recommended defensive patterns include:
- Replacing
eval()with a safe, declarative expression engine that operates on a strict grammar and prevents arbitrary function calls - Applying strict allowlists for permitted operators and functions, and rejecting any expression that deviates from expected patterns
- Treating "computed value" content as data, not code, and evaluating it through explicit, hard-coded logic paths rather than generic interpreter APIs
- Restricting high-risk configuration capabilities to a minimal set of trusted administrators and using separate accounts for routine tasks
- Running the application with least-privilege OS and database accounts to limit the blast radius if code execution occurs
How teams detect issues like this
Detection can be approached through both code-level and operational monitoring techniques:
- Static analysis rules that flag any use of
eval(),assert(), or similar dynamic execution APIs, especially when arguments derive from configuration or request data - Secure code review checklists that explicitly require justification and alternatives for interpreter use and dynamic expression features
- Application logging and monitoring focused on changes to user extrafields configuration, particularly updates to "computed value" fields
- Web application firewalls or runtime application self-protection (RASP) solutions that can detect anomalous PHP execution patterns or suspicious expression strings
- Periodic configuration audits to identify and review any complex or unexpected "computed value" expressions that may embed logic beyond simple calculations

