Summary
A command injection vulnerability in Dolibarr's ODT to PDF conversion pipeline allows arbitrary shell commands to be executed through an unsanitized configuration constant.
When an authenticated administrator controls the MAIN_ODT_AS_PDF setting, they can inject commands into the exec() call used for document conversion, leading to remote code execution as the web server user whenever an ODT template is generated.
Affected context
This vulnerability occurs in Dolibarr deployments that:
- Use the ODT to PDF conversion feature handled by
odf.php - Rely on the MAIN_ODT_AS_PDF configuration constant to define the conversion command
- Allow administrator-level users to modify this configuration value via the web interface or configuration files
The risk is present when document generation features that invoke ODT templates are used, as each conversion triggers the vulnerable exec() call.
Exploit preconditions
- Attack surface: Web application interface (Dolibarr admin configuration and document generation endpoints)
- Required access: Authenticated administrator-level access capable of setting or changing the MAIN_ODT_AS_PDF configuration constant
- Trigger point: Generating an ODT-based document (e.g., invoice, proposal, report) that invokes the ODT to PDF conversion routine in
odf.php - Why exploitation is possible: The value of MAIN_ODT_AS_PDF is concatenated directly into a shell command passed to
exec()without proper escaping, validation, or use of safer APIs, allowing shell metacharacters and command separators to alter the executed command.
Why this happens
The root cause is direct interpolation of a configurable string into a shell command executed by exec() without sanitization or escaping.
This matches CWE-78: Improper Neutralization of Special Elements used in an OS Command, where untrusted input is incorporated into an operating system command line. In this case, the MAIN_ODT_AS_PDF configuration is treated as trusted, but it can be manipulated to include command separators or other shell constructs that change the intended behavior of the command. Instead of treating configuration values as data, the implementation embeds them as executable shell fragments, creating a command injection sink.
Potential impact
- Execution of arbitrary OS commands as the web server user
- Reading or modifying application files accessible to the web server account
- Accessing or exfiltrating sensitive Dolibarr data (e.g., customer, financial, or operational records)
- Installing backdoors or web shells on the host system
- Using the compromised server as a pivot point for further network attacks
- Disruption of ERP/CRM operations through data tampering or resource exhaustion
General mitigation guidance
Effective mitigation focuses on removing the possibility of injecting arbitrary shell syntax through configuration values and reducing the reliance on shell execution:
- Replace generic
exec()usage with language-native libraries or APIs that perform document conversion without invoking the shell, or use parameterized process-execution APIs that do not interpret shell metacharacters. - Treat all configuration values as untrusted input, even when set by administrators, and apply strict validation to ensure they are limited to expected program paths or whitelisted options rather than free-form command lines.
- If shell execution cannot be completely avoided, construct commands using safe argument arrays instead of string concatenation, and explicitly reject characters associated with command chaining or shell control.
- Apply least-privilege to the web server account so that, if command execution occurs, the damage is constrained to the minimal necessary resources.
- Separate duties so that configuration changes affecting system-level behavior require more controlled operational processes, such as out-of-band configuration management rather than arbitrary runtime editing.
How teams detect issues like this
Detection can focus on identifying dangerous command construction patterns and unusual runtime behavior:
- Use static analysis to flag calls to
exec(),system(), or similar functions where command strings are built from configuration values, database fields, or other indirectly controlled inputs. - During code review, look for string concatenation or interpolation when constructing shell commands, particularly in conversion, backup, or integration modules that rely on external tools.
- Establish secure coding standards and linting rules that discourage shell invocation from web-facing code and require justification and review for any remaining uses.
- Monitor application and system logs for anomalous command execution originating from the web server process, such as unexpected processes, outbound connections, or file modifications in non-application directories.
- Incorporate security-focused testing (e.g., configuration fuzzing, abuse of admin settings) in QA to identify features where administrative configuration is interpreted as executable logic.

