Code injection in dolibarr/dolibarr
The dol_eval function in Dolibarr sanitises dangerous PHP functions using str_replace, which can be bypassed by crafting the $s parameter. An attacker could inject arbitrary PHP code and execute commands on the file system.
dolibarr/dolibarr
Originally disclosed on huntr
Improper php function sanitization, lead to an ability to inject arbitrary PHP code and run arbitrary commands on file system. In the function "dol_eval" in file "dolibarr/htdocs/core/lib/functions.lib.php" dangerous PHP functions are sanitized using "str_replace" and can be bypassed using following code in $s parameter
From the GitHub Advisory Database (GHSA-42qm-c3cf-9wv2, CC BY 4.0).
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the sanitisation relies on a simple string replacement (str_replace) that can be bypassed, instead of using a proper allow-list or safe evaluation method.
Impact
An attacker could inject arbitrary PHP code and run arbitrary commands on the file system.
What the attacker needed
Access to a parameter evaluated by dol_eval
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
PHP has a function called dol_eval that is meant to safely evaluate code, but it tries to block dangerous functions by simply replacing their names with str_replace. Because str_replace can be tricked, an attacker can write code that still calls those dangerous functions. This lets them run their own PHP code and commands on the server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.