fix(webhook-server): default-bind to loopback instead of 0.0.0.0#2546
Open
smith-vosburg wants to merge 1 commit into
Open
fix(webhook-server): default-bind to loopback instead of 0.0.0.0#2546smith-vosburg wants to merge 1 commit into
smith-vosburg wants to merge 1 commit into
Conversation
Extract resolveListenConfig() so the bind address is environment-driven and unit-testable. Default to 127.0.0.1 so the webhook port is not exposed to the LAN; set WEBHOOK_BIND=0.0.0.0 (or a specific interface IP) to opt back into external exposure. The existing webhook-server.test.ts imported resolveListenConfig from the production module, but the symbol had never been extracted — the test was effectively dead. This commit lands the missing refactor and extends the test with the empty-string fallback, specific-interface, and combined-env-var cases. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of Change
Description
The webhook server in
src/webhook-server.tscurrently binds to0.0.0.0, exposing the HTTP listener to every interface on the host. Most installs don't actually need this — the Chat-SDK Telegram adapter uses long polling, and operators who genuinely need an externally-reachable webhook are typically fronting it with a reverse proxy on a different port anyway.This refactor extracts
resolveListenConfig()so the bind address is environment-driven and unit-testable. Defaults to127.0.0.1so the port is not exposed to the LAN; operators who need external exposure can opt in withWEBHOOK_BIND=0.0.0.0(or a specific interface IP).Diff
Tests
src/webhook-server.test.ts(new) — four cases onresolveListenConfig:WEBHOOK_PORTwhen setWEBHOOK_BINDfor opt-in external exposureWEBHOOK_BINDas unset (so an accidentalWEBHOOK_BIND=in a dotenv file doesn't silently bind to all interfaces)pnpm typecheckis clean.Notes
webhook-server.test.tsfor this function; the test was dropped in fix(security): use CSPRNG for approval card ids + clicker authorization #2545 because the underlying refactor wasn't included. This PR lands the missing refactor + the test.vosburg-auto/nanoclaw@273da12.🤖 Generated with Claude Code