Skip to content

Commit d0092f9

Browse files
committed
fix command injection (thanks @iwallplace)
1 parent 092d5d1 commit d0092f9

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

root/usr/libexec/rpcd/luci.https-dns-proxy

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,27 +112,17 @@ get_providers() {
112112
}
113113

114114
set_init_action() {
115-
local name="$1" action="$2" cmd
116-
117-
# SECURITY FIX: Validate name parameter to prevent command injection
118-
# CVE-202X-XXXXX: Privilege Escalation via unsanitized 'name' parameter
119-
# Fix by: Ahmet Mersin (ahmetmersin.com)
120-
# Only allow the expected package name
121-
if [ "$name" != "$packageName" ]; then
122-
logger "SECURITY: Rejected invalid name parameter: $name"
123-
print_json_bool "result" '0'
124-
return 1
125-
fi
126-
127-
case $action in
115+
local action="$2" cmd
116+
[ "$(basename "$1")" = "$packageName" ] || { print_json_bool 'result' '0'; return 1; }
117+
case $action in
128118
enable|disable|start|stop|restart)
129-
cmd="/etc/init.d/${name} ${action}"
119+
cmd="/etc/init.d/${packageName} ${action}"
130120
;;
131121
esac
132122
if [ -n "$cmd" ] && eval "$cmd" >/dev/null 2>&1; then
133-
print_json_bool "result" '1'
123+
print_json_bool 'result' '1'
134124
else
135-
print_json_bool "result" '0'
125+
print_json_bool 'result' '0'
136126
fi
137127
}
138128

0 commit comments

Comments
 (0)