Skip to content

serve: require explicit confirmation when binding non-loopback without OPENCODE_SERVER_PASSWORD #10948

Closed

Description

@MaxMiksa

Description

opencode serve starts a headless API server. If OPENCODE_SERVER_PASSWORD is not set, the server runs unauthenticated (it only prints a warning).

When users bind to a non-loopback hostname (e.g. --hostname 0.0.0.0 or --mdns which defaults hostname to 0.0.0.0), this can easily expose the server (and agent capabilities) to a LAN/public network by accident.

Suggested fix

  • If hostname is non-loopback and OPENCODE_SERVER_PASSWORD is unset:
    • On TTY: prompt for confirmation (default No) before starting.
    • On non-TTY: refuse to start unless the user explicitly opts in (e.g. --yes).

This keeps loopback behavior unchanged and avoids hanging in non-interactive environments.

Steps to reproduce

  1. Ensure OPENCODE_SERVER_PASSWORD is unset.
  2. Run opencode serve --hostname 0.0.0.0 (or opencode serve --mdns).
  3. Observe it starts unauthenticated with only a warning.

Environment

  • OS: Windows 11
  • Terminal: Windows Terminal

Activity

  1. github-actions commented on Jan 28, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  2. MaxMiksa commented on Jan 28, 2026

    @MaxMiksa
    ContributorAuthor

    Thanks — these are related, but this issue is intentionally narrower.

    This proposal only changes opencode serve behavior when binding to a non-loopback hostname without OPENCODE_SERVER_PASSWORD: require an explicit confirmation (TTY) or --yes (non-TTY) before starting.

    It does not introduce new auth mechanisms or auto-generate passwords; it’s a minimal guardrail to reduce accidental exposure, especially with --hostname 0.0.0.0 / --mdns.

  3. github-actions commented on Mar 30, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions