Skip to content

security: Unsafe base64 variable expansion in manual .spawnrc creation (provision.sh) #3078

@louisgv

Description

@louisgv

Location

sh/e2e/lib/provision.sh line 176

Vulnerability

When creating a manual .spawnrc fallback, the script expands ${env_b64} directly into a double-quoted remote command string:

if cloud_exec "${app_name}" "printf '%s' \"${env_b64}\" | base64 -d > ~/.spawnrc ...

If the env_b64 variable is corrupted or contains shell metacharacters (which shouldn't happen with base64, but could via memory corruption, race conditions, or other attacks), this could lead to command injection.

Current Mitigation

The risk is partially mitigated because:

  1. env_b64 is base64-encoded from a temp file
  2. Base64 output only contains [A-Za-z0-9+/=] characters
  3. The temp file is created locally (not from untrusted input)

However, the code violates defense-in-depth principles by relying on base64 correctness.

Recommended Fix

Pass the base64 data via stdin instead of interpolating it:

printf '%s' "${env_b64}" | cloud_exec "${app_name}" "base64 -d > ~/.spawnrc && chmod 600 ~/.spawnrc && ..."

Or use a here-document if cloud_exec supports it.

Severity

MEDIUM - Low exploitability but violates secure coding best practices.

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