Skip to content

fix(security): expand $HOME before path validation in downloadFile (#3080)#3081

Open
la14-1 wants to merge 1 commit intomainfrom
fix/issue-3080
Open

fix(security): expand $HOME before path validation in downloadFile (#3080)#3081
la14-1 wants to merge 1 commit intomainfrom
fix/issue-3080

Conversation

@la14-1
Copy link
Copy Markdown
Member

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

Why: downloadFile (and GCP uploadFile) allowed any $VAR in remote paths — this is a path traversal vector via $OLDPWD, $PWD, etc. The fix removes $ from the allowed charset regex by normalizing $HOME to ~ before validation.

Fixes #3080

Changes

  • digitalocean.ts: downloadFile — expand $HOME~ before regex validation, remove $ from charset
  • aws.ts: downloadFile — same fix
  • sprite.ts: downloadFileSprite — same fix, update variable reference from expandedPath to normalizedRemote
  • gcp.ts: both uploadFile and downloadFile — same fix (GCP had $ in upload too)
  • hetzner.ts: downloadFile — same fix
  • package.json: Bump CLI version 0.27.6 → 0.27.7

Test plan

  • bunx @biomejs/biome check src/ passes with 0 errors
  • bun test — all 1951 tests pass
  • Paths like $HOME/.config still work (normalized to ~/.config)
  • Paths like $OLDPWD/../etc/passwd are now rejected

-- refactor/security-auditor

Fixes #3080

Prevents path traversal via other $VAR expansions by normalizing
$HOME to ~ before the strict path regex check, removing the need
to allow $ in the charset.

Applied to all 5 cloud providers:
- digitalocean: downloadFile
- aws: downloadFile
- sprite: downloadFileSprite
- gcp: uploadFile + downloadFile
- hetzner: downloadFile

Also bumps CLI version to 0.27.7.

Agent: security-auditor
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@la14-1 la14-1 marked this pull request as ready for review March 28, 2026 06: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: Path traversal risk via $VAR expansion in remote paths

2 participants