-
Notifications
You must be signed in to change notification settings - Fork 0
π‘οΈ Sentinel: [HIGH] Fix shell quoting and command processing vulnerabilities #31
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| ## 2025-05-23 - Shell Script Variable Quoting and Globbing | ||
| **Vulnerability:** Found unquoted variables in `adduser` loop allowing password truncation/corruption (spaces/globs), and `VPNCMD_*` command processing vulnerable to glob injection and logic error (ignoring subsequent commands). | ||
| **Learning:** In bash, unquoted variables are subject to word splitting and glob expansion. `read` without `-r` interprets backslashes. Loops over `read` output need careful logic to ensure all input is processed. | ||
| **Prevention:** Always quote variables (`"$var"`) unless word splitting is explicitly intended. Use `read -r`. Use `set -f` when relying on word splitting but wanting to avoid globbing. Verify loop logic for multi-line/delimiter processing. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -140,13 +140,13 @@ if [ ! -f $CONFIG ] || [ ! -s $CONFIG ]; then | |||||||||||||||||||
| if [[ $USERS ]]; then | ||||||||||||||||||||
| while IFS=';' read -ra USER; do | ||||||||||||||||||||
| for i in "${USER[@]}"; do | ||||||||||||||||||||
| IFS=':' read username password <<<"$i" | ||||||||||||||||||||
| IFS=':' read -r username password <<<"$i" | ||||||||||||||||||||
| # echo "Creating user: ${username}" | ||||||||||||||||||||
| adduser $username $password | ||||||||||||||||||||
| adduser "$username" "$password" | ||||||||||||||||||||
| done | ||||||||||||||||||||
| done <<<"$USERS" | ||||||||||||||||||||
| else | ||||||||||||||||||||
| adduser $USERNAME $PASSWORD | ||||||||||||||||||||
| adduser "$USERNAME" "$PASSWORD" | ||||||||||||||||||||
| fi | ||||||||||||||||||||
|
|
||||||||||||||||||||
| echo | ||||||||||||||||||||
|
|
@@ -156,15 +156,21 @@ if [ ! -f $CONFIG ] || [ ! -s $CONFIG ]; then | |||||||||||||||||||
|
|
||||||||||||||||||||
| # handle VPNCMD_* commands right before setting admin passwords | ||||||||||||||||||||
| if [[ $VPNCMD_SERVER ]]; then | ||||||||||||||||||||
| while IFS=";" read -ra CMD; do | ||||||||||||||||||||
| vpncmd_server $CMD | ||||||||||||||||||||
| done <<<"$VPNCMD_SERVER" | ||||||||||||||||||||
| set -f | ||||||||||||||||||||
| IFS=";" read -ra CMDS <<<"$VPNCMD_SERVER" | ||||||||||||||||||||
| for cmd in "${CMDS[@]}"; do | ||||||||||||||||||||
| vpncmd_server $cmd | ||||||||||||||||||||
| done | ||||||||||||||||||||
| set +f | ||||||||||||||||||||
|
Comment on lines
+159
to
+164
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π§© Analysis chainπ Script executed: # First, locate and read the entrypoint.sh file
find . -name "entrypoint.sh" -type f | head -20Repository: bluPhy/docker-softether Length of output: 92 π Script executed: # If found, let's read the relevant lines from the file
# Read around lines 159-164 and 168-173
if [ -f "copyables/entrypoint.sh" ]; then
echo "=== Lines 155-175 of copyables/entrypoint.sh ==="
sed -n '155,175p' copyables/entrypoint.sh | cat -n
fiRepository: bluPhy/docker-softether Length of output: 687 π Script executed: #!/bin/bash
set -euo pipefail
VPNCMD_SERVER='CmdA /ARG:pa\\ss;CmdB'
echo "Testing read behavior with and without -r flag:"
echo "Input: $VPNCMD_SERVER"
echo ""
IFS=";" read -a CMDS <<<"$VPNCMD_SERVER"
printf 'without -r: %q\n' "${CMDS[@]}"
IFS=";" read -r -a CMDS <<<"$VPNCMD_SERVER"
printf 'with -r: %q\n' "${CMDS[@]}"Repository: bluPhy/docker-softether Length of output: 234 Add Lines 160 and 169 use Proposed fix- IFS=";" read -ra CMDS <<<"$VPNCMD_SERVER"
+ IFS=";" read -r -a CMDS <<<"$VPNCMD_SERVER"- IFS=";" read -ra CMDS <<<"$VPNCMD_HUB"
+ IFS=";" read -r -a CMDS <<<"$VPNCMD_HUB"Also applies to: 168-173 π€ Prompt for AI Agents |
||||||||||||||||||||
| fi | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if [[ $VPNCMD_HUB ]]; then | ||||||||||||||||||||
| while IFS=";" read -ra CMD; do | ||||||||||||||||||||
| vpncmd_hub $CMD | ||||||||||||||||||||
| done <<<"$VPNCMD_HUB" | ||||||||||||||||||||
| set -f | ||||||||||||||||||||
| IFS=";" read -ra CMDS <<<"$VPNCMD_HUB" | ||||||||||||||||||||
| for cmd in "${CMDS[@]}"; do | ||||||||||||||||||||
| vpncmd_hub $cmd | ||||||||||||||||||||
| done | ||||||||||||||||||||
|
Comment on lines
+170
to
+172
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the
Suggested change
|
||||||||||||||||||||
| set +f | ||||||||||||||||||||
| fi | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # set password for hub | ||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While
set -fcorrectly prevents globbing, the unquoted expansion of$cmdperforms word splitting that doesn't respect quotes within the command string. This will cause arguments containing spaces to be split incorrectly. For example, a command likeUserSetPassword user "new password"would be broken. Usingxargscan parse the command string correctly and handle quoted arguments, providing a safer alternative toeval.