security: validate base64 in gcp/aws/hetzner cloud_exec and soak.sh#2532
security: validate base64 in gcp/aws/hetzner cloud_exec and soak.sh#2532
Conversation
…n-depth) Add base64 character validation ([A-Za-z0-9+/=]) before use in SSH command strings for gcp.sh, aws.sh, and hetzner.sh cloud_exec functions -- matching the existing fix in digitalocean.sh (#2528). Also add a validated _encode_b64 helper to soak.sh and use it for all Telegram bot token encoding, preventing corrupted base64 from breaking out of single-quoted SSH command strings. Closes #2527 Agent: security-auditor Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
louisgv
left a comment
There was a problem hiding this comment.
Security Review
Verdict: APPROVED
Commit: cf805df
Findings
None. Changes are security-positive.
Analysis
✅ Command Injection Defense — Adds grep -qE '^[A-Za-z0-9+/=]+$' validation before interpolating base64-encoded commands into SSH exec calls (aws.sh, gcp.sh, hetzner.sh). Prevents corrupted base64 from breaking out of single quotes.
✅ Consistent Pattern — Matches existing fix in digitalocean.sh (PR #2528), ensuring uniform protection across all cloud drivers.
✅ Centralized Validation — _encode_b64 helper in soak.sh centralizes base64 encoding + validation logic for Telegram token handling (5 call sites).
✅ Error Handling — All validations return 1 on failure with clear log_err messages.
✅ macOS Compatibility — Uses portable grep -qE regex syntax (works on BSD/GNU grep).
Tests
bash -n: PASS (all 4 modified .sh files)bun test: PASS (1396 tests, 0 failures)- curl|bash safety: N/A (no remote curl invocations)
- macOS compat: OK (uses portable grep -E, printf, base64 -w 0 fallback)
-- security/pr-reviewer
…n-depth) (OpenRouterTeam#2532) Add base64 character validation ([A-Za-z0-9+/=]) before use in SSH command strings for gcp.sh, aws.sh, and hetzner.sh cloud_exec functions -- matching the existing fix in digitalocean.sh (OpenRouterTeam#2528). Also add a validated _encode_b64 helper to soak.sh and use it for all Telegram bot token encoding, preventing corrupted base64 from breaking out of single-quoted SSH command strings. Closes OpenRouterTeam#2527 Agent: security-auditor Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
…n-depth) (OpenRouterTeam#2532) Add base64 character validation ([A-Za-z0-9+/=]) before use in SSH command strings for gcp.sh, aws.sh, and hetzner.sh cloud_exec functions -- matching the existing fix in digitalocean.sh (OpenRouterTeam#2528). Also add a validated _encode_b64 helper to soak.sh and use it for all Telegram bot token encoding, preventing corrupted base64 from breaking out of single-quoted SSH command strings. Closes OpenRouterTeam#2527 Agent: security-auditor Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
…n-depth) (OpenRouterTeam#2532) Add base64 character validation ([A-Za-z0-9+/=]) before use in SSH command strings for gcp.sh, aws.sh, and hetzner.sh cloud_exec functions -- matching the existing fix in digitalocean.sh (OpenRouterTeam#2528). Also add a validated _encode_b64 helper to soak.sh and use it for all Telegram bot token encoding, preventing corrupted base64 from breaking out of single-quoted SSH command strings. Closes OpenRouterTeam#2527 Agent: security-auditor Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Why: PR #2528 fixed base64 validation in
digitalocean.shcloud_exec, but the same vulnerability exists in the other three cloud drivers (gcp.sh, aws.sh, hetzner.sh) and in soak.sh's Telegram token encoding. Unvalidated base64 output interpolated into single-quoted SSH command strings could allow command injection if base64 encoding is corrupted.Changes
Cloud drivers (
sh/e2e/lib/clouds/):gcp.sh— addgrep -qE '^[A-Za-z0-9+/=]+$'validation before SSH execaws.sh— same validationhetzner.sh— same validationdigitalocean.shfrom PR security: validate base64 in digitalocean.sh SSH exec #2528Soak test (
sh/e2e/lib/soak.sh):_encode_b64helper that base64-encodes + validates outputencoded_tokenassignments with validated helper'${encoded_token}'incloud_execcallsSecurity Impact
Defense-in-depth: standard
base64always produces safe characters, but validation ensures corrupted output cannot escape single-quoted SSH command strings. This is the same pattern applied in provision.sh (lines 284-289) and digitalocean.sh (PR #2528).Closes #2527
-- refactor/security-auditor