Telegram Desktop Bug Deletes 800 GB of User Data Due to Spelling Checker Path Error

A Telegram Desktop update introduced a critical flaw that caused the application to recursively delete user folders containing up to 800 GB of data on Windows systems. The root cause traced back to an incorrect path construction for the custom dictionary file used by the lib_spellcheck library when Windows native spell checking was enabled. Due to a misplaced return statement in the code, the working directory path remained empty, leading Qt to interpret the path as the root-level C:\custom folder. The application then invoked QDir::removeRecursively on this directory, removing all accessible files while skipping locked ones. The bug affected releases 7.1.0 and 7.1.1 for approximately 66 hours before being fixed in version 7.1.2. Researchers used Process Monitor to confirm Telegram.exe was directly responsible for the deletion attempts. The incident highlights risks of combining recursive deletion functions with unvalidated path inputs in widely used applications.

HabrTranslated from Russian

Read at source

A Windows user reported losing nearly 800 GB of data after updating Telegram Desktop. Files began disappearing from the custom directory C:\custom immediately after launching the messenger, while folders themselves remained intact.

Tracing the culprit

By monitoring application launches, the user isolated the issue to Telegram Desktop. Reinstalling the application to a separate location and creating test files confirmed that Telegram continued to target the original folder. Testing across versions showed the problem appeared after updating from 6.9.4 to 7.1.1.

Process Monitor investigation

Running Process Monitor revealed that Telegram.exe opened C:\custom, enumerated its contents, requested delete permissions, and attempted recursive removal. Stack traces pointed directly inside the Telegram binary, ruling out malware.

Root cause in spell checking

The deletion originated from the lib_spellcheck library. Telegram stores user-added words in a file named custom. In version 7.1.0, changes to support Windows native spell checking introduced a logic error: the path to the internal dictionary was set after an early return when the system spell checker was active.

With an empty working directory path, the code constructed the string /custom. Qt resolved this to C:\custom on the root of the current drive. The subsequent check if (QFileInfo(path).isDir()) { QDir(path).removeRecursively(); } then deleted the entire folder instead of a small internal dictionary directory.

Fix and impact

Developers corrected the issue in commit 9c316281 by setting the path before the return and added an empty-path guard in lib_spellcheck. The faulty versions remained available for roughly 66 hours. The bug was confirmed only on Windows with native spell checking enabled.

The case demonstrates how individually reasonable decisions—storing custom words, cleaning damaged directories, and using recursive deletion—combined into severe data loss when path validation was absent.

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