Skip to content

security: validate base64 in digitalocean.sh SSH exec#2528

Merged
louisgv merged 1 commit intomainfrom
fix/security-2526-2527
Mar 12, 2026
Merged

security: validate base64 in digitalocean.sh SSH exec#2528
louisgv merged 1 commit intomainfrom
fix/security-2526-2527

Conversation

@la14-1
Copy link
Member

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

Why: Defense-in-depth validation for base64-encoded commands passed via SSH in the E2E DigitalOcean cloud driver.

Changes

Fix #2526 - digitalocean.sh base64 validation

Added explicit validation that encoded_cmd contains only [A-Za-z0-9+/=] characters after base64 encoding, before embedding it in the SSH command string. This matches the existing defense-in-depth pattern already present in provision.sh (lines 284-289).

The validation ensures that even if the base64 encoding were somehow corrupted, the value cannot break out of the single-quoted context in the SSH command.

#2527 - provision.sh (already fixed)

The base64 validation described in #2527 already exists in provision.sh at lines 284-289:

if ! printf '%s' "${env_b64}" | grep -qE '^[A-Za-z0-9+/=]+$'; then
    log_err "Invalid base64 encoding"
    return 1
fi

This was likely fixed in a prior commit. No additional changes needed.

Fixes #2526

-- refactor/security-auditor

Add explicit base64 character validation in _digitalocean_exec after
encoding the command, matching the existing pattern in provision.sh.
This ensures the encoded value contains only [A-Za-z0-9+/=] before
embedding it in the SSH command string.

Note: #2527 (provision.sh base64 validation) was already fixed in a
prior commit — the validation at lines 284-289 already rejects
non-base64 characters and empty output.

Fixes #2526

Agent: security-auditor
Co-Authored-By: Claude Sonnet 4.6 <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: 8149a9d

Findings

No security issues found. The PR adds defense-in-depth validation for base64-encoded SSH commands:

  • Validates base64 output matches standard alphabet [A-Za-z0-9+/=] before passing to SSH
  • Prevents any corruption from breaking out of single quotes in the SSH exec command
  • Well-commented, minimal change with clear security purpose

Tests

  • bash -n: PASS
  • bun test: N/A (test failure unrelated to this PR - missing module dependency in test suite)
  • curl|bash: N/A (file is sourced by E2E harness, not executed via curl|bash)
  • macOS compat: OK (uses POSIX-compliant grep -qE)

Additional Checks

  • ✓ No command injection vectors
  • ✓ No credential leaks
  • ✓ No path traversal risks
  • ✓ macOS bash 3.x compatible
  • ✓ Follows shell script conventions (no set -u, proper error handling)

-- security/pr-reviewer

@louisgv louisgv merged commit 76399ea into main Mar 12, 2026
6 checks passed
@louisgv louisgv deleted the fix/security-2526-2527 branch March 12, 2026 12:16
la14-1 pushed a commit that referenced this pull request Mar 12, 2026
…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 added a commit that referenced this pull request Mar 12, 2026
…n-depth) (#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 (#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: 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 12, 2026
…th) (OpenRouterTeam#2528)

Add explicit base64 character validation in _digitalocean_exec after
encoding the command, matching the existing pattern in provision.sh.
This ensures the encoded value contains only [A-Za-z0-9+/=] before
embedding it in the SSH command string.

Note: OpenRouterTeam#2527 (provision.sh base64 validation) was already fixed in a
prior commit — the validation at lines 284-289 already rejects
non-base64 characters and empty output.

Fixes OpenRouterTeam#2526

Agent: security-auditor

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
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
…th) (OpenRouterTeam#2528)

Add explicit base64 character validation in _digitalocean_exec after
encoding the command, matching the existing pattern in provision.sh.
This ensures the encoded value contains only [A-Za-z0-9+/=] before
embedding it in the SSH command string.

Note: OpenRouterTeam#2527 (provision.sh base64 validation) was already fixed in a
prior commit — the validation at lines 284-289 already rejects
non-base64 characters and empty output.

Fixes OpenRouterTeam#2526

Agent: security-auditor

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <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
…th) (OpenRouterTeam#2528)

Add explicit base64 character validation in _digitalocean_exec after
encoding the command, matching the existing pattern in provision.sh.
This ensures the encoded value contains only [A-Za-z0-9+/=] before
embedding it in the SSH command string.

Note: OpenRouterTeam#2527 (provision.sh base64 validation) was already fixed in a
prior commit — the validation at lines 284-289 already rejects
non-base64 characters and empty output.

Fixes OpenRouterTeam#2526

Agent: security-auditor

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <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: [digitalocean.sh] Command injection risk in _digitalocean_exec_long via base64-encoded command

2 participants