pypi aiogram 3.33.0
Security fixes and Testing World

45 minutes ago

This release fixes three security advisories; upgrading is recommended:
GHSA-52j5-qrwv-2vf2 (bot token in network errors),
GHSA-fvpw-9jw8-rj3h (filter bypasses) and
GHSA-hv98-r5fx-wc83 (webhook / undecodable updates, union validation cost).
All three were reported by the Anthropic OSS Scanner.

Security

  • CallbackData.pack() now refuses values that would not unpack back unchanged with a self-overlapping multi-character separator (such as "--"), instead of letting the end of one value shift into the next field. Reported by the Anthropic OSS Scanner (ANT-2026-0M5J1VQ7).
    GHSA-fvpw-9jw8-rj3h

  • MaybeInaccessibleMessageUnion is now discriminated by date (0 means aiogram.types.inaccessible_message.InaccessibleMessage), so nested messages are validated once instead of once per member, which took time exponential in the nesting depth.
    Reported by the Anthropic OSS Scanner (ANT-2026-IOHAUKLG).
    GHSA-hv98-r5fx-wc83

  • StateFilter(Group), Group() and "..." in Group now match the states of a StatesGroup nested three or more levels deep. Reported by the Anthropic OSS Scanner (ANT-2026-664Y7GWN).
    GHSA-fvpw-9jw8-rj3h

  • Update.event_type no longer keeps the last 128 updates alive in a process-wide cache; aiogram.utils.mypy_hacks is removed.
    Reported by the Anthropic OSS Scanner (ANT-2026-PX6H5HDK).
    GHSA-hv98-r5fx-wc83

  • and_f(...) now passes the data returned by a filter on to the next filters, as filters registered in a row already do. Previously a later filter in and_f did not see it, and a negated check on that value always passed. Reported by the Anthropic OSS Scanner (ANT-2026-RO3G83HJ).
    GHSA-fvpw-9jw8-rj3h

  • A filter that returns a coroutine or another awaitable instead of a result, such as a synchronous function or lambda that calls an async function, an async def wrapper around a synchronous function built with functools.wraps, or functools.partial over a Filter instance, now raises TypeError instead of passing for every update. aiogram does not await such results: declare async filters with async def. Reported by the Anthropic OSS Scanner (ANT-2026-IYO3AS6K).
    GHSA-fvpw-9jw8-rj3h

  • Fixed the bot token appearing in network errors.
    aiogram.exceptions.TelegramNetworkError and the aiohttp errors raised by Bot.download_file() / Bot.download() now show the token as <bot id>:*** in their message and traceback, and keep their type, so existing except clauses still catch them.
    The original exception is available as .original and may contain the token.
    Reported by the Anthropic OSS Scanner (ANT-2026-4GL80S7S).
    GHSA-52j5-qrwv-2vf2

  • List fields of Telegram objects, including nested rich text arrays, now stop validation at the first invalid item instead of collecting one error per item, so a validation error reports only the first invalid item of a list. The minimum supported pydantic version is now 2.8.0.
    Reported by the Anthropic OSS Scanner (ANT-2026-NM3LC5D1).
    GHSA-hv98-r5fx-wc83

  • Passing filters to a Scene entry point, on.<event>.enter(...), now emits a DeprecationWarning: these filters were never checked when entering the scene. Put access checks on the handler that enters the scene instead. Reported by the Anthropic OSS Scanner (ANT-2026-9QFTXU7P).
    GHSA-fvpw-9jw8-rj3h

  • Root filters registered with dp.update.filter(...) are now checked before the update is dispatched: a rejected update is reported as not handled, and the data a root filter returns is passed to the handlers. Previously these filters were silently ignored, so existing dp.update.filter(...) registrations start being enforced after upgrading. Reported by the Anthropic OSS Scanner (ANT-2026-EZKREY5K).
    GHSA-fvpw-9jw8-rj3h

  • The "Detected unknown update type" warning no longer includes the update, so Python's warning registry no longer keeps a copy of every such update; the update is logged on aiogram.event at DEBUG.
    Reported by the Anthropic OSS Scanner (ANT-2026-PI9G2NGU).
    GHSA-hv98-r5fx-wc83

  • The webhook handlers now decode the request body as UTF-8 and ignore the charset of the request, which could select a slow codec.
    Reported by the Anthropic OSS Scanner (ANT-2026-HL9BRR9S).
    GHSA-hv98-r5fx-wc83

  • Undecodable updates are now skipped and reported: an update that fails validation on the webhook path (both modes of SimpleRequestHandler and TokenBasedRequestHandler, Dispatcher.feed_raw_update and Dispatcher.feed_webhook_update with a dict) is answered with 200 so Telegram stops redelivering it, logged once on aiogram.webhook with the number of validation errors instead of the full error text, and passed to the errors handlers as an ErrorEvent whose update carries only update_id. Before, background mode lost the error in an unawaited task that rendered it in full on the event loop, and inline mode answered 500.
    Reported by the Anthropic OSS Scanner (ANT-2026-KMKQCARC).
    GHSA-hv98-r5fx-wc83

Features

  • Added aiogram.test, an experimental integration testing toolkit for bots,
    installed with the aiogram[test] extra.

    Updates go through your real aiogram.dispatcher.dispatcher.Dispatcher, so filters,
    middlewares, dependency injection, FSM and Scenes run as they do in production. A stateful
    fake Telegram answers every Bot API call and applies it to an isolated in-memory world.

    • Declare chats, users, memberships, forum topics, business connections, communities and
      invite links with aiogram.test.Blueprint.
    • Drive the world through actors (await user.send("/start"),
      await user.click(button), await user.follow_deep_link(), …). Every
      aiogram.types.Update variant has a trigger.
    • Assert on the resulting chat state, on the recorded calls, or on which handler and
      router handled an update.
    • The world models messages, polls and reactions, chat administration and membership, the
      bot's own rights and profile, forum topics, rich and ephemeral messages, sticker sets,
      Telegram Stars and gifts, file uploads and downloads, flood control and a clock the test
      controls. Calls the toolkit does not model are recorded and answered with a result
      synthesized from their return type. BotTestEnvironment.on() overrides any call per
      test.

    The pytest plugin loads on its own through a pytest11 entry point; -p no:aiogram
    turns it off.

    The API is provisional and may change incompatibly in minor releases. The parts intended
    to stay stable are listed in the toolkit documentation.
    #1887

Misc

  • The minimum supported typing-extensions version is now 4.12.1: 4.12.0 together with pydantic older than 2.10 could not import aiogram.
    #2035

  • The source distribution no longer includes the contributor tooling directories .claude/,
    openspec/ and .oss-scanner/.
    #2032

Don't miss a new aiogram release

NewReleases is sending notifications on new releases.