Skip to content

Commit 7e9948d

Browse files
committed
Patch security issue on empty salt
A configured salt is necessary for generating security keys According to the comment above its definition, keeping it empty was supposed to disable the feature. Instead, it kept it insecurely enabled and used the empty salt, giving absolutely predictible security keys considered as valid instead of not returning any Note that commenting-out the define properly disabled this feature This behavior is now fixed. If you do not update and have an empty salt, either remove/comment the define, or set one immediately Default allowed file extensions have also been edited, showing regex are supported (which they are since the beginning) to make sure users are aware of that possibility as it wasn't documented Version bumped to 2.1.1
1 parent 5889fca commit 7e9948d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

sharexen.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,23 @@
2525
]);
2626

2727
// Security keys salt - NEVER SHARE THIS
28-
// Format: define('SALT', 'randomstring');
2928
// Used to generate and compute security keys
3029
// Changing this will render all previously generated
3130
// deletion URLs invalid without any exception
32-
// Keep empty to disable this feature, only admins will
33-
// then be able to delete files without security keys
31+
// Keep as-is, set empty, or remove the define
32+
// to disable this feature, only admins will then
33+
// be able to delete files without security keys
3434
// Mandatory for having deletion URLs, set this to
3535
// a very long and random string of various characters
3636
// Random generator: https://bfnt.io/pwgen
37-
define('SALT', '');
37+
define('SALT', 'change-me');
3838

3939
// List of allowed image extensions
4040
// Only put image extensions here unless
4141
// you edit the MIME_TYPE_REGEX option as well,
4242
// which is very discouraged for security reasons
43-
define('EXTS', ['png', 'jpg', 'jpeg', 'gif', 'webm', 'mp4']);
43+
// Regular expressions can be used as well here
44+
define('EXTS', ['png', 'jpe?g', 'gif', 'webm', 'mp4']);
4445

4546

4647
/* OPTIONAL CONSTANTS BELOW THIS LINE */
@@ -119,7 +120,7 @@
119120
\*****************************/
120121

121122

122-
define('VERSION', '2.1.0');
123+
define('VERSION', '2.1.1');
123124
define('SOURCE', 'https://github.com/Xenthys/ShareXen');
124125

125126
$data = [
@@ -346,7 +347,7 @@ function error_die(&$data, $code, $reason = 'unknown_error', $debug = '')
346347

347348
function retrieve_key($name)
348349
{
349-
if (!defined('SALT'))
350+
if (!defined('SALT') || !SALT || SALT === "change-me")
350351
{
351352
return false;
352353
}

0 commit comments

Comments
 (0)