Skip to content

fix: require explicit public network binds#7

Merged
smiggleworth merged 3 commits into
mainfrom
fix/security-loopback-default-bind
Jul 26, 2026
Merged

fix: require explicit public network binds#7
smiggleworth merged 3 commits into
mainfrom
fix/security-loopback-default-bind

Conversation

@smiggleworth

Copy link
Copy Markdown
Contributor

Closes #6. Defaults both server entrypoints to 127.0.0.1, rejects implicit public hosts, and documents the allowPublicBind opt-in.

Copilot AI review requested due to automatic review settings July 26, 2026 17:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the Node adapter’s network exposure defaults by ensuring both listen() and serve() bind to loopback (127.0.0.1) unless the caller explicitly opts into a public bind via allowPublicBind: true, aligning with Issue #6’s security requirement.

Changes:

  • Introduces resolveBindHost() to centralize loopback-default binding and public-bind opt-in enforcement.
  • Updates listen() and serve() to use the resolved host for both binding and Host allowlisting.
  • Adds test coverage and documentation describing the new default and opt-in behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/node.test.ts Adds a regression test asserting loopback-default binding and requiring explicit public-bind opt-in.
src/serve.ts Uses resolveBindHost() for consistent binding/allowedHosts behavior in serve().
src/listen.ts Uses resolveBindHost() for consistent binding/allowedHosts behavior in listen().
src/contracts.ts Adds allowPublicBind?: boolean to the public options contract (via ListenOptions).
src/bind.ts Adds shared host resolution + opt-in enforcement helper.
README.md Documents loopback-default binding and the allowPublicBind opt-in requirement.
Comments suppressed due to low confidence (1)

tests/node.test.ts:37

  • Same pattern as above: combining the type check and value assertion can turn a non-TCP address into false === "0.0.0.0", which is harder to debug than an explicit guard.
    const publicAddress = publicServer.address();
    expect(typeof publicAddress === "object" && publicAddress?.address).toBe("0.0.0.0");

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/serve.ts Outdated
Comment thread tests/node.test.ts
@smiggleworth
smiggleworth merged commit adfe87d into main Jul 26, 2026
3 checks passed
@smiggleworth
smiggleworth deleted the fix/security-loopback-default-bind branch July 26, 2026 17:13
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.

Security: default network listeners to loopback

2 participants