fix(security): default standalone servers to loopback bind#13184
fix(security): default standalone servers to loopback bind#13184steipete merged 3 commits intoopenclaw:mainfrom
Conversation
| const path = opts.path ?? "/telegram-webhook"; | ||
| const healthPath = opts.healthPath ?? "/healthz"; | ||
| const port = opts.port ?? 8787; | ||
| const host = opts.host ?? "0.0.0.0"; | ||
| const host = opts.host ?? "127.0.0.1"; | ||
| const runtime = opts.runtime ?? defaultRuntime; |
There was a problem hiding this comment.
Port 0 breaks webhook URL
startTelegramWebhook uses const port = opts.port ?? 8787; and then builds publicUrl from that port before calling server.listen(port, host, ...). When callers pass port: 0 (tests do this, and other callers may for ephemeral ports), the server binds to a random port but publicUrl becomes http://127.0.0.1:0/..., so bot.api.setWebhook(publicUrl, ...) registers an unusable URL. Compute the URL after listen() using server.address().port (or require a non-zero port when publicUrl isn’t explicitly provided).
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/telegram/webhook.ts
Line: 33:37
Comment:
**Port 0 breaks webhook URL**
`startTelegramWebhook` uses `const port = opts.port ?? 8787;` and then builds `publicUrl` from that `port` before calling `server.listen(port, host, ...)`. When callers pass `port: 0` (tests do this, and other callers may for ephemeral ports), the server binds to a random port but `publicUrl` becomes `http://127.0.0.1:0/...`, so `bot.api.setWebhook(publicUrl, ...)` registers an unusable URL. Compute the URL after `listen()` using `server.address().port` (or require a non-zero port when `publicUrl` isn’t explicitly provided).
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
This is a pre-existing issue in the telegram webhook setup, not introduced by our change. Our PR only changes the default bind host from 0.0.0.0 to 127.0.0.1 — the port resolution logic is unchanged.
Change canvas host and telegram webhook default bind from 0.0.0.0 (all interfaces) to 127.0.0.1 (loopback only) to prevent unintended network exposure when no explicit host is configured.
…faults (openclaw#13184) thanks @davidrudduck
986ffed to
ce4ee67
Compare
…13184) * fix(security): default standalone servers to loopback bind (openclaw#4) Change canvas host and telegram webhook default bind from 0.0.0.0 (all interfaces) to 127.0.0.1 (loopback only) to prevent unintended network exposure when no explicit host is configured. * fix: restore telegram webhook host override while keeping loopback defaults (openclaw#13184) thanks @davidrudduck * style: format telegram docs after rebase (openclaw#13184) thanks @davidrudduck --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
…13184) * fix(security): default standalone servers to loopback bind (openclaw#4) Change canvas host and telegram webhook default bind from 0.0.0.0 (all interfaces) to 127.0.0.1 (loopback only) to prevent unintended network exposure when no explicit host is configured. * fix: restore telegram webhook host override while keeping loopback defaults (openclaw#13184) thanks @davidrudduck * style: format telegram docs after rebase (openclaw#13184) thanks @davidrudduck --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
…13184) * fix(security): default standalone servers to loopback bind (openclaw#4) Change canvas host and telegram webhook default bind from 0.0.0.0 (all interfaces) to 127.0.0.1 (loopback only) to prevent unintended network exposure when no explicit host is configured. * fix: restore telegram webhook host override while keeping loopback defaults (openclaw#13184) thanks @davidrudduck * style: format telegram docs after rebase (openclaw#13184) thanks @davidrudduck --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
…13184) * fix(security): default standalone servers to loopback bind (openclaw#4) Change canvas host and telegram webhook default bind from 0.0.0.0 (all interfaces) to 127.0.0.1 (loopback only) to prevent unintended network exposure when no explicit host is configured. * fix: restore telegram webhook host override while keeping loopback defaults (openclaw#13184) thanks @davidrudduck * style: format telegram docs after rebase (openclaw#13184) thanks @davidrudduck --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
…13184) * fix(security): default standalone servers to loopback bind (openclaw#4) Change canvas host and telegram webhook default bind from 0.0.0.0 (all interfaces) to 127.0.0.1 (loopback only) to prevent unintended network exposure when no explicit host is configured. * fix: restore telegram webhook host override while keeping loopback defaults (openclaw#13184) thanks @davidrudduck * style: format telegram docs after rebase (openclaw#13184) thanks @davidrudduck --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
…13184) * fix(security): default standalone servers to loopback bind (#4) Change canvas host and telegram webhook default bind from 0.0.0.0 (all interfaces) to 127.0.0.1 (loopback only) to prevent unintended network exposure when no explicit host is configured. * fix: restore telegram webhook host override while keeping loopback defaults (openclaw#13184) thanks @davidrudduck * style: format telegram docs after rebase (openclaw#13184) thanks @davidrudduck --------- Co-authored-by: Peter Steinberger <steipete@gmail.com> (cherry picked from commit 5643a93) # Conflicts: # CHANGELOG.md # docs/channels/telegram.md
…13184) * fix(security): default standalone servers to loopback bind (#4) Change canvas host and telegram webhook default bind from 0.0.0.0 (all interfaces) to 127.0.0.1 (loopback only) to prevent unintended network exposure when no explicit host is configured. * fix: restore telegram webhook host override while keeping loopback defaults (openclaw#13184) thanks @davidrudduck * style: format telegram docs after rebase (openclaw#13184) thanks @davidrudduck --------- Co-authored-by: Peter Steinberger <steipete@gmail.com> (cherry picked from commit 5643a93) # Conflicts: # CHANGELOG.md # docs/channels/telegram.md # src/telegram/monitor.ts
…13184) * fix(security): default standalone servers to loopback bind (#4) Change canvas host and telegram webhook default bind from 0.0.0.0 (all interfaces) to 127.0.0.1 (loopback only) to prevent unintended network exposure when no explicit host is configured. * fix: restore telegram webhook host override while keeping loopback defaults (openclaw#13184) thanks @davidrudduck * style: format telegram docs after rebase (openclaw#13184) thanks @davidrudduck --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
Summary
127.0.0.1instead of0.0.0.0.Supersedes #12370 (accidentally closed during fork maintenance).
Test plan
Greptile Overview
Greptile Summary
This PR hardens the default networking posture of the standalone HTTP servers by changing the default bind address from
0.0.0.0to127.0.0.1in:src/canvas-host/server.ts(canvas host)src/telegram/webhook.ts(Telegram webhook listener)The change reduces accidental exposure on machines with public interfaces while still allowing explicit overrides via config (
listenHost/host).One functional issue remains in the Telegram webhook server: when
port: 0is used (ephemeral port), the code constructs the webhookpublicUrlusing the requested port before the server is actually listening, resulting inhttp://…:0/...being registered with Telegram.Confidence Score: 3/5
startTelegramWebhookcurrently registers a webhook URL usingportprior tolisten(). Withport: 0, this deterministically produces an invalid:0webhook URL and will break webhook delivery in any environment using an ephemeral port (including the existing unit test setup).Context used:
dashboard- CLAUDE.md (source)dashboard- AGENTS.md (source)