Securityaffairs

Telegram Desktop Flaw Could Turn Old Chat Exports Into Data Theft Traps


Telegram Desktop Flaw Could Turn Old Chat Exports Into Data Theft Traps

Pierluigi Paganini
September 15, 2026

A Telegram Desktop flaw let bots inject JavaScript into exported chats, enabling data theft and page manipulation. Old HTML exports remain unsafe.

A vulnerability in Telegram Desktop could have turned an ordinary chat export into a serious data leak. Security researchers Denis and Aleksander Rostilov of ExPatch found a stored cross-site scripting flaw in the application’s HTML export feature that allowed malicious JavaScript to hide inside a Telegram message and run later when someone opened the exported file in a browser.

“A stored XSS in Telegram Desktop lets an attacker plant invisible JavaScript in an exportable chat through a bot’s inline keyboard button. The payload can sit in message history for months and detonates when a participant opens an HTML export page containing that message.” reads the report published by ExPatch. “No second click, no warning: every message and metadata field rendered in that document can be shipped to the attacker’s server, and the page itself can be rewritten. The bot never joins the target chat — one forwarded message can be enough.”

The attack is unusual because the attacker doesn’t need to be a member of the target group. A bot can create a message containing a specially crafted inline keyboard, and that message can then be forwarded into other chats. Once included in the conversation history, the payload can remain there for months or even years, waiting for someone to export the chat.

The Telegram app itself doesn’t execute the code. That’s an important distinction. The problem appears when Telegram Desktop converts the stored conversation into an HTML document that is later opened in a browser, where the injected content is interpreted as JavaScript.

The researchers traced the problem to Telegram Desktop’s HTML export code. In export_output_html.cpp, the application wrote the text of inline keyboard buttons directly into the HTML output instead of passing it through the existing SerializeString() sanitization function. That meant HTML tags placed in the button text could be treated as real markup in the exported document.

“When exporting a chat to HTML, Telegram Desktop writes inline-button text straight into the HTML page — unescaped. SerializeString(), which escapes every HTML-dangerous character (<>&"'), converts newlines and Unicode line/paragraph separators to 
, and hex-encodes ASCII control characters, is defined in the same file and applied to message text, sender names, and other fields. It just wasn’t applied to button text.” continues the report. “That means any HTML sitting in a button’s text property renders as live markup in the exported page. 



Source link