-
Notifications
You must be signed in to change notification settings - Fork 13
Description
Location
sh/e2e/lib/clouds/digitalocean.sh line 189
Vulnerability
The _digitalocean_exec_long function interpolates a base64-encoded command into a remote SSH command string with insufficient quoting:
ssh ... "root@${ip}" "timeout ${timeout_secs} bash -c \"\$(printf '%s' '${encoded_cmd}' | base64 -d)\""The ${encoded_cmd} variable is expanded inside single quotes that are themselves inside double quotes. This creates a potential command injection vector if encoded_cmd somehow contains a single quote character.
Current Mitigation
The attack surface is mitigated because:
encoded_cmdis base64-encoded from the original command- Base64 output only contains
[A-Za-z0-9+/=]characters (no single quotes)
However, this relies on the base64 implementation being correct and the command variable not being corrupted.
Recommended Fix
Pass the base64-encoded command via stdin instead of interpolating it into the remote command string:
printf '%s' "${encoded_cmd}" | ssh ... "root@${ip}" "timeout ${timeout_secs} bash -c '\$(base64 -d)'"This completely eliminates the interpolation risk.
Severity
MEDIUM - Low exploitability due to base64 encoding, but violates defense-in-depth principles.