🛡️ Sentinel: [MEDIUM] Fix shell script quoting and globbing vulnerabilities#37
🛡️ Sentinel: [MEDIUM] Fix shell script quoting and globbing vulnerabilities#37
Conversation
…lities 🚨 Severity: MEDIUM 💡 Vulnerability: Unquoted variable expansions in `entrypoint.sh` allowed for: 1. Password truncation if spaces were present. 2. Backslash interpretation in passwords/usernames due to `read` without `-r`. 3. Unintended globbing (filename expansion) when processing `VPNCMD_SERVER/HUB` commands. 4. Format string injection in `printf`. 🎯 Impact: - Users could have passwords silently truncated. - Passwords with backslashes would be corrupted. - Malicious or accidental input in `VPNCMD_*` variables could trigger file operations or execute unintended commands via globbing. 🔧 Fix: - Added `read -r` to prevent backslash interpretation. - Quoted all variables in `adduser` and `vpncmd` calls. - Wrapped dynamic command execution in `set -f; ...; set +f` to disable globbing while allowing argument splitting. - Fixed `printf` usage. ✅ Verification: - Verified syntax with `bash -n`. - Verified password handling with reproduction script. - Verified globbing prevention with reproduction script. Co-authored-by: bluPhy <11618798+bluPhy@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
WalkthroughA security documentation entry was added describing shell variable quoting and globbing vulnerabilities. Concurrently, an entrypoint shell script was hardened with consistent variable quoting, backslash-preserving read flags, and globbing controls to prevent word-splitting and unintended expansion risks. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Important Action Needed: IP Allowlist UpdateIf your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:
Reviews will stop working after February 8, 2026 if the new IP is not added to your allowlist. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @bluPhy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the security and robustness of the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@copyables/entrypoint.sh`:
- Around line 158-172: The loop reading into an array CMD (via read -r -a CMD)
only ever calls vpncmd_server or vpncmd_hub with $CMD which expands to ${CMD[0]}
and drops the rest; change the inner invocation to iterate all array elements —
e.g., after read -r -a CMD, loop over for entry in "${CMD[@]}"; do vpncmd_server
"$entry"; done (and likewise for vpncmd_hub) so every parsed semicolon-separated
command is executed.
| if [[ $VPNCMD_SERVER ]]; then | ||
| while IFS=";" read -ra CMD; do | ||
| while IFS=";" read -r -a CMD; do | ||
| set -f | ||
| vpncmd_server $CMD | ||
| set +f | ||
| done <<<"$VPNCMD_SERVER" | ||
| fi | ||
|
|
||
| if [[ $VPNCMD_HUB ]]; then | ||
| while IFS=";" read -ra CMD; do | ||
| while IFS=";" read -r -a CMD; do | ||
| set -f | ||
| vpncmd_hub $CMD | ||
| set +f | ||
| done <<<"$VPNCMD_HUB" | ||
| fi |
There was a problem hiding this comment.
Bug: Array expansion only uses first element, dropping subsequent commands.
ShellCheck SC2128 is correct here. When read -r -a CMD parses VPNCMD_SERVER by ; delimiter, multiple commands are stored in array elements. However, $CMD (line 161) expands only to ${CMD[0]}, silently discarding all other commands.
For example, if VPNCMD_SERVER="Cmd1 arg1;Cmd2 arg2":
CMD=("Cmd1 arg1" "Cmd2 arg2")- Only
Cmd1 arg1is executed;Cmd2 arg2is lost
This differs from the USERS parsing (lines 141-146) which correctly iterates with for i in "${USER[@]}".
Proposed fix to iterate over all array elements
if [[ $VPNCMD_SERVER ]]; then
while IFS=";" read -r -a CMD; do
- set -f
- vpncmd_server $CMD
- set +f
+ for c in "${CMD[@]}"; do
+ set -f
+ vpncmd_server $c
+ set +f
+ done
done <<<"$VPNCMD_SERVER"
fi
if [[ $VPNCMD_HUB ]]; then
while IFS=";" read -r -a CMD; do
- set -f
- vpncmd_hub $CMD
- set +f
+ for c in "${CMD[@]}"; do
+ set -f
+ vpncmd_hub $c
+ set +f
+ done
done <<<"$VPNCMD_HUB"
fi📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if [[ $VPNCMD_SERVER ]]; then | |
| while IFS=";" read -ra CMD; do | |
| while IFS=";" read -r -a CMD; do | |
| set -f | |
| vpncmd_server $CMD | |
| set +f | |
| done <<<"$VPNCMD_SERVER" | |
| fi | |
| if [[ $VPNCMD_HUB ]]; then | |
| while IFS=";" read -ra CMD; do | |
| while IFS=";" read -r -a CMD; do | |
| set -f | |
| vpncmd_hub $CMD | |
| set +f | |
| done <<<"$VPNCMD_HUB" | |
| fi | |
| if [[ $VPNCMD_SERVER ]]; then | |
| while IFS=";" read -r -a CMD; do | |
| for c in "${CMD[@]}"; do | |
| set -f | |
| vpncmd_server "$c" | |
| set +f | |
| done | |
| done <<<"$VPNCMD_SERVER" | |
| fi | |
| if [[ $VPNCMD_HUB ]]; then | |
| while IFS=";" read -r -a CMD; do | |
| for c in "${CMD[@]}"; do | |
| set -f | |
| vpncmd_hub "$c" | |
| set +f | |
| done | |
| done <<<"$VPNCMD_HUB" | |
| fi |
🧰 Tools
🪛 Shellcheck (0.11.0)
[warning] 161-161: Expanding an array without an index only gives the first element.
(SC2128)
[warning] 169-169: Expanding an array without an index only gives the first element.
(SC2128)
🤖 Prompt for AI Agents
In `@copyables/entrypoint.sh` around lines 158 - 172, The loop reading into an
array CMD (via read -r -a CMD) only ever calls vpncmd_server or vpncmd_hub with
$CMD which expands to ${CMD[0]} and drops the rest; change the inner invocation
to iterate all array elements — e.g., after read -r -a CMD, loop over for entry
in "${CMD[@]}"; do vpncmd_server "$entry"; done (and likewise for vpncmd_hub) so
every parsed semicolon-separated command is executed.
There was a problem hiding this comment.
Code Review
This pull request effectively hardens the entrypoint.sh script by implementing better variable quoting, preventing format string injection in printf, and disabling globbing during dynamic command execution, significantly improving its security and robustness. However, a critical logic error exists in the processing of VPNCMD_SERVER and VPNCMD_HUB environment variables. The current implementation only executes the first command in a semicolon-separated list, silently ignoring any additional commands, which could lead to security configurations being partially applied. This needs to be corrected to ensure all intended commands are executed.
| while IFS=";" read -r -a CMD; do | ||
| set -f | ||
| vpncmd_server $CMD | ||
| set +f | ||
| done <<<"$VPNCMD_SERVER" |
There was a problem hiding this comment.
The logic for processing multiple commands in VPNCMD_SERVER is flawed. The current implementation only executes the first command, silently ignoring any additional commands. This critical vulnerability could lead to security configurations being partially applied. To ensure all commands are executed, you must iterate over all elements of the array.
| while IFS=";" read -r -a CMD; do | |
| set -f | |
| vpncmd_server $CMD | |
| set +f | |
| done <<<"$VPNCMD_SERVER" | |
| while IFS=";" read -r -a CMDS; do | |
| for CMD in "${CMDS[@]}"; do | |
| set -f | |
| vpncmd_server $CMD | |
| set +f | |
| done | |
| done <<<"$VPNCMD_SERVER" |
| while IFS=";" read -r -a CMD; do | ||
| set -f | ||
| vpncmd_hub $CMD | ||
| set +f | ||
| done <<<"$VPNCMD_HUB" |
There was a problem hiding this comment.
Similar to the VPNCMD_SERVER processing, the logic for VPNCMD_HUB is flawed. It only executes the first command in a semicolon-separated list, silently ignoring subsequent commands. This critical vulnerability could lead to security configurations being partially applied. To ensure all commands are executed, you must iterate over all elements of the array.
| while IFS=";" read -r -a CMD; do | |
| set -f | |
| vpncmd_hub $CMD | |
| set +f | |
| done <<<"$VPNCMD_HUB" | |
| while IFS=";" read -r -a CMDS; do | |
| for CMD in "${CMDS[@]}"; do | |
| set -f | |
| vpncmd_hub $CMD | |
| set +f | |
| done | |
| done <<<"$VPNCMD_HUB" |
This PR addresses multiple shell scripting vulnerabilities in
copyables/entrypoint.sh. It enforces strict variable quoting, disables backslash interpretation inread, prevents format string injection, and safely handles dynamic command execution by disabling globbing. This ensures robust handling of user credentials and configuration commands.PR created automatically by Jules for task 209830914703777865 started by @bluPhy
Summary by CodeRabbit
Release Notes
Bug Fixes
Documentation