Skip to content

fix(telegram): warn when setup leaves dmPolicy as pairing without allowFrom#50710

Merged
obviyus merged 4 commits intoopenclaw:mainfrom
ernestodeoliveira:fix/telegram-pairing-security-warning
Mar 20, 2026
Merged

fix(telegram): warn when setup leaves dmPolicy as pairing without allowFrom#50710
obviyus merged 4 commits intoopenclaw:mainfrom
ernestodeoliveira:fix/telegram-pairing-security-warning

Conversation

@ernestodeoliveira
Copy link
Copy Markdown
Contributor

Summary

When a user completes the Telegram channel setup without configuring an allowFrom list, the bot silently defaults to dmPolicy: "pairing". This means any Telegram user who discovers the bot can send pairing requests — potentially gaining access to a bot that handles private data, files, or system commands.

Most users are not aware of this exposure. There is currently no warning in the setup flow to inform them.

Problem

The getCurrent fallback in setup-surface.ts defaults to pairing:

getCurrent: (cfg) => cfg.channels?.telegram?.dmPolicy ?? 'pairing',

A user who completes the wizard without explicitly choosing a DM policy, or without adding allowFrom entries, ends up with an open bot and no indication of the risk.

Solution

Added a completionNote to telegramSetupWizard that is conditionally shown after setup completes. It only triggers when:

  1. dmPolicy is effectively pairing (default or explicitly set), and
  2. allowFrom is empty or not configured

When shown, the note includes:

  • A plain-language explanation of the exposure
  • The exact CLI commands to switch to an allowlist
  • A link to the pairing documentation
⚠️  Telegram DM access warning

Your bot is using the default DM policy (pairing).
Any Telegram user who discovers the bot can send pairing requests.
For private use, configure an allowlist with your Telegram user id:

  openclaw config set channels.telegram.dmPolicy "allowlist"
  openclaw config set channels.telegram.allowFrom "[YOUR_USER_ID]"

Docs: https://docs.openclaw.ai/channels/pairing

Design decisions

  • No behavior change: The default remains pairing to avoid breaking existing users. This is purely informational.
  • Minimal surface: Only one file changed (setup-surface.ts). No schema changes, no new dependencies beyond existing plugin-sdk/setup-tools helpers.
  • Surgical condition: Warning fires only on the exact unsafe combination (pairing + no allowFrom). Users who explicitly choose pairing are informed once; users who configure allowFrom correctly never see it.

Testing

  • All 977 existing Telegram tests pass
  • TypeScript type-checks clean (pnpm typecheck)
  • Formatting clean (pnpm format:check)

Files changed

  • extensions/telegram/src/setup-surface.ts — added completionNote with shouldShow guard

@openclaw-barnacle openclaw-barnacle bot added channel: telegram Channel integration: telegram size: XS labels Mar 20, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 20, 2026

Greptile Summary

This PR adds a security-awareness completionNote to the Telegram channel setup wizard that warns users when their bot is left in the pairing DM policy without any allowFrom entries — the configuration most likely to expose the bot to unsolicited pairing requests.

  • The implementation is purely additive and consistent with how other channels (e.g. Synology Chat) use completionNote and shouldShow.
  • mergeTelegramAccountConfig is correctly used to resolve the final per-account config before evaluating the warning condition, ensuring multi-account setups are handled properly.
  • The hasAllowFrom check (Array.isArray(merged.allowFrom) && merged.allowFrom.some(...)) is a safe guard against non-array values that could appear in manually edited configs.
  • Minor: the warning text says "default DM policy (pairing)" but the shouldShow condition also fires when a user explicitly chose pairing. This makes the message factually misleading for that subset of users.

Confidence Score: 4/5

  • Safe to merge — purely informational, no behavioral change, no new dependencies.
  • The change touches a single file, introduces no schema or runtime behavior changes, and follows established patterns already present in the codebase. The only issue found is a minor wording inaccuracy in the warning message.
  • No files require special attention.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/telegram/src/setup-surface.ts
Line: 115

Comment:
**"default" wording inaccurate for explicitly-set policy**

The `shouldShow` guard fires whenever `dmPolicy === "pairing"` — which includes users who *explicitly* selected `pairing` during setup. Telling those users they're on the *default* policy is factually misleading. Consider dropping the word "default" or branching on whether the value was explicitly set:

```suggestion
      "Your bot is using DM policy: pairing.",
```

How can I resolve this? If you propose a fix, please make it concise.

Last reviewed commit: "fix(telegram): warn ..."

