Skip to content

security: deploy --remote-build uploads .env, .git and local database files to the server #12

Closed

Description

@fadymondy

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_URL with 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/, local storage/, editor files.

Where

cmd/deploy.go (main fa3c22e):

  • The remote-build path calls rsyncTo(proj.Root+string(os.PathSeparator), remote, t).
  • rsyncTo runs rsync -az -e <ssh> <root>/ <user>@<host>:<path>, with no --exclude, --filter or .gitignore handling.
  • When rsync isn't installed, it falls back to scp -r <root>/ <remote>, which also copies everything.
  • --dry-run prints rsync ./ → … 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

Expected

Remote builds ship only what the build needs:

  • .env, .env.* (except .env.example), .git, local DB files (*.db, *.db-wal, *.db-shm), node_modules and .togo/ are excluded by default;
  • ideally .gitignore is respected, e.g. with rsync --filter=':- .gitignore' or by shipping git archive HEAD;
  • the scp fallback gets the same exclusion set, or is refused for remote builds;
  • --dry-run lists 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, .git and togo.db are not delivered; .env.example and the source are.
  • The scp fallback can't upload excluded files; it is either refused for remote builds or tested.
  • --dry-run shows the exclusions.
  • The release notes call out the behaviour change and tell users to remove stale .env, .git and database files from servers they deployed to with --remote-build, and to rotate any secrets that were in that .env.

Notes

Activity

  1. added
    bug
    on Oct 8, 2026
  2. fadymondy commented on Oct 14, 2026

    @fadymondy
    ContributorAuthor

    Fixed in #20, released in v0.2.37.

    --remote-build now excludes .env, .env.* (keeping .env.example), .git/, *.db/*.sqlite files with their -wal/-shm companions, node_modules/ and .togo/, and honours .gitignore. deploy.include opts a path back in. The scp fallback is refused for remote builds (it cannot exclude), --dry-run lists 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, .git and database files from the deploy path and rotate the secrets from that .env.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions