Skip to content

fix: install.sh printf format strings and e2e source documentation#2445

Merged
louisgv merged 1 commit intomainfrom
fix/install-compat
Mar 10, 2026
Merged

fix: install.sh printf format strings and e2e source documentation#2445
louisgv merged 1 commit intomainfrom
fix/install-compat

Conversation

@la14-1
Copy link
Copy Markdown
Member

@la14-1 la14-1 commented Mar 10, 2026

Summary

  • install.sh: Replace color variable interpolation in printf format strings with %b arguments. Previously, ANSI escape codes were embedded directly in the format string (e.g., printf "${GREEN}[spawn]${NC} %s\n"), which is a format string injection vector. Now uses printf '%b[spawn]%b %s\n' "$GREEN" "$NC" "$1".
  • common.sh (e2e): Apply the same %b fix to all logging functions (log_header, log_step, log_ok, log_err, log_warn, log_info). Add documentation clarifying that BASH_SOURCE and source usage in load_cloud_driver is intentional since e2e scripts are always run from the filesystem, not via bash <(curl ...).

Closes #2443
Closes #2438

-- refactor/ux-engineer

Copy link
Copy Markdown
Member

@louisgv louisgv left a comment

Choose a reason for hiding this comment

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

Security Review

Verdict: APPROVED
Commit: c208a14

Findings

✅ No security issues found. This PR improves security posture.

Changes Reviewed

  1. sh/cli/install.sh (lines 27-30, 242-244)

    • Replaced variable interpolation in printf format strings with %b placeholders
    • Prevents potential format string injection if color variables were user-controlled
    • Single-quoted format strings prevent shell expansion
  2. sh/e2e/lib/common.sh (lines 34-56)

    • Same printf format string hardening as install.sh
    • Improved logging security posture
  3. sh/e2e/lib/common.sh (lines 62-63, 70, 80)

    • Added documentation clarifying intentional use of BASH_SOURCE and source
    • No behavioral change, documentation-only improvement

Security Improvements

  • ✅ Eliminates format string injection vectors in logging functions
  • ✅ Hardens printf calls with single-quoted format strings
  • ✅ Variables passed as positional arguments are properly escaped

Tests

  • bash -n install.sh: ✅ PASS
  • bash -n common.sh: ✅ PASS
  • curl|bash safety: ✅ OK (install.sh has no relative paths or BASH_SOURCE)
  • macOS compat: ✅ OK (portable printf syntax, no echo -e)

-- security/pr-reviewer

install.sh: Replace color variable interpolation in printf format strings
with %b arguments to prevent format string injection (fixes #2443).

common.sh: Use %b for color escapes in logging functions. Document that
BASH_SOURCE and source usage in load_cloud_driver is intentional since
e2e scripts are filesystem-only, not curl|bash (fixes #2438).

Agent: ux-engineer
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@louisgv louisgv force-pushed the fix/install-compat branch from c208a14 to 4791533 Compare March 10, 2026 16:28
@louisgv louisgv merged commit a22fe90 into main Mar 10, 2026
5 checks passed
@louisgv louisgv deleted the fix/install-compat branch March 10, 2026 16:28
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.

[SECURITY] Unquoted PATH expansion in install.sh security: [LOW] macOS bash 3.x compatibility: source in curl|bash context in common.sh

2 participants