Skip to content

Commit a2845d4

Browse files
authored
Fix security issue in v-add-user-package + v-change-user-package (hestiacp#2171)
* Fix issue where shell could be executed during change of package * Replace the last eval * Also verify nameserver name servers format
1 parent 818aa4e commit a2845d4

File tree

4 files changed

+57
-15
lines changed

4 files changed

+57
-15
lines changed

bin/v-add-user-package

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ rewrite=$3
1818
# Includes
1919
# shellcheck source=/usr/local/hestia/func/main.sh
2020
source $HESTIA/func/main.sh
21+
# shellcheck source=/usr/local/hestia/func/domain.sh
22+
source $HESTIA/func/domain.sh
2123
# shellcheck source=/usr/local/hestia/conf/hestia.conf
2224
source $HESTIA/conf/hestia.conf
2325

@@ -65,6 +67,28 @@ is_package_consistent() {
6567
if [ "$BACKUPS" != 'unlimited' ]; then
6668
is_int_format_valid $BACKUPS 'BACKUPS'
6769
fi
70+
if [ -n "$WEB_TEMPLATE" ]; then
71+
is_web_template_valid $WEB_TEMPLATE
72+
fi
73+
if [ -n "$BACKEND_TEMPLATE" ]; then
74+
is_backend_template_valid $BACKEND_TEMPLATE
75+
fi
76+
if [ -n "$PROXY_TEMPLATE" ]; then
77+
is_proxy_template_valid $PROXY_TEMPLATE
78+
fi
79+
if [ -n "$DNS_TEMPLATE" ]; then
80+
is_dns_template_valid $DNS_TEMPLATE
81+
fi
82+
if [ -n "$NS" ]; then
83+
IFS=',' read -r -a nameservers <<< "$NS"
84+
i=1;
85+
for ns in "${nameservers[@]}"
86+
do
87+
is_domain_format_valid "$ns" "ns$i"
88+
i=$((i+1))
89+
done
90+
fi
91+
6892
is_format_valid_shell $SHELL
6993
}
7094

bin/v-change-user-package

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,8 @@ source $HESTIA/func/main.sh
2424
source $HESTIA/conf/hestia.conf
2525

2626
is_package_avalable() {
27-
28-
usr_data=$(cat $USER_DATA/user.conf)
29-
IFS=$'\n'
30-
for key in $usr_data; do
31-
eval ${key%%=*}=${key#*=}
32-
done
27+
28+
source $USER_DATA/user.conf
3329

3430
WEB_DOMAINS='0'
3531
DATABASES='0'
@@ -38,9 +34,7 @@ is_package_avalable() {
3834
DISK_QUOTA='0'
3935
BANDWIDTH='0'
4036

41-
pkg_data=$(cat $HESTIA/data/packages/$package.pkg |grep -v TIME |\
42-
grep -v DATE)
43-
eval $pkg_data
37+
source $HESTIA/data/packages/$package.pkg
4438

4539
# Checking usage agains package limits
4640
if [ "$WEB_DOMAINS" != 'unlimited' ]; then
@@ -81,8 +75,11 @@ is_package_avalable() {
8175
}
8276

8377
change_user_package() {
84-
eval $(cat $USER_DATA/user.conf)
85-
eval $(cat $HESTIA/data/packages/$package.pkg |egrep -v "TIME|DATE")
78+
source $USER_DATA/user.conf
79+
# Keep user creation date and time saved
80+
time="$TIME"
81+
date="$DATE"
82+
source $HESTIA/data/packages/$package.pkg
8683
echo "NAME='$NAME'
8784
PACKAGE='$package'
8885
WEB_TEMPLATE='$WEB_TEMPLATE'
@@ -144,8 +141,8 @@ PREF_UI_SORT='$PREF_UI_SORT'
144141
LOGIN_DISABLED='$LOGIN_DISABLED'
145142
LOGIN_USE_IPLIST='$LOGIN_USE_IPLIST'
146143
LOGIN_ALLOW_IPS='$LOGIN_ALLOW_IPS'
147-
TIME='$TIME'
148-
DATE='$DATE'" > $USER_DATA/user.conf
144+
TIME='$time'
145+
DATE='$date'" > $USER_DATA/user.conf
149146
}
150147

151148

@@ -173,7 +170,7 @@ check_hestia_demo_mode
173170
change_user_package
174171

175172
# Update user shell
176-
shell_conf=$(echo "$pkg_data" | grep 'SHELL' | cut -f 2 -d \')
173+
shell_conf=$(cat $HESTIA/data/packages/$package.pkg | grep 'SHELL' | cut -f 2 -d \')
177174
$BIN/v-change-user-shell $user $shell_conf
178175

179176
# Run template trigger

install/deb/nginx/phpmyadmin.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
location /%pma_alias% {
22
alias /usr/share/phpmyadmin/;
33

4-
location ~ /(libraries|setup|templates|locale|sql)/ {
4+
location ~ /(libraries|setup|templates|locale) {
55
deny all;
66
return 404;
77
}

install/upgrade/versions/1.4.18.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
# Hestia Control Panel upgrade script for target version 1.4.18
4+
5+
#######################################################################################
6+
####### Place additional commands below. #######
7+
#######################################################################################
8+
####### Pass trough information to the end user incase of a issue or problem #######
9+
####### #######
10+
####### Use add_upgrade_message "My message here" to include a message #######
11+
####### to the upgrade email. Please add it using: #######
12+
####### #######
13+
####### add_upgrade_message "My message here" #######
14+
####### #######
15+
####### You can use \n within the string to create new lines. #######
16+
#######################################################################################
17+
18+
if [ ! -z "$DB_PMA_ALIAS" ]; then
19+
$HESTIA/bin/v-change-sys-db-alias 'pma' $DB_PMA_ALIAS
20+
fi
21+

0 commit comments

Comments
 (0)