The official Telegram Desktop client is reportedly affected by multiple vulnerabilities in the built-in QuickJS widget sandbox, potentially allowing Remote Code Execution (RCE), arbitrary memory access, and application crashes.
The reporter, @chatcoder, demonstrated successful exploitation using an unmodified official Telegram Desktop client, the standard Bot API, and a standard binary, without modified clients.
The reported vulnerabilities include:
Use-After-Return via await using (RCE): Improper closure handling after stack frame termination in QuickJS allows memory pointer manipulation, address-space disclosure or acquisition, and arbitrary code execution. The reporter demonstrated launching calc.exe. Current Telegram builds are reportedly affected.
UAF in Generator Prologue (RCE): A generator lifecycle vulnerability (quickjs-ng #1910). Manipulating arguments and garbage collection allows memory redirection and arbitrary byte read/write primitives, enabling calculator execution through WinExec.
Constant Pool Errors (DoS / Memory Corruption): An unchecked index return during out-of-memory (OOM) conditions can overwrite heap metadata, resulting in STATUS_HEAP_CORRUPTION and application crashes.
The reporter also indicates that the issues affect QuickJS/quickjs-ng branches and remain partially unpatched in several pinned versions.
Steps to reproduce
Use the official Telegram Desktop client (version 7.4.2 or later).
Use the built-in widget sandbox mechanism based on QuickJS.
Trigger the reported QuickJS vulnerabilities through the standard Bot API:
Exploit the Use-After-Return condition using await using.
Exploit the UAF in Generator Prologue by manipulating arguments and garbage collection.
Trigger Constant Pool Errors under out-of-memory conditions.
Observe the resulting memory corruption, arbitrary memory access, code execution, or application crash.
Current result
The reported vulnerabilities allow:
Remote Code Execution, including launching calc.exe through the demonstrated exploitation techniques.
Arbitrary byte read/write primitives through memory corruption.
Heap metadata corruption and application crashes with STATUS_HEAP_CORRUPTION.
Expected result
The QuickJS widget sandbox should safely isolate widget execution and prevent memory corruption, arbitrary memory access, and execution of arbitrary code within the Telegram Desktop process.
Device info
Telegram Desktop 7.4.2 x64, Linux Pc, Windows 11 x64