mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-04-29 12:29:31 +00:00
fix: Prevent shell/Python injection in Codespaces, Render, and FluidStack (#252)
GitHub Codespaces scripts embedded API keys directly into heredocs sent over SSH, allowing single-quote breakout for command injection. Fixed by adding upload_file/run_server/inject_env_vars helpers to Codespaces lib and using safe temp-file-upload pattern (matching Railway/Render). Render claude.sh and openclaw.sh built JSON config via unescaped heredocs. Fixed by using shared setup_claude_code_config/setup_openclaw_config helpers which properly json_escape values. FluidStack had triple-quote injection in SSH key registration (pub_key embedded in Python triple-quotes) and missing single-quote validation in create_server env var checks. Fixed by reading values via stdin/argv instead of string interpolation, and added single-quote to validation. Agent: security-auditor Co-authored-by: A <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
281ea2a74f
commit
f39ffd6e24
8 changed files with 108 additions and 159 deletions
|
|
@ -174,6 +174,57 @@ delete_codespace() {
|
|||
}
|
||||
}
|
||||
|
||||
# Upload a file to codespace via gh codespace cp
|
||||
# Args: $1 = local path
|
||||
# $2 = remote path
|
||||
upload_file() {
|
||||
local local_path="$1"
|
||||
local remote_path="$2"
|
||||
|
||||
if [[ ! -f "$local_path" ]]; then
|
||||
log_error "Local file not found: $local_path"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ -z "${CODESPACE_NAME:-}" ]]; then
|
||||
log_error "CODESPACE_NAME not set. Call create_codespace first."
|
||||
return 1
|
||||
fi
|
||||
|
||||
gh codespace cp "$local_path" "${CODESPACE_NAME}:${remote_path}"
|
||||
}
|
||||
|
||||
# Run a command on the codespace (wrapper matching other providers' interface)
|
||||
run_server() {
|
||||
local cmd="$1"
|
||||
|
||||
if [[ -z "${CODESPACE_NAME:-}" ]]; then
|
||||
log_error "CODESPACE_NAME not set. Call create_codespace first."
|
||||
return 1
|
||||
fi
|
||||
|
||||
gh codespace ssh --codespace "$CODESPACE_NAME" -- bash -c "$cmd"
|
||||
}
|
||||
|
||||
# Inject environment variables into shell config
|
||||
# Writes to a temp file and uploads to avoid shell interpolation of values
|
||||
inject_env_vars() {
|
||||
log_warn "Injecting environment variables..."
|
||||
|
||||
local env_temp
|
||||
env_temp=$(mktemp)
|
||||
chmod 600 "${env_temp}"
|
||||
track_temp_file "${env_temp}"
|
||||
|
||||
generate_env_config "$@" > "${env_temp}"
|
||||
|
||||
# Upload and append to .bashrc
|
||||
upload_file "${env_temp}" "/tmp/env_config"
|
||||
run_server "cat /tmp/env_config >> ~/.bashrc && rm /tmp/env_config"
|
||||
|
||||
log_info "Environment variables configured"
|
||||
}
|
||||
|
||||
# Get codespace info
|
||||
# Args: $1 = codespace name
|
||||
get_codespace_info() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue