Skip to content

security: validate base64 in gcp/aws/hetzner cloud_exec and soak.sh#2532

Merged
louisgv merged 1 commit intomainfrom
fix/security-base64-all
Mar 12, 2026
Merged

security: validate base64 in gcp/aws/hetzner cloud_exec and soak.sh#2532
louisgv merged 1 commit intomainfrom
fix/security-base64-all

Conversation

@la14-1
Copy link
Member

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

Why: PR #2528 fixed base64 validation in digitalocean.sh cloud_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/):

Soak test (sh/e2e/lib/soak.sh):

  • Add _encode_b64 helper that base64-encodes + validates output
  • Replace all 5 inline encoded_token assignments with validated helper
  • Prevents corrupted base64 from breaking out of '${encoded_token}' in cloud_exec calls

Security Impact

Defense-in-depth: standard base64 always 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

…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>
Copy link
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: 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

@louisgv louisgv merged commit 6fda75c into main Mar 12, 2026
6 checks passed
@louisgv louisgv deleted the fix/security-base64-all branch March 12, 2026 13:32
AhmedTMM pushed a commit to AhmedTMM/spawn that referenced this pull request Mar 12, 2026
…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>
AhmedTMM pushed a commit to AhmedTMM/spawn that referenced this pull request Mar 13, 2026
…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>
AhmedTMM pushed a commit to AhmedTMM/spawn that referenced this pull request Mar 13, 2026
…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>
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: [provision.sh] Unvalidated base64 value in SSH command allows potential command injection

2 participants