Skip to content

fix(security): default standalone servers to loopback bind#13184

Merged
steipete merged 3 commits intoopenclaw:mainfrom
davidrudduck:fix/default-bind-loopback
Feb 13, 2026
Merged

fix(security): default standalone servers to loopback bind#13184
steipete merged 3 commits intoopenclaw:mainfrom
davidrudduck:fix/default-bind-loopback

Conversation

@davidrudduck
Copy link
Contributor

@davidrudduck davidrudduck commented Feb 10, 2026

Summary

  • Default standalone HTTP servers (canvas-host, webhook listener) to bind on 127.0.0.1 instead of 0.0.0.0.
  • Prevents unintended network exposure when running on machines with public interfaces.
  • Users who need external access can still override via configuration.

Supersedes #12370 (accidentally closed during fork maintenance).

Test plan

  • Verify canvas host binds to localhost by default
  • Verify telegram webhook listener binds to localhost by default
  • Verify explicit bind address config still works when overridden

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.0 to 127.0.0.1 in:

  • 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: 0 is used (ephemeral port), the code constructs the webhook publicUrl using the requested port before the server is actually listening, resulting in http://…:0/... being registered with Telegram.

Confidence Score: 3/5

  • This PR is not safe to merge until the Telegram webhook URL/port handling is fixed for ephemeral ports.
  • Binding to loopback by default is a straightforward security hardening, but startTelegramWebhook currently registers a webhook URL using port prior to listen(). With port: 0, this deterministically produces an invalid :0 webhook URL and will break webhook delivery in any environment using an ephemeral port (including the existing unit test setup).
  • src/telegram/webhook.ts

Context used:

  • Context from dashboard - CLAUDE.md (source)
  • Context from dashboard - AGENTS.md (source)

@openclaw-barnacle openclaw-barnacle bot added the channel: telegram Channel integration: telegram label Feb 10, 2026
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines 33 to 37
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;
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

davidrudduck and others added 3 commits February 13, 2026 16:36
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.
@steipete steipete force-pushed the fix/default-bind-loopback branch from 986ffed to ce4ee67 Compare February 13, 2026 15:37
@steipete steipete merged commit 5643a93 into openclaw:main Feb 13, 2026
9 checks passed
alex-muradov pushed a commit to alex-muradov/openclaw that referenced this pull request Feb 13, 2026
…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>
@openclaw-barnacle openclaw-barnacle bot added docs Improvements or additions to documentation size: XS labels Feb 13, 2026
zhangyang-crazy-one pushed a commit to zhangyang-crazy-one/openclaw that referenced this pull request Feb 13, 2026
…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>
skyhawk14 pushed a commit to skyhawk14/openclaw that referenced this pull request Feb 13, 2026
…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>
steipete added a commit to azade-c/openclaw that referenced this pull request Feb 14, 2026
…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>
@davidrudduck davidrudduck deleted the fix/default-bind-loopback branch February 14, 2026 11:04
GwonHyeok pushed a commit to learners-superpumped/openclaw that referenced this pull request Feb 15, 2026
…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>
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 1, 2026
…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
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 3, 2026
…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
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram docs Improvements or additions to documentation size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants