diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index 4ba48e83145..67b69d3149d 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -662,8 +662,24 @@ print '
'; print 'MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE = '.getDolGlobalString('MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Recommended").': 1)
'; print '
'; +print 'MAIN_SECURITY_ANTI_SSRF_SERVER_IP = '.getDolGlobalString('MAIN_SECURITY_ANTI_SSRF_SERVER_IP', ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': List of static IPs of server separated with coma - '.$langs->trans("Note").': common loopback ip like 127.*.*.*, [::1] are already added)')."
"; +print '
'; + +print 'MAIN_SECURITY_CSRF_WITH_TOKEN = '.getDolGlobalString('MAIN_SECURITY_CSRF_WITH_TOKEN', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 2)'."
"; + +print ''; + + +print '
'; +print '
'; + + +print load_fiche_titre($langs->trans("DatabaseEncryption"), '', 'folder'); + +print '
'; + //print ''.$langs->trans("PasswordEncryption").': '; -print 'MAIN_SECURITY_HASH_ALGO = '.getDolGlobalString('MAIN_SECURITY_HASH_ALGO', ''.$langs->trans("Undefined").'')."   "; +print ''.$langs->trans("AlgorithmFor", $langs->transnoentitiesnoconv("Passwords")).' (non reversible encryption, defined into MAIN_SECURITY_HASH_ALGO) = '.getDolGlobalString('MAIN_SECURITY_HASH_ALGO', ''.$langs->trans("Undefined").'')."   "; if (!getDolGlobalString('MAIN_SECURITY_HASH_ALGO')) { print '     (If unset: \'md5\')'; } @@ -683,10 +699,22 @@ if (getDolGlobalString('MAIN_SECURITY_HASH_ALGO') != 'password_hash') { } print '
'; -print 'MAIN_SECURITY_ANTI_SSRF_SERVER_IP = '.getDolGlobalString('MAIN_SECURITY_ANTI_SSRF_SERVER_IP', ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': List of static IPs of server separated with coma - '.$langs->trans("Note").': common loopback ip like 127.*.*.*, [::1] are already added)')."
"; -print '
'; +$action = GETPOST('action'); +$exampletodecrypt = GETPOST('exampletodecrypt', 'password'); -print 'MAIN_SECURITY_CSRF_WITH_TOKEN = '.getDolGlobalString('MAIN_SECURITY_CSRF_WITH_TOKEN', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 2)'."
"; +print ''.$langs->trans("AlgorithmFor", $langs->transnoentitiesnoconv("SensitiveData")).' (reversible encryption done with dolEncrypt/dolDecrypt) = '.constant('MAIN_SECURITY_REVERSIBLE_ALGO').' with key defined into conf.php file in $dolibarr_main_instance_unique_id
'; +print '
'; +print ''; +print ''; +print ''; +print $langs->trans("ToolToDecryptAString").': '; +print ''; +print ''; +if ($action == 'doldecrypt' && $user->admin && $exampletodecrypt) { + usleep(200); + print ' => '; +} +print '
'; print '
'; diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index ec6de2992d2..1f1cb081421 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -107,6 +107,9 @@ function dolGetRandomBytes($length) return bin2hex(openssl_random_pseudo_bytes((int) floor($length / 2))); // the bin2hex will double the number of bytes so we take length / 2. May be very slow on Windows. } + +define('MAIN_SECURITY_REVERSIBLE_ALGO', 'AES-256-CTR'); + /** * Encode a string with a symmetric encryption. Used to encrypt sensitive data into database. * Note: If a backup is restored onto another instance with a different $conf->file->instance_unique_id, then decoded value will differ. @@ -120,7 +123,7 @@ function dolGetRandomBytes($length) * @since v17 * @see dolDecrypt(), dol_hash() */ -function dolEncrypt($chain, $key = '', $ciphering = 'AES-256-CTR', $forceseed = '') +function dolEncrypt($chain, $key = '', $ciphering = '', $forceseed = '') { global $conf; global $dolibarr_disable_dolcrypt_for_debug; @@ -139,7 +142,7 @@ function dolEncrypt($chain, $key = '', $ciphering = 'AES-256-CTR', $forceseed = $key = $conf->file->instance_unique_id; } if (empty($ciphering)) { - $ciphering = 'AES-256-CTR'; + $ciphering = constant('MAIN_SECURITY_REVERSIBLE_ALGO'); } $newchain = $chain; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index bcfebcbc286..feb598ef0c9 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2576,3 +2576,8 @@ YouHaveALargeAmountOfRecordOnLists=You have a default max size for lists set to RoundBorders=Round borders CheckIfModuleIsNotBlackListed=Block install for modules found into the Remote blacklist CheckIfModuleIsNotBlackListedHelp=Some modules may be provided by some companies that do not respect the project's rules of goodwill (non-compliance with GDPR, violation of the rules tof use the Dolibarr brand name, etc.). By checking this box, a request will be made to the project server to see if a report was received about this module, and will protect you by blocking the deployment of flagged modules +DatabaseEncryption=Encryption in database +AlgorithmFor=Algorithm for: %s +SensitiveData=Sensitive data +ToolToDecryptAString=Tool to decrypt a string +Decrypt=Decrypt