Skip to content

fix(security): pipe base64 via stdin in daytona uploadFile#2133

Merged
louisgv merged 2 commits intomainfrom
fix/security-2130
Mar 3, 2026
Merged

fix(security): pipe base64 via stdin in daytona uploadFile#2133
louisgv merged 2 commits intomainfrom
fix/security-2130

Conversation

@la14-1
Copy link
Member

@la14-1 la14-1 commented Mar 3, 2026

Why: Eliminates shell interpolation of base64 content in uploadFile's remote command, providing defense-in-depth against injection even if base64 validation were ever bypassed.

Changes

  • Replace printf '%s' '${b64}' | base64 -d > '${remotePath}' with base64 -d > '${remotePath}'
  • Pipe b64 content via stdin instead of embedding in command string
  • Remove now-unnecessary b64 character validation (content no longer interpolated)
  • Existing remotePath validation (/^[a-zA-Z0-9/_.~-]+$/) is kept (still needed for path safety)

Security Impact

  • Before: b64 content interpolated into remote shell command (validated but still a pattern to avoid)
  • After: b64 content sent via stdin, not visible in command string at all

Fixes #2130

-- refactor/security-auditor

Eliminates b64 interpolation into the remote shell command string,
providing defense-in-depth alongside existing path validation.

Fixes #2130

Agent: security-auditor
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Member

@louisgv louisgv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security Review

Verdict: APPROVED
Commit: e6ea66e

Summary

This PR correctly fixes a command injection vulnerability (issue #2130) by changing from embedding base64 data in shell command strings to piping via stdin.

Findings

NONE - All security concerns resolved.

Analysis

FIXED: Command injection - The original code embedded base64-encoded file content directly into the SSH command string:

`printf '%s' '${b64}' | base64 -d > '${remotePath}'`

This was vulnerable despite the regex validation, because base64 encoding from arbitrary binary files could theoretically produce edge cases. The fix correctly pipes data via stdin instead:

`base64 -d > '${remotePath}'`
stdin.write(b64 + "\n");

remotePath safety: Still interpolated into the command string but protected by:

  • Single-quote wrapping (prevents expansion)
  • Strict allowlist validation: /^[a-zA-Z0-9/_.~-]+$/
  • Path traversal prevention: blocks ".."
  • Flag injection prevention: blocks "-" prefix on any path component

This is the correct security approach for this use case.

Tests

  • bun test: PASS (1372 pass, 0 fail)
  • biome lint: PASS (0 errors)
  • Version bump: PASS (0.12.7 → 0.12.8, appropriate for patch)

-- security/pr-reviewer

@louisgv louisgv merged commit 6881719 into main Mar 3, 2026
5 checks passed
@louisgv louisgv deleted the fix/security-2130 branch March 3, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security: Potential command injection in daytona uploadFile function

2 participants