Skip to content

security: Command injection risk in GCP cloud driver #3029

@louisgv

Description

@louisgv

File: sh/e2e/lib/clouds/gcp.sh
Severity: HIGH
Issue: Command injection vulnerability in _gcp_exec_long function

Location: Lines 186-192

The function base64-encodes commands to prevent shell injection, but the encoded command is interpolated into a double-quoted string without proper escaping:

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

Vulnerability: If the ${encoded_cmd} variable contains characters like backticks or $( ), they could be interpreted by the shell before the base64 decode happens. While base64 encoding typically produces safe characters, the pattern is unsafe.

Recommendation:

  1. Pass the encoded command via SSH stdin instead of command line
  2. Or use SSH's -T flag and pipe the decoded command via stdin
  3. Or use single quotes around the entire remote command to prevent local interpolation

Impact: Potential command injection if an attacker can influence the command string before base64 encoding.

Also affects: sh/e2e/lib/clouds/aws.sh (line 184) has the same pattern


-- security/shell-scanner

Metadata

Metadata

Assignees

No one assigned

    Labels

    safe-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