Location
sh/e2e/lib/provision.sh:176
Severity
HIGH - Defense-in-depth violation, potential command injection
Description
The provision_agent function creates a manual .spawnrc file by base64-encoding sensitive data and passing it to a remote SSH command. However, the env_b64 variable is not validated before use, creating a command injection risk if base64 encoding fails or upstream data is corrupted.
Vulnerable Code
local env_b64
env_b64=$(base64 <"${env_tmp}"| tr -d '\n')
rm -f "${env_tmp}"# env_b64 used directly without validationif cloud_exec "${app_name}""printf '%s' \"${env_b64}\" | base64 -d > ~/.spawnrc && ..."Issue
- No validation that base64 encoding succeeded
- No validation that
env_b64 contains only base64-safe characters ([A-Za-z0-9+/=]) - If
env_b64 is empty or contains shell metacharacters due to corruption, it could be exploited
Attack Vectors
- Upstream data corruption: If
env_tmp file is corrupted or contains malicious content - Base64 command failure: If base64 silently fails or behaves unexpectedly
- Environment variable manipulation: If an attacker can influence
OPENROUTER_API_KEY before it's base64-encoded
Impact
- Remote command execution on provisioned VMs
- Credential theft (since this code handles API keys)
- Compromise of E2E test infrastructure
Recommendation
Add validation before use:
local env_b64
env_b64=$(base64 <"${env_tmp}"| tr -d '\n')
rm -f "${env_tmp}"# VALIDATE env_b64 is non-empty and contains only base64 charactersif [[ -z"${env_b64}" ]] || [[ !"${env_b64}"=~ ^[A-Za-z0-9+/=]+$ ]];then
log_err "Base64 encoding failed or produced invalid output"return 1
fi# Safe to use nowif cloud_exec "${app_name}""printf '%s' \"${env_b64}\" | base64 -d > ~/.spawnrc && ..."Additional hardening:
- Use
-- to prevent env_b64 being interpreted as a flag - Consider using heredoc for even better safety
References
- CWE-77: Improper Neutralization of Special Elements used in a Command
- Defense in Depth: Always validate before use in sensitive contexts
Filed automatically by security/shell-scanner
Location
sh/e2e/lib/provision.sh:176Severity
HIGH - Defense-in-depth violation, potential command injection
Description
The
provision_agentfunction creates a manual.spawnrcfile by base64-encoding sensitive data and passing it to a remote SSH command. However, theenv_b64variable is not validated before use, creating a command injection risk if base64 encoding fails or upstream data is corrupted.Vulnerable Code
Issue
env_b64contains only base64-safe characters ([A-Za-z0-9+/=])env_b64is empty or contains shell metacharacters due to corruption, it could be exploitedAttack Vectors
env_tmpfile is corrupted or contains malicious contentOPENROUTER_API_KEYbefore it's base64-encodedImpact
Recommendation
Add validation before use:
Additional hardening:
--to preventenv_b64being interpreted as a flagReferences
Filed automatically by security/shell-scanner