Summary
Dolibarr ERP/CRM versions 22.0.0 through 22.0.4 and 24.0.0-alpha contain a remote code execution issue in the cron job handling logic that uses call_user_func_array() in htdocs/cron/class/cronjob.class.php.
Under certain conditions where an attacker can influence the function name or parameters for cron job execution, arbitrary PHP code can be triggered on the server.
Affected context
This vulnerability lies in Dolibarr's scheduled task (cron job) functionality.
It becomes relevant in deployments where:
- Cron jobs can be created, modified, or imported based on user-controlled input
- The job "type" or handler configuration is not strictly constrained to a fixed, vetted set
- The application executes jobs by dynamically resolving function or method names via
call_user_func_array()
The risk is heightened in multi-user or exposed administrative environments where job configuration can be influenced by untrusted or partially trusted actors.
Exploit preconditions
- Attack surface: HTTP(S) interface of Dolibarr's ERP/CRM application where cron jobs are created or managed.
- Required access:
- Ability to create, edit, or otherwise control cron job definitions (e.g., job type, handler, or parameters).
- This may correspond to authenticated access with specific roles or misconfigured permissions; exact requirements depend on deployment.
- Trigger point: Execution of scheduled jobs, either via system cron invoking Dolibarr or via a web-triggered cron endpoint.
- Why exploitation is possible: The cron framework relies on
call_user_func_array()with values derived from job configuration that are not strictly validated against a fixed whitelist. This dynamic dispatch allows attackers who control job metadata to influence which code is executed and with what arguments.
Why this happens
The core issue is the use of dynamic function invocation (call_user_func_array()) with insufficiently constrained inputs.
Instead of mapping job types to a static set of known-safe handlers, the design permits user-influenced configuration to dictate which function or method is called.
This maps to CWE-94: Improper Control of Generation of Code ('Code Injection'), where an application constructs or resolves executable behavior based on external input without enforcing strict validation or whitelisting.
In practice, this pattern allows untrusted or semi-trusted data to cross the boundary from configuration into executable control flow, leading to potential remote code execution.
Potential impact
- Execution of arbitrary PHP code within the Dolibarr application context
- Full compromise of the underlying web server account, including read/write access to application data
- Unauthorized access to sensitive ERP/CRM records such as invoices, customer data, and financial information
- Installation of web shells or backdoors for persistent access
- Lateral movement to other internal systems reachable from the compromised host
- Tampering with scheduled jobs to conceal malicious behavior or disable security-related tasks
General mitigation guidance
Effective mitigation focuses on removing or strictly constraining dynamic code execution paths in cron handling:
- Replace free-form dynamic function calls with a whitelisted registry of allowed job handlers, mapping job types to specific, hard-coded callable targets.
- Enforce strong validation on all cron job configuration fields, especially any that influence function names, class names, or include paths.
- Treat job configuration as untrusted input: avoid using it directly in code paths that determine executable behavior without normalization and validation.
- Apply the principle of least privilege to the web server and application runtime so that even if code execution occurs, its ability to affect the wider system is constrained.
- Where possible, separate high-privilege maintenance tasks from user-configurable cron jobs, using distinct mechanisms and permissions.
- Implement secure defaults by disabling or limiting advanced job types in multi-tenant or externally exposed deployments.
How teams detect issues like this
Organizations can detect and monitor for this class of vulnerability using a combination of code and behavior analysis:
- Static analysis:
- Search for uses of
call_user_func_array(),call_user_func(), and similar dynamic invocation APIs. - Flag cases where the callable or arguments are derived from HTTP parameters, database fields, or any user-modifiable configuration.
- Check that cron job types are validated against a strict, predefined list before execution.
- Code review:
- Review the cron subsystem design for any configuration-driven function resolution or class loading.
- Look for patterns where job metadata is directly mapped to callable identifiers without centralized validation.
- Runtime monitoring:
- Log cron job executions with handler names and parameters, and alert on unusual handler patterns or unexpected job types.
- Monitor for anomalous filesystem changes (e.g., new PHP files, modified core scripts) after cron runs.
- Security tooling:
- Integrate SAST tools with rules targeting dynamic function calls and configuration-driven dispatch.
- Use RASP or application firewalls configured to detect attempts to abuse dynamic invocation patterns.

