Security Finding
Severity: HIGH
Category: Command injection via API key interpolation
Description
Multiple agent scripts pass OPENROUTER_API_KEY directly into run_server command strings without proper escaping. If an API key contains shell metacharacters (e.g., $(cmd), backticks, ; cmd, etc.), they would be interpreted by the remote shell.
Affected files (non-exhaustive — pattern appears in ~12+ files):
| File | Line | Pattern |
|---|
latitude/continue.sh | 35-36 | run_server "$IP" "printf '%s\n' 'export OPENROUTER_API_KEY=${OPENROUTER_API_KEY}' >> /root/.bashrc" |
daytona/continue.sh | 32-33 | run_server "printf 'export OPENROUTER_API_KEY=%s\n' '${OPENROUTER_API_KEY}' >> ~/.bashrc" |
scaleway/continue.sh | 37-38 | Same pattern with ${OPENROUTER_API_KEY} in double-quoted string |
e2b/continue.sh | 36-37 | Same pattern |
modal/continue.sh | 35-36 | Same pattern |
upcloud/continue.sh | 34-35 | Same pattern |
github-codespaces/continue.sh | 41-42 | Same pattern |
kamatera/nanoclaw.sh | 43 | run_server "$IP" "printf 'ANTHROPIC_API_KEY=%s\n' '${OPENROUTER_API_KEY}' > ~/nanoclaw/.env" |
Root Cause
The API key is interpolated into a double-quoted string that forms a shell command. The run_server function typically executes this via SSH, meaning the string is parsed by the remote shell. While OpenRouter API keys are normally alphanumeric, any key with special characters would be executed as shell commands.
Remediation
Use the generic_inject_env_vars pattern from shared/common.sh which writes env vars to a temp file with chmod 600, uploads it, and sources it — avoiding shell interpolation entirely. The existing inject_env_vars and inject_env_vars_fly functions in shared/common.sh already do this safely.
For scripts that must use inline commands, use printf '%s' with the key passed as a separate argument rather than interpolated into the format string.
Found by
Automated security scan (spawn security team)
Security Finding
Severity: HIGH
Category: Command injection via API key interpolation
Description
Multiple agent scripts pass
OPENROUTER_API_KEYdirectly intorun_servercommand strings without proper escaping. If an API key contains shell metacharacters (e.g.,$(cmd), backticks,; cmd, etc.), they would be interpreted by the remote shell.Affected files (non-exhaustive — pattern appears in ~12+ files):
latitude/continue.shrun_server "$IP" "printf '%s\n' 'export OPENROUTER_API_KEY=${OPENROUTER_API_KEY}' >> /root/.bashrc"daytona/continue.shrun_server "printf 'export OPENROUTER_API_KEY=%s\n' '${OPENROUTER_API_KEY}' >> ~/.bashrc"scaleway/continue.sh${OPENROUTER_API_KEY}in double-quoted stringe2b/continue.shmodal/continue.shupcloud/continue.shgithub-codespaces/continue.shkamatera/nanoclaw.shrun_server "$IP" "printf 'ANTHROPIC_API_KEY=%s\n' '${OPENROUTER_API_KEY}' > ~/nanoclaw/.env"Root Cause
The API key is interpolated into a double-quoted string that forms a shell command. The
run_serverfunction typically executes this via SSH, meaning the string is parsed by the remote shell. While OpenRouter API keys are normally alphanumeric, any key with special characters would be executed as shell commands.Remediation
Use the
generic_inject_env_varspattern fromshared/common.shwhich writes env vars to a temp file withchmod 600, uploads it, and sources it — avoiding shell interpolation entirely. The existinginject_env_varsandinject_env_vars_flyfunctions inshared/common.shalready do this safely.For scripts that must use inline commands, use
printf '%s'with the key passed as a separate argument rather than interpolated into the format string.Found by
Automated security scan (spawn security team)