Repository navigation
Closed
Labels
bugSomething isn't working
Description
Summary
togo deploy --remote-build (or remote_build: true in togo.yaml) uploads the entire project directory to the server, with no exclusions. That includes:
.env, which holds local secrets:AUTH_SECRET,DATABASE_URLwith credentials, provider API keys;.git, the full history, including anything ever committed and removed;- local database files such as
togo.db(SQLite); - everything else under the project root:
node_modules,.togo/, localstorage/, editor files.
Where
cmd/deploy.go (main fa3c22e):
- The remote-build path calls
rsyncTo(proj.Root+string(os.PathSeparator), remote, t). rsyncTorunsrsync -az -e <ssh> <root>/ <user>@<host>:<path>, with no--exclude,--filteror.gitignorehandling.- When rsync isn't installed, it falls back to
scp -r <root>/ <remote>, which also copies everything. --dry-runprintsrsync ./ → …and doesn't mention that dotfiles are included.
Reproduction
I ran this in a Linux container (golang:1.27) with CLI main fa3c22e. rsync and ssh were stubs that log their arguments; the rsync stub copies the source tree the way rsync does. The project had togo.yaml (deploy: with remote_build: true, build: "true"), a .env, a togo.db and git init.
$ togo deploy --remote-build
rsync /proj/ → deploy@example.invalid:/opt/demo
rsync argv: -az -e ssh /proj/ deploy@example.invalid:/opt/demo
ssh argv: deploy@example.invalid cd /opt/demo && true
✓ Deployed demo → example.invalid
--- files on 'server':
.env .git main.go togo.db togo.yaml
The rsync arguments come straight from the CLI and contain no exclusions. With those arguments, real rsync transfers every file under the source directory, dotfiles included.
Impact
- Secret exposure: developer secrets in
.envend up on the server. Anyone with access to the server, its backups or the deploy path can read them. If the deploy path is web-served, so can anyone else. - Wrong configuration in production: a dev
.envon the server can be picked up by anything that reads it, e.g. a process manager'sEnvironmentFile, or a future CLI.envloader. Local SQLite data and the git history are also published. - Unchanged by Proposal: load the project .env for local development commands (migrate, seed, serve), shell env taking precedence #10: Proposal: load the project .env for local development commands (migrate, seed, serve), shell env taking precedence #10 loads
.envonly formigrate,seedanddev, notserve. Its production guard is a separate matter; it doesn't fix this exposure.
Expected
Remote builds ship only what the build needs:
.env,.env.*(except.env.example),.git, local DB files (*.db,*.db-wal,*.db-shm),node_modulesand.togo/are excluded by default;- ideally
.gitignoreis respected, e.g. with rsync--filter=':- .gitignore'or by shippinggit archive HEAD; - the scp fallback gets the same exclusion set, or is refused for remote builds;
--dry-runlists the exclusions;- an explicit opt-in (e.g.
deploy.include) covers files that must be shipped.
Acceptance criteria
- A test that builds the rsync command line asserts the default excludes are present (
.env,.git, local DB files). - An end-to-end test with stubbed rsync/ssh:
.env,.gitandtogo.dbare not delivered;.env.exampleand the source are. - The scp fallback can't upload excluded files; it is either refused for remote builds or tested.
-
--dry-runshows the exclusions. - The release notes call out the behaviour change and tell users to remove stale
.env,.gitand database files from servers they deployed to with--remote-build, and to rotate any secrets that were in that.env.
Notes
- The default (non-remote) deploy ships only the built artifact, so it isn't affected.
- Out of scope: Proposal: load the project .env for local development commands (migrate, seed, serve), shell env taking precedence #10 (
.envloading) and togo new treats redirected stdin (/dev/null, NUL) as interactive and auto-starts docker compose #4.
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
fadymondy commentedon Oct 14, 2026
Fixed in #20, released in v0.2.37.
--remote-buildnow excludes.env,.env.*(keeping.env.example),.git/,*.db/*.sqlitefiles with their-wal/-shmcompanions,node_modules/and.togo/, and honours.gitignore.deploy.includeopts a path back in. The scp fallback is refused for remote builds (it cannot exclude),--dry-runlists the exclusions, and the release notes carry the cleanup/rotation guidance. Tests cover the filter set and ordering, the scp refusal, and an end-to-end run with the real rsync (runs in CI on ubuntu; it was skipped on my Windows host where rsync is unavailable).Note for servers already deployed with
--remote-build: delete stale.env,.gitand database files from the deploy path and rotate the secrets from that.env.