You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Authenticated Local File Inclusion (LFI) via selectobject.php leading to sensitive data disclosure
Target
Dolibarr Core (Tested on version 22.0.4)
Summary
I have discovered a Local File Inclusion (LFI) vulnerability 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:
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
I am committed to coordinated vulnerability disclosure. I will keep this vulnerability, along with the provided PoC, strictly confidential until a patch is released and you give explicit authorization for public disclosure.
Please let me know if you need any further technical details, logs, or if you would like me to test the remediation once you have developed a patch.
Thank you for your time and your commitment to securing Dolibarr. I look forward to hearing from you.
The PHP application receives input from an upstream component, but it does not restrict or incorrectly restricts the input before its usage in require, include, or similar functions.
Learn more on MITRE.
Authenticated Local File Inclusion (LFI) via selectobject.php leading to sensitive data disclosure
Target
Dolibarr Core (Tested on version 22.0.4)
Summary
I have discovered a Local File Inclusion (LFI) vulnerability in the core AJAX endpoint
/core/ajax/selectobject.php. By manipulating theobjectdescparameter and exploiting a fail-open logic flaw in the core access control functionrestrictedArea(), 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.phpwhere dynamic file inclusion occurs before any access control checks are performed, combined with a fail-open logic in the core ACL function.objectdescparameter into a$classpath. IffetchObjectByElementfails (e.g., by providing a fake class likeA:conf/.htaccess:0), the application falls back todol_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.restrictedArea(). Because the object creation failed, the$featuresparameter sent torestrictedArea()is empty (''). Insidesecurity.lib.php, if the$featuresparameter is empty, the access check block is completely skipped, leaving the$readokvariable at1. 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
conf/.htaccessfile will be reflected in the response body right before the PHP Fatal Error message.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
$classpathmust be strictly validated or whitelisted before being passed todol_include_once().restrictedArea()incore/lib/security.lib.phpso that if the$featuresparameter is empty, access is explicitly denied ($readok = 0) instead of allowed by defaultDisclosure Policy & Assistance
I am committed to coordinated vulnerability disclosure. I will keep this vulnerability, along with the provided PoC, strictly confidential until a patch is released and you give explicit authorization for public disclosure.
Please let me know if you need any further technical details, logs, or if you would like me to test the remediation once you have developed a patch.
Thank you for your time and your commitment to securing Dolibarr. I look forward to hearing from you.
Best Regards,
Vincent KHAYAT (cnf409)
Video PoC
poc.mp4
PoC Script