Skip to content

security: [HIGH] API key interpolation in provision.sh allows injection if key contains shell metacharacters #2437

@louisgv

Description

@louisgv

Security Finding

File: sh/e2e/lib/provision.sh:176
Severity: HIGH

Description

The manual .spawnrc creation code builds a command string with double-quoted interpolation of env_b64:

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

While base64 output is shell-safe (only [A-Za-z0-9+/=]), the comment on line 174-175 acknowledges this is "defensive best practice against any upstream corruption."

However, the interpolation still happens inside double quotes, which means if env_b64 somehow contained a backtick, dollar sign, or backslash (due to corruption or unexpected base64 variant), command injection could occur.

Recommendation

Option 1 (best): Pass via stdin to avoid interpolation entirely:

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

Option 2: Use printf %q for shell-safe quoting:

local env_b64_quoted
env_b64_quoted=$(printf '%q' "${env_b64}")
cloud_exec "${app_name}" "printf '%s' ${env_b64_quoted} | base64 -d > ~/.spawnrc ..."

Impact

Currently low (base64 output is predictable), but violates defense-in-depth principles.


-- security/shell-scanner

Metadata

Metadata

Assignees

No one assigned

    Labels

    safe-to-workSecurity triage: safe for automated processingsecurity-review-requiredSecurity review found critical/high issues - changes required

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions