Skip to content

Commit 3fdee29

Browse files
author
Serghey Rodin
committed
Hardening password checks
1 parent ffdae1d commit 3fdee29

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

bin/v-check-user-password

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ if [ -z "$salt" ]; then
8282
fi
8383

8484
# Generating hash
85-
hash=$($BIN/v-generate-password-hash $method $salt <<< $password)
85+
hash=$($BIN/v-generate-password-hash $method $salt <<< "$password")
8686
if [[ -z "$hash" ]]; then
8787
echo "Error: password missmatch"
8888
echo "$date $time $user $ip failed to login" >> $VESTA/log/auth.log

func/main.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ is_object_value_exist() {
273273
is_password_valid() {
274274
if [[ "$password" =~ ^/tmp/ ]]; then
275275
if [ -f "$password" ]; then
276-
password=$(head -n1 $password)
276+
password="$(head -n1 $password)"
277277
fi
278278
fi
279279
}

web/api/index.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
fwrite($fp, $_POST['password']."\n");
1919
fclose($fp);
2020
$v_ip_addr = escapeshellarg($_SERVER["REMOTE_ADDR"]);
21-
exec(VESTA_CMD ."v-check-user-password ".$v_user." ".$v_password." '".$v_ip_addr."'", $output, $auth_code);
21+
exec(VESTA_CMD ."v-check-user-password ".$v_user." ".escapeshellarg($v_password)." '".$v_ip_addr."'", $output, $auth_code);
2222
unlink($v_password);
23+
/* No hash auth for security reason
2324
} else {
2425
$key = '/usr/local/vesta/data/keys/' . basename($_POST['hash']);
2526
if (file_exists($key) && is_file($key)) {
2627
$auth_code = '0';
2728
}
29+
*/
2830
}
2931

3032
if ($auth_code != 0 ) {

web/login/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
fclose($fp);
4545

4646
// Check user & password
47-
exec(VESTA_CMD ."v-check-user-password ".$v_user." ".$v_password." ".escapeshellarg($_SERVER['REMOTE_ADDR']), $output, $return_var);
47+
exec(VESTA_CMD ."v-check-user-password ".$v_user." ".escapeshellarg($v_password)." ".escapeshellarg($_SERVER['REMOTE_ADDR']), $output, $return_var);
4848
unset($output);
4949

5050
// Remove tmp file

0 commit comments

Comments
 (0)