-
Notifications
You must be signed in to change notification settings - Fork 7
Closed
Labels
safe-to-workSecurity triage: safe for automated processingSecurity triage: safe for automated processingsecuritySecurity vulnerabilities and concernsSecurity vulnerabilities and concerns
Description
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 validation
if cloud_exec "${app_name}" "printf '%s' \"${env_b64}\" | base64 -d > ~/.spawnrc && ..."Issue
- No validation that base64 encoding succeeded
- No validation that
env_b64contains only base64-safe characters ([A-Za-z0-9+/=]) - If
env_b64is empty or contains shell metacharacters due to corruption, it could be exploited
Attack Vectors
- Upstream data corruption: If
env_tmpfile 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_KEYbefore 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 characters
if [[ -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 now
if cloud_exec "${app_name}" "printf '%s' \"${env_b64}\" | base64 -d > ~/.spawnrc && ..."Additional hardening:
- Use
--to preventenv_b64being 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
safe-to-workSecurity triage: safe for automated processingSecurity triage: safe for automated processingsecuritySecurity vulnerabilities and concernsSecurity vulnerabilities and concerns