Skip to content

Commit d50f95c

Browse files
authored
[Security] Patches multiple security issue (hestiacp#2555)
* Add missing check in is_format_valid * Add check on v-delete-dns-domain * Validate theme via is_format_valid * No need for extra code * Prevent LF command passed trough + Add test to verify * Add missing checks * Don't allow exception for localhost * Add some more missing checks * Fix to strict error validation * Add validation for user * Fix bug in main.sh * Use -d instead -f
1 parent e243d34 commit d50f95c

32 files changed

+444
-36
lines changed

bin/v-add-access-key

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,9 @@ date=$(echo "$time_n_date" |cut -f 2 -d \ )
6161
#----------------------------------------------------------#
6262

6363
check_args '1' "$#" 'USER [PERMISSIONS] [COMMENT] [FORMAT]'
64-
is_format_valid 'user'
64+
is_format_valid 'user' 'comment' 'format'
6565
is_object_valid 'user' 'USER' "$user"
6666
is_key_permissions_format_valid "$permissions" "$user"
67-
if [ -n "$comment" ]; then
68-
is_format_valid 'comment'
69-
fi
7067

7168
#----------------------------------------------------------#
7269
# Action #

bin/v-add-backup-host

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ EOF
107107
if [ "$type" != 'local' ];then
108108
check_args '4' "$#" "TYPE HOST USERNAME PASSWORD [PATH] [PORT]"
109109
is_format_valid 'host' 'path' 'port'
110-
is_username_format_valid "$username" "username"
110+
is_type_valid "$type" 'sftp,ftp,b2'
111+
is_username_format_valid "$user" "username"
111112
is_password_valid
112113
format_no_quotes "$password" "password"
113114

bin/v-add-cron-job

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ is_object_unsuspended 'user' 'USER' "$user"
4444
is_package_full 'CRON_JOBS'
4545
get_next_cronjob
4646
is_format_valid 'job'
47+
is_format_valid 'restart'
4748
is_object_new 'cron' 'JOB' "$job"
4849

4950
# Perform verification if read-only mode is enabled

bin/v-add-dns-domain

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ if [ -z "$(is_ip_format_valid $domain)" ]; then
6666
exit 1
6767
fi
6868

69+
if [ -n "$restart" ]; then
70+
is_format_valid 'restart'
71+
fi
72+
6973
is_package_full 'DNS_DOMAINS'
7074
template=$(get_user_value '$DNS_TEMPLATE')
7175
is_dns_template_valid "$template"

bin/v-add-dns-record

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ is_object_new "dns/$domain" 'ID' "$id"
9696
is_dns_fqnd "$rtype" "$dvalue"
9797
is_dns_nameserver_valid "$domain" "$rtype" "$dvalue"
9898
is_format_valid 'ttl'
99+
if [ -n "$restart" ]; then
100+
is_format_valid 'restart'
101+
fi
99102

100103
# Perform verification if read-only mode is enabled
101104
check_hestia_demo_mode

bin/v-add-fastcgi-cache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ source_conf "$HESTIA/conf/hestia.conf"
3131
#----------------------------------------------------------#
3232

3333
check_args '2' "$#" 'USER DOMAIN [DURATION] [DEBUG] [RESTART]'
34-
is_format_valid 'user' 'domain'
34+
is_format_valid 'user' 'domain' 'restart'
3535
is_object_valid 'user' 'USER' "$user"
3636
is_object_unsuspended 'user' 'USER' "$user"
3737
is_object_valid 'web' 'DOMAIN' "$domain"

bin/v-add-firewall-chain

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# Argument definition
1414
chain=$(echo $1 | tr '[:lower:]' '[:upper:]')
1515
port=$2
16+
port_ext=$2
1617
protocol=${4-TCP}
1718
protocol=$(echo $protocol|tr '[:lower:]' '[:upper:]')
1819

@@ -40,7 +41,7 @@ source_conf "$HESTIA/conf/hestia.conf"
4041
#----------------------------------------------------------#
4142

4243
check_args '1' "$#" 'CHAIN [PORT] [PROTOCOL]'
43-
is_format_valid 'chain'
44+
is_format_valid 'chain' 'port_ext' 'protocol'
4445
is_system_enabled "$FIREWALL_SYSTEM" 'FIREWALL_SYSTEM'
4546

4647
# Perform verification if read-only mode is enabled

bin/v-add-mail-domain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ domain_utf=$(idn -t --quiet -u "$domain_idn")
5050
#----------------------------------------------------------#
5151

5252
check_args '2' "$#" 'USER DOMAIN [ANTISPAM] [ANTIVIRUS] [DKIM] [DKIM_SIZE]'
53-
is_format_valid 'user' 'domain' 'antispam' 'antivirus' 'dkim' 'dkim_size'
53+
is_format_valid 'user' 'domain' 'antispam' 'antivirus' 'dkim' 'dkim_size' 'restart'
5454
is_system_enabled "$MAIL_SYSTEM" 'MAIL_SYSTEM'
5555
is_object_valid 'user' 'USER' "$user"
5656
is_object_unsuspended 'user' 'USER' "$user"

bin/v-add-mail-domain-ssl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ is_web_domain_cert_valid
6363
# Perform verification if read-only mode is enabled
6464
check_hestia_demo_mode
6565

66+
if [ -n "$restart" ]; then
67+
is_format_valid "$restart"
68+
fi
6669
#----------------------------------------------------------#
6770
# Action #
6871
#----------------------------------------------------------#

bin/v-add-mail-domain-webmail

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ if [ -z "$webmail" ]; then
6161
fi
6262

6363
check_args '2' "$#" 'USER DOMAIN [WEBMAIL] [RESTART]'
64-
is_format_valid 'user' 'domain'
64+
is_format_valid 'user' 'domain' 'restart'
6565
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
6666
is_system_enabled "$IMAP_SYSTEM" 'IMAP_SYSTEM'
6767
is_type_valid "$WEBMAIL_SYSTEM disabled" "$webmail"

0 commit comments

Comments
 (0)