fix(security): harden env_b64 and b64_tmp expansion in provision.sh (#3078)#3083
Open
fix(security): harden env_b64 and b64_tmp expansion in provision.sh (#3078)#3083
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why: The manual
.spawnrcfallback inprovision.shinterpolated untrusted data (remote mktemp output and base64 payload) directly intocloud_execcommand strings without sufficient validation, violating defense-in-depth principles.Changes
Validate
b64_tmppath — The remotemktempoutput is now checked against^[A-Za-z0-9_./ -]+$before being used in subsequentcloud_execcalls. A compromised remote could return a crafted path containing shell metacharacters (',;,$, etc.) that would be interpreted when interpolated into the command string.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