Summary
Dolibarr ERP & CRM up to version 22.0.4 contains an inconsistency in how the Website module enforces PHP code detection and editing permissions across different input parameters.
As a result, an authenticated user who is supposed to be limited to HTML/JavaScript editing can inject PHP code through unprotected inputs during website page creation, potentially leading to server-side code execution.
Affected context
This vulnerability occurs within the Website module of Dolibarr ERP & CRM installations up to and including version 22.0.4.
It is relevant in deployments where:
- The Website module is enabled and used for creating or editing website pages
- Users are granted limited web content editing rights (e.g., HTML/JavaScript only) without full PHP editing privileges
- PHP code filtering or detection is expected to prevent non-privileged users from adding executable PHP fragments
Under these conditions, some input parameters in the page creation flow are not covered by the same PHP code checks, leaving a path for PHP injection.
Exploit preconditions
- Attack surface: Web-based management interface of Dolibarr, specifically the Website module page creation or editing features.
- Required access: Valid authenticated account with permissions to create or edit website content, but without explicit PHP editing rights.
- Trigger point: Submission of crafted content via page creation or related fields where PHP detection and permission enforcement are missing or inconsistent.
- Why exploitation is possible: Not all input parameters are protected by the same PHP code detection and permission checks, allowing PHP snippets to be stored and later interpreted by the PHP engine despite the user's restricted role.
Why this happens
The core issue is an inconsistent application of security controls that are intended to prevent unauthorized PHP code from being introduced by users without appropriate privileges.
Some fields in the Website module correctly enforce checks that detect PHP code and verify whether the user has permissions to add such code, but other parameters either skip these checks or apply weaker validation.
This maps primarily to CWE-94: Improper Control of Generation of Code ('Code Injection'), as user-controlled input can influence server-side code execution, and secondarily to CWE-284: Improper Access Control, because the system fails to uniformly enforce the intended separation between HTML/JavaScript editors and PHP-capable administrators.
Conceptually, the application treats data that should be inert content as potentially executable code, without consistently gating that capability behind strict permission and validation logic.
Potential impact
- Authenticated users with limited content-editing rights may inject and execute arbitrary PHP code on the server.
- Attackers could read or modify sensitive data handled by Dolibarr (e.g., CRM/ERP records, configuration, or stored credentials).
- Compromise of the underlying web server environment, including deployment of web shells or backdoors.
- Escalation from a low-privileged content editor account to full application or system-level compromise.
- Lateral movement to other systems or services reachable from the compromised server.
General mitigation guidance
Effective mitigation focuses on consistent enforcement of code execution boundaries and strong access control around server-side code capabilities:
- Apply uniform PHP code detection and filtering to all inputs that may end up being interpreted by the PHP engine, regardless of how or where they are submitted.
- Enforce a clear separation of permissions: roles allowed to create or edit PHP should be narrowly scoped and distinct from general content editors.
- Treat all page content fields as untrusted input; avoid any dynamic evaluation or inclusion that could turn stored content into executable code.
- Adopt a deny-by-default policy for executable content types and require explicit, centralized checks for any feature that can introduce server-side code.
- Where possible, design the Website module to store and render only static content (HTML/CSS/JavaScript) for most roles, with no path for embedded PHP at all.
- Regularly review privilege configurations to ensure only administrative or trusted technical roles can introduce or modify executable components.
How teams detect issues like this
Organizations can look for this pattern using both code-centric and operational approaches:
- Static analysis: Define rules or use tools to flag direct or indirect inclusion of user-controlled template content that may be interpreted as PHP, especially where different fields use inconsistent validation or permission checks.
- Code review: Examine the Website module's page creation and editing paths to verify that all input parameters flow through the same PHP detection and authorization logic. Look for duplicated validation branches, bypassed helper functions, or conditional checks based on field names.
- Security testing: Perform authenticated tests with low-privileged content editor accounts, attempting to insert PHP markers into all content-related parameters and confirm that none are executed on rendering.
- Logging and monitoring: Monitor web server logs and application logs for unusual PHP error messages, unexpected file inclusions, or patterns indicative of content-based code injection.
- Policy enforcement: Integrate automated checks in CI/CD pipelines to prevent new or modified features from introducing additional executable content paths without centralized permission checks.

