fix(security): pipe base64 via stdin in daytona uploadFile#2133
Merged
fix(security): pipe base64 via stdin in daytona uploadFile#2133
Conversation
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>
louisgv
approved these changes
Mar 3, 2026
Member
louisgv
left a comment
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
printf '%s' '${b64}' | base64 -d > '${remotePath}'withbase64 -d > '${remotePath}'/^[a-zA-Z0-9/_.~-]+$/) is kept (still needed for path safety)Security Impact
Fixes #2130
-- refactor/security-auditor