Skip to content

bug: The site search does not stop outside $HOME, and --domain can point outside the home directory #3

Closed

Description

@nabil1440

Blocker: yes. Fix this before the server-monitoring work starts.

Defect

  • FindComposeFile (internal/utils/finder.go:23-35) goes up the directory tree until it gets to $HOME.
  • If the current directory is not in $HOME, the search gets to /. filepath.Dir("/") returns /. Thus, the loop does not stop, and the process uses 100% CPU.
  • Test: go to a directory outside $HOME that has no docker-compose.yml above it, for example /var/www. Run fly start. Result: the command does not stop.
  • The function ignores the errors from os.UserHomeDir() and os.Getwd().
  • The function puts the --domain value into a path, but it does not examine the value.
  • Test: fly start --domain ../ with HOME=/home/fly. Result: the CLI uses /home/docker-compose.yml.

Cost

  • If a user runs a command from the wrong directory, the process does not stop. It uses a full CPU core until the user stops it.
  • A systemd service starts in / by default. If agent code calls this function, the agent stops and does not continue.
  • The control plane will send domain values. Without a check, a remote value can point to files outside the sites directory. This is a security risk.
  • The Cursor rules on main say that domain validation prevents path traversal. This statement is not correct.

Benefit of the fix

  • The search always stops. It gives a clear "not found" error.
  • The CLI can safely accept a --domain value from the control plane.
  • The CLI does not lose errors from the operating system.

Fix

  1. Stop the loop when filepath.Dir(dir) == dir.
  2. Return the errors from os.UserHomeDir() and os.Getwd().
  3. Accept a --domain value only if it is a valid hostname. Reject path separators, .. and empty labels.
  4. Make sure that the final path is in the sites root directory.

Completion checks

  • A command that starts outside $HOME shows "not found" immediately.
  • --domain ../, --domain .. and --domain a/b show a clear error.
  • Unit tests for the two items above.

Activity

  1. self-assigned this
    on Sep 21, 2026
  2. added a commit that references this issue on Sep 22, 2026
    cc8a308
  3. changed the title [-]The site search does not stop outside $HOME, and --domain can point outside the home directory[/-] [+]bug: The site search does not stop outside $HOME, and --domain can point outside the home directory[/+] on Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions