Summary
Dolibarr's website template import can allow PHP code embedded in a template's javascript.js.php file to execute when the public endpoint includes it. A website editor may be able to trigger this behavior without having PHP permission, potentially running code with the web server's privileges.
Affected context
The issue occurs in Dolibarr's Website::importWebSite() template-import functionality. It may put a deployment at risk when a website editor can import a template containing PHP code in javascript.js.php and the public endpoint later includes that file for execution.
Exploit preconditions
- Attack surface: Website template import and the public
javascript.js.phpendpoint - Required access: Ability to import website templates as a website editor; PHP permission is not required according to the description
- Trigger point: The endpoint includes the imported
javascript.js.phpfile - Why exploitation is possible: PHP code in the imported file is treated as executable code when included by the endpoint
Why this happens
The import and serving path permits template content to cross from data into executable PHP. Including an imported PHP-bearing file allows its contents to run rather than treating them as inert website assets, which is a code injection flaw mapped to CWE-94.
Potential impact
- An attacker may execute code with the web server user's privileges.
- The application or its accessible data could be compromised.
- An attacker could alter website content or disrupt service.
- The web server's access to other resources could increase the scope of impact.
General mitigation guidance
Defensive patterns include treating imported templates as untrusted data, validating and constraining their contents, and keeping uploaded assets outside executable paths. Where practical, use static asset formats and serve them without a PHP include or interpreter. Apply least-privilege permissions to the web server and restrict template-import capabilities to trusted users.
How teams detect issues like this
- Review import and asset-serving code for paths where uploaded files can reach dynamic include or execution operations.
- Use static analysis to flag dynamic includes and execution of files from user-writable or import-controlled locations.
- Inspect imported template archives and deployment directories for unexpected PHP files or content.
- Enforce policies that separate uploaded assets from executable code and prevent interpreters from running in asset directories.

