Skip to content

Security2 publishers3 min readPublished Updated

Telegram Desktop exports made before July 14 still carry a bot's injected JavaScript

ExPatch says Telegram Desktop wrote bot button text into HTML chat exports without escaping it from March 2024 until a July fix, and updating the app leaves every file the earlier builds wrote unchanged on disk.

The Watch · Security desk

Illustration accompanying Telegram Desktop exports made before July 14 still carry a bot's injected JavaScript

What happened

  • ExPatch researchers Denis Rostilov and Aleksander Rostilov published a writeup on September 12 on a Telegram Desktop flaw that let a bot plant hidden JavaScript in chats users exported to HTML.
  • Opening an affected export in a browser ran the script with no further click, and it could copy that file's messages, sender names, timestamps, chat name, member count and local path to the attacker's server.
  • The update escapes new exports and does not touch files written by earlier versions, so HTML exports made before the fix still carry the script.
  • The researchers scored the flaw 8.2 out of 10 on CVSS 3.1, and as of September 14 neither Telegram nor the U.S. National Vulnerability Database had published a score of its own.

Compiled by The WatchSomething wrong?How this is made

Why it matters

  • exposure Patching the client cleans nothing already on disk, so an organisation holding HTML exports has to remediate file by file, and the sorting key is which client version wrote each one.
  • capability Because a forwarded web-link button keeps its payload, a group that never added a bot can still hold one, so checking a chat's bot membership does not clear its exports.
  • constraint An export kept as evidence or a compliance record can be rewritten in the browser at display time while the bytes on disk stay as written, which limits what a pre-July HTML file can be used to prove.
  • decision Owners of old archives now choose between re-exporting every chat from Telegram's intact copy and reading the existing files with scripting switched off.

The export escaped message text, sender names and other fields [3]. It did not escape the text a bot chooses for the buttons under its own message [2]. A bot could put a script tag in that button text and pad it with invisible characters; in the build the researchers tested, the button then looked empty [4].

The bot does not have to be in the chat it targets. A message whose only buttons are web links keeps those buttons when it is forwarded, so any member who forwards the bot's message into a group brings the script with it [5]. From there the message sits in the history like any other until someone deletes it, and the export can be taken months or years later [6].

The researchers reported to Telegram on June 3, two days after finding the bug [13]. Commit 8457d13a by Telegram Desktop developer John Preston was written on June 30, 27 days later, and the escaping reached stable in 7.0.1 on July 14, 41 days after the report [14][23]. The unescaped line had been in stable releases since 4.15.1 in March 2024, roughly 28 months of exports written by vulnerable code [15][24].

The take from one file is bounded. Telegram Desktop splits long exports into files of 1,000 messages, and the script reads only the file it sits in, not the whole chat or the account [9]. What it can send is everything in that file: messages, sender names, timestamps, the chat's name, type and member count, and the local file path [8].

The script could also rewrite what the page showed. In the researchers' demonstration it replaced the whole export with a fake Telegram "verification" form [10]. The same control can change dates, senders or message text in a file being kept as a record, and neither Telegram's own copy of the chat nor the export file on disk was altered [11].

Whether an archive holds a carrier depends on how the export was made. Exporting a single chat from its menu includes every member's messages, while a full-account export includes by default only the owner's own messages in groups and channels, plus all messages in one-to-one chats and chats with bots [20].

The researchers looked at Telegram Desktop's HTML export and did not examine the JSON export format or the export features of Telegram's other apps [19]. They tested on their own accounts and test groups, and their writeup does not claim the flaw has been used against real users [21]. Their advice is to update to 7.0.1 or later, or 6.9.4 or later on the beta channel, and then re-export any chat that was exported to HTML before the fix [22]. Opening an old export with JavaScript turned off breaks the third precondition, and the script does not run [18][25].

What to watch

  • A CVE identifier or an NVD entry with a vendor score, which would give defenders something to weigh against the researchers' 8.2.
  • Whether the JSON export path, or the export features in Telegram's mobile and web apps, write the same field unescaped.
  • Any report of the injected script turning up in an export outside the researchers' own test accounts.
Loading claim ledger
Loading source directory links
Loading share composer
Loading topic controls
Loading related stories