Skip to content

docs: Document Telegram gateway security pipeline & fix YAML allowlist fields#492

Merged
MervinPraison merged 1 commit into
mainfrom
claude/issue-486-20260602-1903
Jun 3, 2026
Merged

docs: Document Telegram gateway security pipeline & fix YAML allowlist fields#492
MervinPraison merged 1 commit into
mainfrom
claude/issue-486-20260602-1903

Conversation

@MervinPraison
Copy link
Copy Markdown
Owner

Fixes #486

This PR addresses the documentation gaps identified after PraisonAI PR #1791, which fixed a security vulnerability where the Telegram gateway polling path bypassed all access-control enforcement.

Changes Made

📚 New Documentation Sections

  • Channel Security subsection in bot-gateway.mdx with complete YAML reference table, security pipeline diagram, and configuration examples
  • Channel Security section in channels-gateway.mdx showing standalone/gateway parity
  • Gateway Mode note in bot-unknown-user-pairing.mdx with gateway YAML configuration example

🐛 Critical Bug Fixes

  • Fixed field name throughout bot-security.mdx: allowlist: → allowed_users:
  • Added warning callout about field name requirements (examples using allowlist: silently produce bots with no enforcement)
  • Updated user ID format comments to clarify platform-specific requirements

🔗 Cross-References

  • Added cross-link from messaging-bots.mdx to gateway security documentation
  • Linked gateway and standalone bot configuration references

🎨 Visual Improvements

  • Added Mermaid security pipeline diagram following AGENTS.md color standards
  • Included comparison tables showing feature parity between modes

Impact

  • Users can now properly configure gateway security (previously undocumented)
  • Fixed critical examples that would silently break security enforcement
  • Clarified that gateway mode now enforces the same security as standalone bots

Generated with Claude Code

…t fields (fixes #486)

This commit addresses the documentation gaps identified after PR #1791, which fixed
the security vulnerability where Telegram gateway polling bypassed access controls.

Changes:
- Add Channel Security subsection to bot-gateway.mdx with YAML reference table,
  security pipeline diagram, and configuration examples
- Add Channel Security section to channels-gateway.mdx showing standalone/gateway parity
- Add Gateway Mode note to bot-unknown-user-pairing.mdx with gateway YAML example
- Fix critical bug: replace 'allowlist:' with 'allowed_users:' throughout bot-security.mdx
- Add cross-link from messaging-bots.mdx to gateway security documentation
- Include Mermaid diagrams following AGENTS.md color standards
- Add warnings about empty allowed_users and field name requirements

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Mervin Praison <MervinPraison@users.noreply.github.com>
@qodo-code-review
Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 2, 2026

Warning

Review limit reached

@MervinPraison, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 55 minutes and 15 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bbd3e04d-beef-429a-b341-228c0aab710b

📥 Commits

Reviewing files that changed from the base of the PR and between aa7ace5 and 30f4a76.

📒 Files selected for processing (5)
  • docs/best-practices/bot-security.mdx
  • docs/features/bot-gateway.mdx
  • docs/features/bot-unknown-user-pairing.mdx
  • docs/features/channels-gateway.mdx
  • docs/features/messaging-bots.mdx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/issue-486-20260602-1903

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the documentation to align with security pipeline changes introduced in PR #1791, detailing the transition from allowlist to allowed_users and explaining how gateway-mode bots now enforce the same security controls as standalone bots. However, the reviewer identified several critical mismatches between these documentation updates and the underlying codebase. Specifically, the Pydantic schema (ChannelConfigSchema) still expects allowlist as a list and lacks definitions for allowed_channels and allowed_users as a list, which will cause validation errors. Additionally, the gateway server implementation fails to extract or pass unknown_user_policy and owner_user_id from the configuration, silently breaking the pairing workflow. Minor documentation issues were also noted, including missing keys in the Channel Security reference table and inconsistent link prefixes.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +10 to +12
<Warning>
**Field name is `allowed_users`, not `allowlist`.** The gateway YAML parser only recognizes `allowed_users:` and `allowed_channels:`. Examples using `allowlist:` will silently produce a bot with **no enforcement**. (Fixed in [PR #1791](https://github.com/MervinPraison/PraisonAI/pull/1791).)
</Warning>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

There is a critical mismatch between this documentation change and the Pydantic configuration schema in praisonai/bots/_config_schema.py.

In _config_schema.py, ChannelConfigSchema defines:

  • allowlist: List[str] = Field(default_factory=list)
  • allowed_users: Optional[str] = None

If a user configures bot.yaml (for standalone bot mode) using allowed_users as a list (as shown in the updated examples on lines 151, 172, 194, 214, etc.), praisonai bot start --config bot.yaml will fail Pydantic validation with a ValidationError (since a list cannot be coerced into Optional[str]).

To resolve this, the codebase's ChannelConfigSchema in praisonai/bots/_config_schema.py should be updated to support allowed_users as a list or string, or the documentation should clarify that allowlist is still required for standalone bot.yaml while allowed_users is used for gateway.yaml.

Comment on lines +89 to +91
<Info>
**Gateway mode (`praisonai gateway start`)**: As of PR #1791, the gateway polling path runs the same pairing pipeline as the standalone bot. If `pairing.enabled: true` is set in your gateway config, unknown users get the same Approve/Deny inline-button flow. No code changes needed — configure `unknown_user_policy: "pair"` and `owner_user_id` in your `channels:` YAML entry.
</Info>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

There is a critical implementation gap between this documentation and the gateway server codebase (praisonai/gateway/server.py).

Currently, praisonai/gateway/server.py does not extract or pass unknown_user_policy or owner_user_id from the channel's YAML configuration (ch_cfg) when instantiating BotConfig on line 1651:

            config_kwargs = dict(
                token=token,
                allowed_users=list(_raw_allowed),
                allowed_channels=list(_raw_channels),
                mention_required=mention_required,
                auto_approve_tools=auto_approve_tools,
            )

Because of this, any unknown_user_policy or owner_user_id configured in gateway.yaml will be completely ignored, defaulting to "deny" and None respectively, which silently breaks the pairing workflow in gateway mode.

Additionally, there is no pairing or pairing.enabled field defined in GatewayConfig or ChannelConfigSchema.

To fix this, the gateway server's start_channels method in praisonai/gateway/server.py needs to be updated to extract and pass these fields to BotConfig:

            config_kwargs = dict(
                token=token,
                allowed_users=list(_raw_allowed),
                allowed_channels=list(_raw_channels),
                mention_required=mention_required,
                auto_approve_tools=auto_approve_tools,
                unknown_user_policy=ch_cfg.get("unknown_user_policy", "deny"),
                owner_user_id=ch_cfg.get("owner_user_id"),
            )

Comment on lines +178 to +187
| YAML Key | Type | Default | Purpose |
|----------|------|---------|---------|
| `token` | `str` | required* | Bot auth token. *Optional for `whatsapp` web mode and `email`/`agentmail`. |
| `platform` | `str` | channel name | Override channel platform (e.g. `telegram`). |
| `routing` / `routes` | `dict` | `{"default": "default"}` | Route map: `dm`, `group`, `default` → agent id. |
| `allowed_users` | `list[str]` \| `str` | `[]` | User-ID allowlist. Comma-separated string also accepted (env-expansion friendly). |
| `allowed_channels` | `list[str]` \| `str` | `[]` | Channel/group-ID allowlist. Same string handling. |
| `group_policy` | `str` | `"mention_only"` | One of `"mention_only"`, `"command_only"`, `"respond_all"`. Sets `mention_required` automatically. |
| `auto_approve_tools` | `bool` \| `str` | `True` | Auto-approve safe tools. Strings `"1"/"true"/"yes"/"on"` are truthy. |
| `default_tools` | `list[str]` | (BotConfig default) | Per-channel override for default safe tools. |
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The YAML reference table for Channel Security is missing unknown_user_policy and owner_user_id keys, which are documented as configurable in channels: entries in bot-unknown-user-pairing.mdx. Adding them to this reference table will improve completeness and consistency.

Comment on lines +258 to +263
| Feature | Standalone Bot | Gateway Mode |
|---------|----------------|--------------|
| User allowlist (`allowed_users`) | ✅ | ✅ |
| Channel allowlist (`allowed_channels`) | ✅ | ✅ |
| Unknown user pairing | ✅ | ✅ |
| Group policy enforcement | ✅ | ✅ |
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The table states that allowed_channels is supported for Standalone Bots. However, ChannelConfigSchema in praisonai/bots/_config_schema.py (which validates bot.yaml for standalone bots) does not define allowed_channels. Consequently, configuring allowed_channels in bot.yaml will cause a validation error on startup.

Please update praisonai/bots/_config_schema.py to include allowed_channels to ensure parity between standalone bot.yaml and gateway configurations.

Comment on lines +499 to 500
When running via the gateway, set `group_policy` per channel in `gateway.yaml`. See [Bot Gateway → Channel Security](/docs/features/bot-gateway#channel-security).
</Note>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The link /docs/features/bot-gateway#channel-security uses the /docs prefix, whereas other links in this file (e.g., /features/cross-platform-mirror on line 11, /features/bot-commands on line 935) do not use the /docs prefix. Please ensure consistency across documentation links to prevent broken links depending on the documentation site's routing configuration.

@MervinPraison MervinPraison merged commit cee76d1 into main Jun 3, 2026
26 checks passed
@MervinPraison MervinPraison deleted the claude/issue-486-20260602-1903 branch June 3, 2026 04:51
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.

[Docs] Document Telegram gateway security pipeline & gateway YAML allowlist fields (PR #1791)

1 participant