/

CVE-2026-31018

Severity:

HIGH RISK

(8.8)

Code Injection / Improper Access Control in Dolibarr

CVE-2026-31018

Modified

Vulnerability type

Category:

Code Injection / Improper Access Control

CWE:

CWE-94, CWE-284

Impact:

Authenticated Remote Code Execution

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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.

Sources

SourceLink
github.comgithub.com/PhDg1410/CVE/blob/main/CVE-2026-31018/README.md

Frequently asked

questions

Yes, but only by authenticated users. An attacker must log into Dolibarr and have at least content-editing access to the Website module to exploit the issue.

The attacker needs a valid user account with permissions to create or edit website pages, but does not require full administrative or PHP editing rights. The vulnerability specifically affects users who should be restricted to HTML/JavaScript content.

Ensure that all content fields in the Website module are treated as non-executable by default and that any capability to add PHP or other server-side code is gated through a single, centralized permission check and strict validation. Consolidating and reusing one robust validation/authorization path for all relevant inputs is more reliable than scattered, field-specific checks.

Adopt a secure design pattern where executable code paths are minimized, isolated, and governed by explicit, role-based permissions. Combine this with consistent input validation, regular code review focusing on privilege boundaries, and automated static analysis rules that detect user-controlled data flowing into templates or dynamic execution functions.

Find out what's already
exploitable in your codebase.