Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 2024-05-23 - [Variable Quoting in Shell Scripts]
**Vulnerability:** Unquoted variable expansion in `entrypoint.sh` caused passwords with spaces to be truncated when passed to the `adduser` function.
**Learning:** Shell word splitting can silently corrupt data integrity, specifically credentials, leading to weaker passwords than intended. This is often overlooked in "simple" wrapper scripts.
**Prevention:** Always quote variable expansions (`"$var"`) unless word splitting is explicitly required and understood. Use tools like `checkbashisms` or `shellcheck` (though not available here) to detect these issues.
16 changes: 9 additions & 7 deletions copyables/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ set -e

CONFIG=/var/lib/softether/vpn_server.config

if [ ! -f $CONFIG ] || [ ! -s $CONFIG ]; then
if [ ! -f "$CONFIG" ] || [ ! -s "$CONFIG" ]; then
# Generate a random PSK if not provided
: ${PSK:=$(cat /dev/urandom | tr -dc 'A-Za-z0-9' | fold -w 20 | head -n 1)}

Expand Down Expand Up @@ -142,11 +142,11 @@ if [ ! -f $CONFIG ] || [ ! -s $CONFIG ]; then
for i in "${USER[@]}"; do
IFS=':' read 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
Expand All @@ -156,15 +156,17 @@ if [ ! -f $CONFIG ] || [ ! -s $CONFIG ]; then

# handle VPNCMD_* commands right before setting admin passwords
if [[ $VPNCMD_SERVER ]]; then
while IFS=";" read -ra CMD; do
IFS=";" read -ra COMMANDS <<<"$VPNCMD_SERVER"
for CMD in "${COMMANDS[@]}"; do
vpncmd_server $CMD
done <<<"$VPNCMD_SERVER"
done
fi

if [[ $VPNCMD_HUB ]]; then
while IFS=";" read -ra CMD; do
IFS=";" read -ra COMMANDS <<<"$VPNCMD_HUB"
for CMD in "${COMMANDS[@]}"; do
vpncmd_hub $CMD
done <<<"$VPNCMD_HUB"
done
fi

# set password for hub
Expand Down