Skip to content

fix: use platform-aware bind address for host agent HTTP server#846

Open
yasinBursali wants to merge 1 commit intoLight-Heart-Labs:mainfrom
yasinBursali:fix/host-agent-bind-address
Open

fix: use platform-aware bind address for host agent HTTP server#846
yasinBursali wants to merge 1 commit intoLight-Heart-Labs:mainfrom
yasinBursali:fix/host-agent-bind-address

Conversation

@yasinBursali
Copy link
Copy Markdown
Contributor

What

Change host agent bind address from hardcoded 0.0.0.0 to a platform-aware default with DREAM_AGENT_BIND env var override.

Why

The host agent has a Docker control API (start/stop containers, execute setup hooks, read logs). Binding to 0.0.0.0 exposes it to the entire LAN. On macOS/Windows, Docker Desktop routes host.docker.internal through the VM to the host's loopback, so 127.0.0.1 is sufficient. The /health endpoint responds without authentication.

How

  • Default: 127.0.0.1 on macOS (Darwin) / Windows, 0.0.0.0 on Linux
  • DREAM_AGENT_BIND env var overrides the default on any platform
  • Warning logged when binding to 0.0.0.0 with guidance to restrict
  • Added DREAM_AGENT_BIND to .env.schema.json

Testing

  • Python syntax verified
  • JSON schema validated
  • Live tested on WSL2: confirmed 0.0.0.0 is required for Linux (host.docker.internal resolves to Docker bridge gateway 172.17.0.1, not loopback)
  • Live tested: 127.0.0.1 bind → container connection refused; 0.0.0.0 → works

Platform Impact

  • macOS: Improved — defaults to 127.0.0.1, no longer LAN-exposed
  • Windows (native): Improved — defaults to 127.0.0.1
  • Linux: No change — defaults to 0.0.0.0 (required for container connectivity via Docker bridge)
  • Windows/WSL2: No change — platform.system() returns "Linux", gets 0.0.0.0 (correct — WSL2 uses Docker bridge like Linux)

Known Limitations

  • Linux remains on 0.0.0.0 — a follow-up could detect the Docker bridge IP for tighter binding
  • DREAM_AGENT_BIND env var provides escape hatch for all platforms

Review

  • Critique Guardian: APPROVED WITH WARNINGS (doc update for HOST-AGENT-API.md recommended as follow-up)

macOS/Windows default to 127.0.0.1 (Docker Desktop routes
host.docker.internal to loopback). Linux keeps 0.0.0.0 for
backward compatibility since host.docker.internal resolves to the
Docker bridge gateway. DREAM_AGENT_BIND env var allows explicit
override on any platform.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant