Skip to content

Conversation

@bluPhy
Copy link
Owner

@bluPhy bluPhy commented Jan 28, 2026

🛡️ Sentinel: [HIGH] Harden entrypoint.sh script execution

Severity: HIGH

Vulnerability:

  1. Command Injection/Logic Flaw: The entrypoint.sh script incorrectly processed semicolon-separated commands in VPNCMD_SERVER and VPNCMD_HUB. It read them into an array but only executed the first element ($CMD instead of ${CMDS[@]}), silently ignoring subsequent commands which might be critical for security configuration.
  2. Data Integrity/Security: Variables (passwords, usernames, paths) were unquoted, leading to potential word splitting and globbing issues.
  3. Input Parsing: read was used without -r, causing backslashes in passwords to be interpreted as escape characters.

Fix:

  • Added read -r to all read commands.
  • Quoted variables ($username, $password, $CONFIG, etc.) to prevent splitting.
  • Fixed the loop logic to iterate over all commands in the array for VPNCMD_SERVER and VPNCMD_HUB.
  • Created .jules/sentinel.md to document the learning.

Verification:

  • Verified syntax with bash -n.
  • Verified logic with a test script confirming multi-command execution and correct handling of spaces/backslashes in inputs.

PR created automatically by Jules for task 5829468812831589290 started by @bluPhy

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced shell script robustness with improved variable quoting and safer read operations.
    • Improved handling of special characters and spaces in configuration values and user inputs.
  • Documentation

    • Added security documentation detailing shell script vulnerabilities and recommended prevention practices.

✏️ Tip: You can customize this high-level summary in your review settings.

Co-authored-by: bluPhy <11618798+bluPhy@users.noreply.github.com>
@google-labs-jules
Copy link

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@gemini-code-assist
Copy link

Summary of Changes

Hello @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 hardens the entrypoint.sh script by addressing critical shell scripting vulnerabilities. The changes ensure that commands are executed completely, sensitive data is handled securely through proper quoting, and user input is parsed without unintended modifications. These improvements enhance the overall security and reliability of the script's execution.

Highlights

  • Command Execution Logic Fix: The entrypoint.sh script now correctly processes and executes all semicolon-separated commands provided in VPNCMD_SERVER and VPNCMD_HUB variables, resolving a previous issue where only the first command was executed.
  • Variable Quoting for Security: All relevant variables, including $CONFIG, $username, and $password, are now properly quoted throughout the script to prevent word splitting and globbing issues, enhancing data integrity and security.
  • Input Parsing Hardening: The -r option has been added to all read commands in the script. This prevents backslashes from being interpreted as escape characters, ensuring that input, especially passwords, is parsed literally and correctly.
  • Security Documentation Added: A new markdown file, .jules/sentinel.md, has been added to document the vulnerabilities and learnings related to shell script variable expansion and read pitfalls, providing future reference and prevention guidelines.

🧠 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.

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link

coderabbitai bot commented Jan 28, 2026

Walkthrough

This PR adds a security journal entry documenting shell script variable expansion vulnerabilities and updates an entrypoint script to improve robustness through proper variable quoting and safer read patterns.

Changes

Cohort / File(s) Summary
Security Documentation
.jules/sentinel.md
New security journal entry detailing shell script variable expansion and read pitfalls, documenting vulnerabilities related to unquoted expansion and unsafe read usage with prevention guidance
Shell Script Hardening
copyables/entrypoint.sh
Added variable quoting around CONFIG path references, replaced unsafe read patterns with read -r variants for safer parsing, and wrapped username/password arguments in adduser invocations to prevent word-splitting and special character interpretation

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 With quotes around each variable dear,
And read -r guarding against fear,
No word-splits shall break the line,
Our shell scripts now are secure and fine!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title references the main change (hardening entrypoint.sh) but uses an emoji and severity tag, making it less ideal for scannable history.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sentinel-harden-entrypoint-5829468812831589290

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@copyables/entrypoint.sh`:
- Around line 159-162: The loop calling vpncmd_server currently invokes it with
an unquoted scalar ("vpncmd_server $cmd") which allows pathname expansion; to
fix, re-parse each command string into an array and call vpncmd_server with the
array expansion (e.g., read -r -a ARGS <<< "$cmd" then call vpncmd_server
"${ARGS[@]}") or temporarily disable globbing with set -f around the invocation
and restore it, and apply the same change to the other occurrence mentioned (the
block at the later loop around lines 167-170); reference vpncmd_server, CMDS and
cmd when making the change.

Comment on lines +159 to +162
while IFS=";" read -r -a CMDS; do
for cmd in "${CMDS[@]}"; do
vpncmd_server $cmd
done
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Prevent globbing when dispatching VPNCMD commands.
vpncmd_* $cmd still expands globs and can mutate arguments from user-provided env vars. Re-parse into an array and pass quoted to keep splitting but block globbing.

🔧 Proposed fix
-      for cmd in "${CMDS[@]}"; do
-        vpncmd_server $cmd
-      done
+      for cmd in "${CMDS[@]}"; do
+        [[ -z "$cmd" ]] && continue
+        read -r -a CMD_PARTS <<<"$cmd"
+        vpncmd_server "${CMD_PARTS[@]}"
+      done
@@
-      for cmd in "${CMDS[@]}"; do
-        vpncmd_hub $cmd
-      done
+      for cmd in "${CMDS[@]}"; do
+        [[ -z "$cmd" ]] && continue
+        read -r -a CMD_PARTS <<<"$cmd"
+        vpncmd_hub "${CMD_PARTS[@]}"
+      done

Also applies to: 167-170

🤖 Prompt for AI Agents
In `@copyables/entrypoint.sh` around lines 159 - 162, The loop calling
vpncmd_server currently invokes it with an unquoted scalar ("vpncmd_server
$cmd") which allows pathname expansion; to fix, re-parse each command string
into an array and call vpncmd_server with the array expansion (e.g., read -r -a
ARGS <<< "$cmd" then call vpncmd_server "${ARGS[@]}") or temporarily disable
globbing with set -f around the invocation and restore it, and apply the same
change to the other occurrence mentioned (the block at the later loop around
lines 167-170); reference vpncmd_server, CMDS and cmd when making the change.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request aims to enhance the security and robustness of the entrypoint.sh script by addressing critical vulnerabilities related to command injection, data integrity, and input parsing. While it correctly implements read -r for safer input handling and quotes variables to prevent unintended word splitting and globbing, the hardening is incomplete. The $cmd variable remains unquoted in the loops for VPNCMD_SERVER and VPNCMD_HUB, leaving the script vulnerable to globbing and incorrect argument splitting if environment variables are untrusted. The PR also includes valuable documentation in .jules/sentinel.md regarding identified vulnerabilities and their prevention.

vpncmd_server $CMD
while IFS=";" read -r -a CMDS; do
for cmd in "${CMDS[@]}"; do
vpncmd_server $cmd

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-medium medium

The original logic only executed the first command in a semicolon-separated list, silently ignoring subsequent commands, which was a critical logic flaw. However, the variable $cmd is still expanded without double quotes, which can lead to globbing and insecure word splitting. If an attacker can influence VPNCMD_SERVER (e.g., by including a * character), the shell will expand it to filenames, passing unexpected arguments to the VPN command. This undermines the PR's security hardening goals. A temporary array should be used to safely split the command string.

Suggested change
vpncmd_server $cmd
read -r -a cmd_args <<< "$cmd"
vpncmd_server "${cmd_args[@]}"

vpncmd_hub $CMD
while IFS=";" read -r -a CMDS; do
for cmd in "${CMDS[@]}"; do
vpncmd_hub $cmd

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-medium medium

Similar to the VPNCMD_SERVER block, ensuring all commands from VPNCMD_HUB are executed is essential for proper configuration and security. However, the $cmd variable is expanded without double quotes, which triggers globbing and insecure word splitting. This should be handled safely using an array to prevent unexpected behavior if the command contains glob characters or spaces, which could lead to silent failures of critical steps.

Suggested change
vpncmd_hub $cmd
read -r -a cmd_args <<< "$cmd"
vpncmd_hub "${cmd_args[@]}"

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

if [ ! -f $CONFIG ] || [ ! -s $CONFIG ]; then
if [ ! -f "$CONFIG" ] || [ ! -s "$CONFIG" ]; then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The change to quote $CONFIG is a good practice. Unquoted variables can lead to unexpected behavior due to word splitting or globbing, especially if the path contains spaces or special characters. This improves the script's robustness and security.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants