Skip to content

fix(security): harden env_b64 and b64_tmp expansion in provision.sh (#3078)#3083

Open
la14-1 wants to merge 1 commit intomainfrom
fix/issue-3078
Open

fix(security): harden env_b64 and b64_tmp expansion in provision.sh (#3078)#3083
la14-1 wants to merge 1 commit intomainfrom
fix/issue-3078

Conversation

@la14-1
Copy link
Copy Markdown
Member

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

Why: The manual .spawnrc fallback in provision.sh interpolated untrusted data (remote mktemp output and base64 payload) directly into cloud_exec command strings without sufficient validation, violating defense-in-depth principles.

Changes

  1. Validate b64_tmp path — The remote mktemp output is now checked against ^[A-Za-z0-9_./ -]+$ before being used in subsequent cloud_exec calls. A compromised remote could return a crafted path containing shell metacharacters (', ;, $, etc.) that would be interpreted when interpolated into the command string.

  2. Escape single quotes in env_b64 — Before interpolating into the remote _B64='...' assignment, any single quotes are escaped using the standard '\'' pattern. While base64 output never contains single quotes (only [A-Za-z0-9+/=]), this prevents command injection if the base64 validation is ever bypassed or weakened.

Both fixes are defense-in-depth — the existing base64 validation (^[A-Za-z0-9+/=]+$) already prevents exploitation under normal conditions. These additions harden against edge cases like memory corruption, race conditions, or future code changes that relax the validation.

Fixes #3078

-- refactor/ux-engineer

…3078)

Two defense-in-depth improvements to the manual .spawnrc fallback:

1. Validate b64_tmp (remote mktemp output) contains only safe path
   characters before interpolating it into subsequent cloud_exec calls.
   A compromised remote could return a crafted path with shell
   metacharacters.

2. Escape single quotes in env_b64 before interpolating into the remote
   command string. Base64 output never contains single quotes, but if
   the validation were ever bypassed, an unescaped quote could break
   out of the _B64='...' assignment on the remote side.

Agent: ux-engineer
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: Unsafe base64 variable expansion in manual .spawnrc creation (provision.sh)

2 participants