Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better message auth #183

Merged
merged 4 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion phpThumb.config.php.default
Original file line number Diff line number Diff line change
Expand Up @@ -273,5 +273,5 @@ function phpThumbURL($ParameterString, $path_to_phpThumb='phpThumb.php') {
}
}
$ParameterString = implode($PHPTHUMB_CONFIG['high_security_url_separator'], $ParamterStringEncodedArray);
return $path_to_phpThumb.'?'.$ParameterString.$PHPTHUMB_CONFIG['high_security_url_separator'].'hash='.md5($ParameterString.$PHPTHUMB_CONFIG['high_security_password']);
return $path_to_phpThumb.'?'.$ParameterString.$PHPTHUMB_CONFIG['high_security_url_separator'].'hash='.hash_hmac('sha256', $ParameterString, $PHPTHUMB_CONFIG['high_security_password']);
}
3 changes: 1 addition & 2 deletions phpThumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,8 @@ function RedirectToCachedFile() {
} elseif (phpthumb_functions::PasswordStrength($phpThumb->config_high_security_password) < 20) {
$phpThumb->config_disable_debug = false; // otherwise error message won't print
$phpThumb->ErrorImage('ERROR: $PHPTHUMB_CONFIG[high_security_password] is not complex enough');
} elseif ($_GET['hash'] != md5(str_replace($phpThumb->config_high_security_url_separator.'hash='.$_GET['hash'], '', $_SERVER['QUERY_STRING']).$phpThumb->config_high_security_password)) {
} elseif ($_GET['hash'] != hash_hmac('sha256', str_replace($phpThumb->config_high_security_url_separator.'hash='.$_GET['hash'], '', $_SERVER['QUERY_STRING']), $phpThumb->config_high_security_password)) {
header('HTTP/1.0 403 Forbidden');
sleep(10); // deliberate delay to discourage password-guessing
$phpThumb->ErrorImage('ERROR: invalid hash');
}
}
Expand Down