Telegram Desktop HTML Export Flaw Allowed Stealthy JavaScript Injection into Chat History

Researchers at ExPatch identified a vulnerability in Telegram Desktop that enabled attackers to embed malicious JavaScript into exported HTML chat histories without user detection. The flaw stemmed from insufficient sanitization of button captions added by bots, allowing hidden scripts to execute when the HTML file was opened in a browser. Malicious messages could be forwarded into chats and remain dormant until export, potentially exfiltrating messages, sender names, and timestamps to attacker servers. The issue affected versions 4.15.1 through 6.9.3, with fixes released in beta 6.9.4 and stable version 7.0.1 on July 14. No in-the-wild exploitation was observed, though the attack required specific conditions including an unpatched export and JavaScript-enabled browser. Users are advised to re-export chats after updating or open old files with JavaScript disabled.

AntiMalwareTranslated from Russian

Read at source

Researchers from ExPatch have disclosed a vulnerability in the desktop version of Telegram that allowed stealthy injection of JavaScript into exported chat histories. The flaw enabled attackers to embed malicious scripts within HTML exports without altering the visible appearance of messages inside the messenger itself.

The root cause lay in how Telegram Desktop handled button captions placed by bots beneath messages. While the application properly escaped dangerous characters in message text, sender names, and other fields, it failed to sanitize the text labels on inline buttons. Attackers could hide scripts using invisible characters, and the button-based payload persisted even after messages were forwarded between chats.

Once a user performed an HTML export in a vulnerable version, the script would execute automatically upon opening the file in any browser with JavaScript enabled. The code could copy conversation contents to a remote server or replace the displayed history with fake content such as a phishing form mimicking Telegram verification. Because large exports are split into separate files of one thousand messages each, the entire account remained protected, but individual chat segments were exposed.

The vulnerability existed in versions ranging from 4.15.1 to 6.9.3. A fix was included in beta release 6.9.4 and the stable version 7.0.1 published on July 14. Importantly, the patch does not retroactively secure previously generated HTML files, prompting researchers to recommend re-exporting old chats after updating or viewing legacy exports with JavaScript disabled.

No confirmed cases of real-world exploitation have been reported. The attack required three simultaneous conditions: use of a vulnerable Telegram Desktop version for export, presence of a malicious bot message in the exported chat, and opening the resulting HTML file in a browser with active scripting.

Meridian digestThe week's most consequential security stories, distilled into one briefing.See the digest

More in Vulnerabilities & Exploits

Telegram for Android Patches Voice Call Vulnerability Enabling Code Execution
Yandex Patches Millions of Stations After eMudhra Certificate Keys Compromised
Cisco ASA and FTD Face DoS Vulnerability in SSL VPN Already Exploited in the Wild