fix: escape shell commands and sanitize JSON to prevent injection (#463)

- Add printf %q command escaping to run_server/interactive_session in
  Koyeb, Render, Railway, and GitHub Codespaces (matching pattern used
  by E2B, Daytona, Northflank, Fly, and other providers)
- Use json_escape in exchange_oauth_code to prevent JSON injection via
  crafted OAuth codes in shared/common.sh
- Use json_escape in Fly.io _fly_create_app to prevent JSON injection
  via FLY_ORG env var, plus add validation for org slug format
- Pass Fly.io _fly_create_machine values via env vars instead of Python
  string interpolation to prevent code injection

Agent: security-auditor

Co-authored-by: A <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
A 2026-02-11 07:20:41 -08:00 committed by GitHub
parent c1085f076a
commit 3d274bf3d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 44 additions and 13 deletions

View file

@ -195,6 +195,7 @@ upload_file() {
}
# Run a command on the codespace (wrapper matching other providers' interface)
# SECURITY: Uses printf %q to properly escape commands to prevent injection
run_server() {
local cmd="$1"
@ -203,7 +204,9 @@ run_server() {
return 1
fi
gh codespace ssh --codespace "$CODESPACE_NAME" -- bash -c "$cmd"
local escaped_cmd
escaped_cmd=$(printf '%q' "$cmd")
gh codespace ssh --codespace "$CODESPACE_NAME" -- bash -c "$escaped_cmd"
}
# Inject environment variables into shell config