Skip to content

fix(telegram): redact bot tokens from all remaining transport-error sites (#58594 salvage) - #65508

Merged
teknium1 merged 2 commits into
mainfrom
salvage/58594-telegram-redact-remaining
Jul 16, 2026
Merged

fix(telegram): redact bot tokens from all remaining transport-error sites (#58594 salvage)#65508
teknium1 merged 2 commits into
mainfrom
salvage/58594-telegram-redact-remaining

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Telegram transport errors can no longer leak the bot token through any adapter log line or SendResult.error. Telegram Bot API exceptions embed the credential in the request URL (/bot<TOKEN>/<method>), so every raw str(exception) interpolation is a leak surface. Closes #58376.

Salvages PR #58594 by @AlexFucuson9 (3 remaining sites from the original issue: rich-send rejected, rich-edit rejected, polling-degraded) and widens the fix to the whole class: all 48 additional raw-exception sites in the adapter now route through the existing _redact_telegram_error_text() helper (forced redaction, independent of the global security.redact_secrets toggle).

Changes

  • plugins/platforms/telegram/adapter.py: 51 raw-exception sites redacted — polling conflict/retry/network ladders, bootstrap conflict, deleteWebhook, overflow-split edits, draft sends, update-prompt/exec-approval/slash-confirm/clarify/model-picker sends (log + SendResult.error), media send fallbacks (voice, media group, photo→document, URL photo, animation), media cache failures (photo/voice/audio/video/document/sticker — PTB file-download URLs embed /file/bot<TOKEN>/), typing indicator, chat info, reactions, DM-topic and command-menu registration.
  • tests/gateway/test_telegram_error_redaction.py: +3 regression tests covering the SendResult.error return surface (update prompt, clarify) and delete_message debug logging.

Validation

Check Result
tests/gateway/test_telegram_error_redaction.py 7/7 passed
scripts/run_tests.sh tests/gateway/ -k telegram 1,189 passed, 0 failed
E2E (real adapter, token-embedding exceptions) token absent from logs and SendResult.error; *** marker present
ruff clean

Contributor commit cherry-picked with authorship preserved; merge via rebase.

Infographic

telegram-redaction-hull

AlexFucuson9 and others added 2 commits July 16, 2026 01:41
Telegram Bot API URLs carry credentials in the path as
/bot<TOKEN>/<method>. Three error-handling paths logged raw exception
text that could include these URLs:

- sendRichMessage fallback (line 1603)
- editMessageText fallback (line 1709)
- polling reconnect warning (line 1902)

Replace raw / with  which
uses the existing redact_sensitive_text(force=True) pipeline. This
matches the pattern already used by transient send failures, retry
errors, and legacy edit paths.

Fixes #58376
…xception sites

Extends @AlexFucuson9's 3-site fix (#58594) across the full adapter:
every logger call and SendResult.error that interpolates a raw PTB
exception now routes through _redact_telegram_error_text(). Covers
polling conflict/retry/network ladders, overflow-split edits, draft
sends, prompt/approval/clarify/picker sends, media send fallbacks,
media cache failures, reactions, and chat-info lookups (48 additional
sites). Telegram Bot API exceptions embed the token in the request URL
(/bot<TOKEN>/<method>), so any raw str(exc) is a leak surface.

Adds regression tests for SendResult.error redaction (update prompt,
clarify) and delete_message debug-log redaction.
@alt-glitch alt-glitch added type/security Security vulnerability or hardening P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins platform/telegram Telegram bot adapter area/auth Authentication, OAuth, credential pools needs-decision Awaiting maintainer decision before any implementation sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data labels Jul 16, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related to #58594 and #58376. The broader salvage needs a correction before merge: its polling-reconnect logging hunk still passes the raw error, and another raw exception interpolation remains.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/plugins Plugin system and bundled plugins needs-decision Awaiting maintainer decision before any implementation P3 Low — cosmetic, nice to have platform/telegram Telegram bot adapter sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telegram transport errors can expose bot tokens

3 participants