From ef6631e9bd5ec4b8cec0e88f1796d3d10dad02ec Mon Sep 17 00:00:00 2001 From: w3houde Date: Wed, 15 Jul 2026 05:52:28 +0700 Subject: [PATCH] Fix #38963 enforce website write right on legacy filemanager (#39160) The legacy FCKeditor file manager connector (config.inc.php, also included by browser/default/browser.php and connectors/php/connector.php) only called main.inc.php and never checked any module right on 21.0 and 22.0, so any authenticated user, even one with no permission, could reach the connector, browse the medias directory and upload files. The permission check already present on 23.0 and develop was never backported. This adds the same guard so a non-admin without website write right is refused. Reported by Abderrahmane Aksoum. Signed-off-by: Dolicraft Co-authored-by: Dolicraft --- htdocs/core/filemanagerdol/connectors/php/config.inc.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/core/filemanagerdol/connectors/php/config.inc.php b/htdocs/core/filemanagerdol/connectors/php/config.inc.php index 0704d51f615..bef7ef1b815 100644 --- a/htdocs/core/filemanagerdol/connectors/php/config.inc.php +++ b/htdocs/core/filemanagerdol/connectors/php/config.inc.php @@ -36,6 +36,7 @@ require_once '../../../../main.inc.php'; /** * @var Conf $conf + * @var User $user * * @var string $dolibarr_main_data_root * @var string $dolibarr_main_url_root @@ -49,6 +50,13 @@ if ($pos == '/') { //define('DOL_URL_ROOT', $pos); $entity = ((!empty($_SESSION['dol_entity']) && $_SESSION['dol_entity'] > 1) ? $_SESSION['dol_entity'] : null); +// This connector browses and writes into the medias directory, so it must be +// restricted the same way as on the newer branches. Without this check any +// authenticated user (even with no module right) could reach the file manager. +if (empty($user->admin) && !$user->hasRight('website', 'write')) { + accessforbidden('Need to be admin or having write permission on website module'); +} + // SECURITY: You must explicitly enable this "connector". (Set it to "true"). // WARNING: don't just set "$Config['Enabled'] = true ;", you must be sure that only // authenticated users can access this file or use some kind of session checking.