completionNote: {
title: "Telegram DM access warning",
lines: [
"Your bot is using the default DM policy (pairing).",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 "default" wording inaccurate for explicitly-set policy

The shouldShow guard fires whenever dmPolicy === "pairing" — which includes users who explicitly selected pairing during setup. Telling those users they're on the default policy is factually misleading. Consider dropping the word "default" or branching on whether the value was explicitly set:

Suggested change
"Your bot is using the default DM policy (pairing).",
"Your bot is using DM policy: pairing.",
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/telegram/src/setup-surface.ts
Line: 115

Comment:
**"default" wording inaccurate for explicitly-set policy**

The `shouldShow` guard fires whenever `dmPolicy === "pairing"` — which includes users who *explicitly* selected `pairing` during setup. Telling those users they're on the *default* policy is factually misleading. Consider dropping the word "default" or branching on whether the value was explicitly set:

```suggestion
      "Your bot is using DM policy: pairing.",
```

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 62c8e6a440

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +118 to +119
` ${formatCliCommand('openclaw config set channels.telegram.dmPolicy "allowlist"')}`,
` ${formatCliCommand('openclaw config set channels.telegram.allowFrom "[YOUR_USER_ID]"')}`,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Scope the suggested config paths to the configured account

This note runs after the setup wizard has already resolved the concrete accountId being configured (src/channels/plugins/setup-wizard.ts:429-447,851-861), but both commands here always target the top-level channels.telegram.* keys. In multi-account Telegram setups those top-level values are inherited by every account (extensions/telegram/src/accounts.ts:116-142), so a user configuring channels.telegram.accounts.work who follows this warning will unintentionally change DM policy and allowlist defaults for all Telegram bots, not just the account they just set up.

Useful? React with 👍 / 👎.

@ernestodeoliveira
Copy link
Copy Markdown
Contributor Author

CI Failures Note

The failing checks are unrelated to this PR's changes.

All failures are in \�xtensions/matrix/src/matrix/sdk.test.ts\ (Matrix crypto extension), specifically an \ENOENT\ error for a missing fixture file (\crypto-idb-snapshot.json). This is a pre-existing issue in the test suite that affects the Matrix extension, not the Telegram extension.

The Telegram-specific check (\�xtension-fast (telegram)) passed ✅, as did all other relevant checks (\check, \�uild-smoke, \checks (node, channels), \�xtension-src-outside-plugin-sdk-boundary, etc.).

Happy to rebase on a newer main if that helps, but the failures appear to be infrastructure/pre-existing rather than caused by this change.

@ernestodeoliveira
Copy link
Copy Markdown
Contributor Author

CI failures note

The failing jobs (\pnpm test:extensions, \pnpm test\ shards) are all in \�xtensions/matrix/src/matrix/sdk.test.ts\ — Matrix SDK crypto/IndexedDB tests that fail with \ENOENT: no such file or directory\ on the CI runner's temp path.

This PR only touches \�xtensions/telegram/src/setup-surface.ts\ (one file, no matrix dependency). The telegram-specific job (\�xtension-fast (telegram)) passes. Happy to rebase if main has a fix for the matrix flakiness, but the failures appear pre-existing and unrelated to this change.

@obviyus obviyus self-assigned this Mar 20, 2026
@obviyus obviyus force-pushed the fix/telegram-pairing-security-warning branch from 82da190 to af400f1 Compare March 20, 2026 03:59
@obviyus obviyus merged commit 80110c5 into openclaw:main Mar 20, 2026
7 checks passed
@obviyus
Copy link
Copy Markdown
Contributor

obviyus commented Mar 20, 2026

Landed on main.

Thanks @ernestodeoliveira.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: af400f1256

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"Any Telegram user who discovers the bot can send pairing requests.",
"For private use, configure an allowlist with your Telegram user id:",
" " + formatCliCommand(`openclaw config set ${configBase}.dmPolicy "allowlist"`),
" " + formatCliCommand(`openclaw config set ${configBase}.allowFrom '["YOUR_USER_ID"]'`),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use a shell-neutral array example in the remediation command

The new remediation line uses openclaw config set ... allowFrom '["YOUR_USER_ID"]'. That fixes POSIX shells, but on Windows cmd.exe the single quotes are passed through literally, so config set parses the value as a JSON5 string and writes allowFrom as the scalar string [“YOUR_USER_ID”] instead of an array (src/cli/config-cli.ts:158-171). Users who follow this warning from cmd.exe will still end up with an invalid Telegram allowlist, so this needs a shell-neutral form such as a --strict-json example.

Useful? React with 👍 / 👎.

Comment on lines +33 to +35
const hasAllowFrom =
Array.isArray(merged.allowFrom) && merged.allowFrom.some((e) => String(e).trim());
return policy === "pairing" && !hasAllowFrom;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate allowFrom entries before suppressing the warning

shouldShowTelegramDmAccessWarning currently treats any non-empty allowFrom entry as sufficient to skip the new warning. Telegram authorization later drops non-numeric entries (extensions/telegram/src/bot-access.ts:42-58), and the suite already covers that allowFrom: ["@testuser"] does not authorize senders (extensions/telegram/src/bot.create-telegram-bot.test.ts:793-805). In configs that still contain unresolved usernames or other invalid values, setup will now hide the warning even though dmPolicy: "pairing" still lets every real user initiate pairing.

Useful? React with 👍 / 👎.

yinuotxie pushed a commit to yinuotxie/openclaw that referenced this pull request Mar 20, 2026
…owFrom (openclaw#50710)

* fix(telegram): warn when setup leaves dmPolicy as pairing without allowFrom

* fix(telegram): scope setup warning to account config

* fix(telegram): quote setup allowFrom example

* fix: warn on insecure Telegram setup defaults (openclaw#50710) (thanks @ernestodeoliveira)

---------

Co-authored-by: Claude Code <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
fuller-stack-dev pushed a commit to fuller-stack-dev/openclaw that referenced this pull request Mar 20, 2026
…owFrom (openclaw#50710)

* fix(telegram): warn when setup leaves dmPolicy as pairing without allowFrom

* fix(telegram): scope setup warning to account config

* fix(telegram): quote setup allowFrom example

* fix: warn on insecure Telegram setup defaults (openclaw#50710) (thanks @ernestodeoliveira)

---------

Co-authored-by: Claude Code <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
fuller-stack-dev pushed a commit to fuller-stack-dev/openclaw that referenced this pull request Mar 20, 2026
…owFrom (openclaw#50710)

* fix(telegram): warn when setup leaves dmPolicy as pairing without allowFrom

* fix(telegram): scope setup warning to account config

* fix(telegram): quote setup allowFrom example

* fix: warn on insecure Telegram setup defaults (openclaw#50710) (thanks @ernestodeoliveira)

---------

Co-authored-by: Claude Code <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
pholpaphankorn pushed a commit to pholpaphankorn/openclaw that referenced this pull request Mar 22, 2026
…owFrom (openclaw#50710)

* fix(telegram): warn when setup leaves dmPolicy as pairing without allowFrom

* fix(telegram): scope setup warning to account config

* fix(telegram): quote setup allowFrom example

* fix: warn on insecure Telegram setup defaults (openclaw#50710) (thanks @ernestodeoliveira)

---------

Co-authored-by: Claude Code <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
frankekn pushed a commit to artwalker/openclaw that referenced this pull request Mar 23, 2026
…owFrom (openclaw#50710)

* fix(telegram): warn when setup leaves dmPolicy as pairing without allowFrom

* fix(telegram): scope setup warning to account config

* fix(telegram): quote setup allowFrom example

* fix: warn on insecure Telegram setup defaults (openclaw#50710) (thanks @ernestodeoliveira)

---------

Co-authored-by: Claude Code <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
alexey-pelykh pushed a commit to remoteclaw/remoteclaw that referenced this pull request Mar 28, 2026
…owFrom (openclaw#50710)

* fix(telegram): warn when setup leaves dmPolicy as pairing without allowFrom

* fix(telegram): scope setup warning to account config

* fix(telegram): quote setup allowFrom example

* fix: warn on insecure Telegram setup defaults (openclaw#50710) (thanks @ernestodeoliveira)

---------

Co-authored-by: Claude Code <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 80110c5)

# Conflicts:
#	CHANGELOG.md
#	extensions/telegram/src/setup-surface.ts
alexey-pelykh pushed a commit to remoteclaw/remoteclaw that referenced this pull request Mar 28, 2026
…owFrom (openclaw#50710)

* fix(telegram): warn when setup leaves dmPolicy as pairing without allowFrom

* fix(telegram): scope setup warning to account config

* fix(telegram): quote setup allowFrom example

* fix: warn on insecure Telegram setup defaults (openclaw#50710) (thanks @ernestodeoliveira)

---------

Co-authored-by: Claude Code <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 80110c5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants