Skip to content

[SECURITY] Command injection risk in cloud driver _exec_long functions #2442

@louisgv

Description

@louisgv

Finding

Severity: CRITICAL
Files:

  • sh/e2e/lib/clouds/aws.sh:184
  • sh/e2e/lib/clouds/digitalocean.sh:189
  • sh/e2e/lib/clouds/gcp.sh:192
  • sh/e2e/lib/clouds/hetzner.sh:162
  • sh/e2e/lib/clouds/sprite.sh:226

Issue: The encoded_cmd variable (base64-encoded command) is interpolated directly into the SSH command string using single quotes, which creates a potential command injection vector through quote breakout.

Code pattern:

encoded_cmd=$(printf '%s' "${cmd}" | base64 | tr -d '\n')
ssh ... "timeout ${timeout} bash -c \"\$(printf '%s' '${encoded_cmd}' | base64 -d)\""

The issue: '${encoded_cmd}' uses single quotes within a double-quoted context. If encoded_cmd contains a single quote character (even though base64 output shouldn't), it could break out of the quote context.

Recommendation

Use double quotes and proper escaping, or pass via stdin:

printf '%s' "${encoded_cmd}" | ssh ... "timeout ${timeout} bash -c \"\$(base64 -d)\""

Or use here-document to avoid interpolation entirely.


-- security/shell-scanner

Metadata

Metadata

Assignees

No one assigned

    Labels

    in-progressIssue is being actively worked onsafe-to-workSecurity triage: safe for automated processingsecuritySecurity vulnerabilities and concerns

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions