CVE-2026-52830: fast-mcp-telegram: Bearer token path traversal bypasses reserved Telegram session protection
fast-mcp-telegram builds a session-file path from the raw HTTP Bearer token, so a token like `../fast-mcp-telegram/telegram` passes the check that blocks the reserved name `telegram`. A remote client with no credentials can then act as the default Telegram account. Affects versions up to 0.19.0. Fixed in 0.19.1.
Published Jul 2, 2026 · Updated Aug 13, 2026 · Analysis Oct 25, 2026
What an attacker can do
SessionFileTokenVerifier.verify_token() rejects the exact token telegram, then appends .session to the raw token and checks that the file exists. Nothing rejects /, \, .. or absolute paths, and the path is not resolved against the session directory. With the default directory, the token ../fast-mcp-telegram/telegram resolves to ~/.config/fast-mcp-telegram/telegram.session. That is the file the reserved-name rule exists to protect. src/client/connection.py builds the client path the same way.
The condition is that the HTTP auth server is running and the default or legacy telegram.session file exists. Then an unauthenticated network client can call Telegram MCP tools as that account: read messages, send messages, make MTProto API calls and use attachment tools. Account-prefixed tools do not help. The middleware sits after authentication and simply lists the prefixed tools of the default account.
For anyone who ran the stdio setup first and later switched on HTTP auth, the old session file is likely still there. The attacker needs only network reach to the HTTP port.
Who is affected
Affected: pip package fast-mcp-telegram 0.19.0 and earlier, when run as an HTTP server with bearer-token auth and when ~/.config/fast-mcp-telegram/telegram.session (or another default session file in the session directory) exists. Stdio-only use does not take bearer tokens.
pip show fast-mcp-telegram
ls ~/.config/fast-mcp-telegram/If the directory holds telegram.session, the default account is reachable.
fast-mcp-telegram
- Ecosystem
- PyPI
- Affected
- <= 0.19.0
- Fixed in
- 0.19.1
- Check
pip show fast-mcp-telegram
How to fix it
Upgrade to 0.19.1.
pip install -U fast-mcp-telegramThe advisory does not describe the patch itself. It recommends accepting only a strict token alphabet such as ^[A-Za-z0-9_-]{32,128}$, rejecting separators and .., and resolving the final path to confirm it stays directly under the session directory. It lists no workaround. If you cannot upgrade, move the default telegram.session out of the session directory and keep the HTTP port off untrusted networks. Those two steps are practical measures that follow from the flaw, not vendor advice.
How to tell if you were hit
Search HTTP access logs and the Authorization headers your proxy records for bearer tokens that contain /, \ or ... Those are never valid generated tokens. Check Telegram's active sessions list for the default account and look for sent messages you did not write. If you find a hit, revoke the Telegram session, delete the .session file and log in again.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
Summary
fast-mcp-telegram validates HTTP Bearer tokens by joining the raw token string into a session-file path. The verifier rejects the exact reserved token telegram, but it does not reject path separators or normalize the path before checking whether the session file exists. A remote HTTP client can therefore authenticate as the default legacy session with a token such as ../fast-mcp-telegram/telegram when the documented default session file ~/.config/fast-mcp-telegram/telegram.session exists.
This bypasses the reserved session name control that is intended to prevent HTTP multi-user sessions from colliding with the default stdio or legacy account. With account-prefixed MCP tools enabled, the attacker still sees and calls the prefixed tools for the default account, so the prefix middleware does not stop the session selection bypass.
Impact
An unauthenticated network client can access the Telegram account represented by the default telegram.session file without knowing a generated bearer token, if that legacy or default session file is present on a server running HTTP auth. The attacker can then call Telegram MCP tools as that account, including message reading, message sending, MTProto API calls, and attachment-producing tool surfaces available to the session.
Technical details
SessionFileTokenVerifier.verify_token() strips whitespace and rejects exact reserved names:
if token.lower() in RESERVED_SESSION_NAMES:
return NoneIt then appends .session to the raw token and checks the resulting path:
session_path = self._session_directory / f"{token}.session"
if not session_path.is_file():
return NoneNo check rejects /, \\, .., absolute paths, or resolved paths outside the configured session directory. The session client path is built the same way in src/client/connection.py:
session_path = SESSION_DIR / f"{token}.session"
client = await _build_telegram_client_for_token(session_path, token)With the default session directory, the token ../fast-mcp-telegram/telegram resolves as follows:
~/.config/fast-mcp-telegram/../fast-mcp-telegram/telegram.session
= ~/.config/fast-mcp-telegram/telegram.sessionThe exact token telegram is denied, but the traversal alias reaches the same file and is accepted. This is especially important because telegram is the documented default session_name, and the security documentation says reserved names are blocked to prevent conflicts with stdio and HTTP no-auth sessions.
The vulnerable code is present on current master commit 167ab705f1cd09b21e85c370570471fe75a4f8c9 and in release tag 0.19.0 commit 77bdf6d7e5c6a84d87acc423db613e6c6ba30094.
Reproduction
The following proof uses stub session files and stub Telegram clients, so it does not need real Telegram credentials. It validates the auth decision and the eventual session path used by the client builder.
Run on current master:
git clone https://github.com/leshchenko1979/fast-mcp-telegram.git
cd fast-mcp-telegram
python validation_token_traversal.pyThe local proof script created for validation is attached below for reference:
# High-level proof outline
# 1. Create a temporary session directory containing telegram.session and a random token session.
# 2. Instantiate SessionFileTokenVerifier with that directory.
# 3. Verify denied controls: token `telegram` is rejected, and a traversal token to a missing file is rejected.
# 4. Verify allowed control: a normal random token with a matching session file is accepted.
# 5. Verify bypass: token `../fast-mcp-telegram/telegram` is accepted and the client builder receives the default telegram.session path.
# 6. Verify prefix behavior: account-prefixed tools are listed for the traversal-authenticated default account, a prefixed call reaches send_message, and an unprefixed call is still denied.Key controls from the current-master run:
{
"reserved_default_token_denied": true,
"normal_random_token_allowed": true,
"missing_traversal_token_denied": true,
"traversal_alias_to_reserved_default_allowed": true,
"traversal_access_token_value": "../fast-mcp-telegram/telegram",
"client_builder_used_default_session_file": true,
"prefixed_tool_listed_for_traversal_token": "defaultalice_send_message",
"prefixed_tool_call_reached_handler_as": "send_message",
"unprefixed_tool_call_denied_when_prefix_resolved": true
}Interpretation:
- Denied control: the exact reserved token
telegramis rejected. - Allowed control: a normal random session token is accepted when its matching session file exists.
- Denied control: a traversal token pointing to a missing file is rejected.
- Bypass:
../fast-mcp-telegram/telegramauthenticates and the client builder receives the resolved default session path. - Prefix control: once authenticated through the traversal token, account-prefixed tools are listed and a prefixed
tools/callreaches the internalsend_messagehandler. An unprefixed call is rejected when the prefix resolves, so the confirmed bug is the session selection and authentication bypass, not a missing-prefix execution bypass.
Why this crosses the auth boundary
A production HTTP auth deployment is expected to require high-entropy per-session bearer tokens. Reserved names are explicitly blocked because common names such as telegram can collide with the default session. The traversal alias turns the public token namespace back into a filesystem namespace and bypasses that reserved-name policy.
The account-prefix middleware is downstream of authentication. It labels tools based on the resolved Telegram account for the token that was accepted. Because the traversal token is accepted as a valid FastMCP AccessToken, the middleware correctly exposes the default account's prefixed tools to the attacker. It cannot recover the lost authentication boundary.
Remediation
Reject bearer tokens that are not strict opaque token identifiers before using them in file paths. Recommended checks:
- Accept only a safe token alphabet, for example
^[A-Za-z0-9_-]{32,128}$, matching generated URL-safe base64 tokens. - Reject
/,\\,.,.., empty segments, and absolute paths for both header auth and URL auth. - Resolve the final session path and require it to remain directly under the configured session directory:
session_dir = self._session_directory.resolve()
session_path = (session_dir / f"{token}.session").resolve()
if session_path.parent != session_dir:
return None- Apply the same validation in
SessionFileTokenVerifier, URL auth middleware, setup flows, cleanup code, and any code that opens session files by token. - Add regression tests for exact reserved names, traversal aliases such as
../fast-mcp-telegram/telegram, absolute paths, URL-encoded traversal if any route decodes path components, Windows separators, and normal generated tokens.
Credited to DavidCarliez.
Questions
- Is the default stdio setup affected?
The advisory describes the flaw in HTTP bearer-token auth. The risk is a server running HTTP auth while a default
telegram.sessionfile is present in the session directory.- Why is the token `telegram` blocked but the traversal token works?
The check compares only the exact string.
../fast-mcp-telegram/telegramis a different string that resolves to the same file once.sessionis appended and the path is opened.- Which version fixes CVE-2026-52830?
fast-mcp-telegram 0.19.1. Versions up to and including 0.19.0 are affected.
References
Read for this analysis:
- https://nvd.nist.gov/vuln/detail/CVE-2026-52830
- https://github.com/pypa/advisory-database/tree/main/vulns/fast-mcp-telegram/PYSEC-2026-2473.yaml
- https://pypi.org/project/fast-mcp-telegram
- https://web.archive.org/web/20250926152207/https://github.com/leshchenko1979/fast-mcp-telegram
- https://github.com/advisories/GHSA-rxw2-pc8j-vxwm
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
More Other MCP servers and tools vulnerabilities
All Other MCP servers and tools entriesCVE-2026-77361
obsidian-tc : Symlink read-ACL scope bypass via lexical path checks
medium4.7Oct 23, 2026CVE-2026-114126
Storybook dev server vulnerable to code injection from the local network
high8.7Oct 22, 2026CVE-2026-113731
djust: Arbitrary absolute-path file read in the find_handlers_for_template MCP tool
low3.3Oct 21, 2026CVE-2026-114125
Storybook: Missing origin validation in Storybook preview allows code injection from malicious websites
critical9.4Oct 21, 2026CVE-2026-111770
MCP TypeScript server SDK: Shared transport or server instances delivered one HTTP client's messages to another
high7.7Oct 20, 2026GHSA-953h-535j-jg2v
agent-router: MCP session resume does not verify the embedded anti-hijacking subject; default Helm seed makes session IDs forgeable
medium6.8Oct 19, 2026
