Telegram App Store Secret-Chat Messages in Plain-Text Database
Telegram's Secret Chat messages were stored in plain text in the app's process memory and in a local database file, so an attacker who gained access to the device could read supposedly encrypted conversations. The attacker could also recover messages that had been deleted from the app.
Published on blog.zimperium.com
EDIT: The following post was not on a rooted or jailbroken device . In order to access the plain-text secret-chat database containing the messages, we used our implementation of CVE-2014-3153.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Telegram is an encrypted instant messaging app for iOS and Android. Its "Secret Chat" feature is a one-on-one chat in which, according to Telegram's own description quoted in the report, "all messages are encrypted with a key held only by the chat's participants. By definition, it follows that no third parties can access the decrypted content without access to one of the devices."
The researcher, Jon Paterson of Zimperium Mobile Security Labs, set out to test that claim from the device side rather than the wire. The question was twofold: if an attacker gains remote control of a phone, how easily can they retrieve the content of end-to-end encrypted Secret Chats, and how are those chats stored on the device itself? The work was conducted against the Android app on Android OS version 4.4.2, and the report notes that Telegram had more than 50 million users at the time.
The report opens by quoting a CryptoFail blog post that is critical of Telegram's crypto contest, in which the author argues the contest is useless because neither users nor developers learn anything from it, and that Telegram will still be able to point at it and say no one has won, so the software must be secure. The researcher's stated intention was to see whether encrypted messages could be read without being on the wire.
Setup
- Target: Telegram for Android, running on Android OS version 4.4.2.
- Precondition for the attack chain: remote compromise of the device. The researcher simulated an attack originating from an app or client-side vulnerability that gains permissions by running a kernel exploit, CVE-2014-3153 (also known as TowelRoot).
- The report explicitly corrects an earlier version of itself: the post was not on a rooted or jailbroken device. Access to the plain-text secret-chat database was obtained using the researcher's implementation of CVE-2014-3153, and claims that the device was rooted or jailbroken are described as incorrect and misleading.
- The researcher refers to what happened "on either phone" when the self-destruct timer failed.
- The researcher created secret messages inside the Android app with the intention of finding them unencrypted somewhere.
Finding it
The researcher's starting assumption was that Secret-Chat messages would be encrypted in memory, or at least in the local database. The report frames the alternative as naive: taking a screenshot as the attacker triggers a notification to both users, so one might assume security and privacy are a top priority for Telegram, but believing an attacker will settle for a screenshot instead of taking complete control of the device is optimistic.

Rather than looking for the more common mistakes expected in non-security-oriented programs, the researcher gave Telegram the benefit of the doubt and simulated the full attack chain: a client-side or app vulnerability leading to code execution, then a kernel exploit to elevate privileges and gain control of the device. The report lists two example techniques for attacking a mobile device remotely, noting that this would be even easier for nation-state actors with more resources, time and money:
- Client-side vulnerability: Chrome exploit, Pwn2Own Autumn 2013.
- Kernel exploit: CVE-2014-3153 (TowelRoot).
With the Secret Chat feature showing its lock icon, the researcher dumped the process memory of Telegram and searched for strings containing the words sent and received in the conversation.


The words Woof, Text, Shlookido, Cookiedo, Tambalul and NotSoEncryptedInMemory were found in the process memory, not encrypted. Any attacker with access to the device could read the Secret-Chat messages in clear text from Telegram's memory. That discovery prompted the researcher to look for an easier route to the same content, and one was found.
Exploitation
Step 1: Dump process memory and search for message strings
After obtaining code execution through the simulated client-side and kernel exploit chain, the researcher dumped the memory of the Telegram process and searched it for the words that had been sent and received in the Secret Chat. The strings appeared in clear text, including the deliberately named NotSoEncryptedInMemory. This shows that the decrypted message content lives in the app's address space while the chat is in use.
Step 2: Inspect the app's private data directory
Using the shell obtained from running CVE-2014-3153, the researcher looked at the app's files under:
/data/data/org.telegram.messenger/
In the app's "files" folder there was a file called Cache4.db.

Step 3: Examine Cache4.db
The researcher noticed table names such as "enc_chats" and "enc_tasks_v2", assumed "enc" stood for encrypted, fetched the file and examined it. The file contained the secret messages in plain text.

Step 4: Test the Delete function and self-destruct timer
The report then turns to Telegram's "Delete" messages function, with the aim of retrieving sensitive information previously deleted by the user, either from memory or from Cache4.db.
- Memory: the researcher set options, then Set Self Destruct to 5 seconds, and expected the message to be deleted, but nothing happened on either phone. The report treats this as looking like a bug rather than a security issue.
- The message was then deleted by clicking options, then delete.
- An inspection of Cache4.db showed no signs of the conversation. A deleted message might be more interesting to an attacker, so the researcher then looked at memory again and was able to find the original conversation after it had been deleted from the memory.
Root cause
The report's conclusion is that Telegram focused purely on data in transit and did not protect data at rest on the mobile device itself. Concretely, two storage locations held Secret-Chat content in clear text:
- Process memory: decrypted message strings were present in the Telegram process and could be recovered by searching a memory dump.
- The local database Cache4.db: despite table names prefixed with "enc", the file contained the secret messages in plain text.
The report says Telegram's communication was supposed to be encrypted and that it was broken as well. The report adds that Telegram's communication was supposed to be encrypted, and that it was broken as well. Existing defences did not help because the attack did not attempt to break the protocol in the middle: it bypassed the encryption by simulating an active attack on the device, after which the app's own memory and files were available to the attacker.
Impact
An attacker who gains remote control of a device, for example through a client-side vulnerability plus a kernel exploit to elevate privileges, can read Secret-Chat messages in clear text from the Telegram process memory and from Cache4.db. The report stresses that this affects users who believe the app provides the security to chat freely, and that Telegram's encryption does not protect users any better than any other page or app that uses SSL against this class of attacker. Deleted messages can also be recovered from memory after deletion, although in the researcher's test the database no longer contained the conversation.
The conditions matter: the attack requires compromise of the device first. The report's point is that once that compromise happens, the Secret Chat's end-to-end encryption provides no further protection for the message content stored on the phone.
Fix
The report does not describe a vendor fix. It records that Telegram's security team was contacted several times and had not responded for over 30 days, and the vulnerability was made public on 23/2/2015 under Zimperium's 30-day zero-day policy. The disclosure timeline given is:
- 17/1/2015: vulnerability found.
- 18/1/2015: vulnerability responsibly disclosed as ZVD-2015-0100, ZVD-2015-0101 and ZVD-2015-0102 according to the 30-day zero-day policy; no response from vendor.
- 23/1/2015: asked vendor to comment; no response.
- 3/2/2015: asked vendor to comment; no response.
- 6/2/2015: asked vendor to comment; no response.
- 23/2/2015: vulnerability made public.
The researcher's recommendation is that Telegram, or any messaging software, should encrypt chat strings in memory as well as encrypting the conversations in the Cache4.db file. The report also recommends adding protection to the mobile device that can detect device-level cyberattacks, and notes that Zimperium's Mobile Threat Defence system detected the entire attack chain used to obtain the content of the secret messages.
Variants to test
- Memory scraping of other "secure" messengers: dump the process memory while a supposedly end-to-end encrypted conversation is open and search for the plain-text strings you sent. A positive result is the message text appearing verbatim in the dump.
- Local database inspection: list the app's private files directory and open any SQLite database found there, paying attention to tables whose names suggest encryption. A positive result is message content readable in clear text despite an "enc"-style prefix.
- A positive result is recovering the deleted content from either location.
- Self-destruct timers: set a short self-destruct interval and observe whether the message is actually removed on both devices. A positive result is the message persisting beyond the configured interval.
- Screenshot notifications: take a screenshot of a Secret Chat and check whether both participants are notified, to establish what protection the app does implement before testing what it does not.

Jon Paterson (@shellprompt) published this research through Zimperium Mobile Security Labs; the report credits the Zimperium Mobile Threat Defence system with detecting the full attack chain.
What happened, in plain words
Telegram is a messaging app for phones, similar in everyday use to WhatsApp or iMessage. It has a special mode called Secret Chat, which is meant for conversations that only the two people involved can read. Telegram's own description, quoted in the report, says that in a Secret Chat "all messages are encrypted with a key held only by the chat's participants. By definition, it follows that no third parties can access the decrypted content without access to one of the devices."
Encryption is the process of scrambling a message so that anyone who intercepts it sees only nonsense, and only the intended recipient can unscramble it. "End-to-end" means the scrambling happens on the sender's phone and the unscrambling on the receiver's phone, so the company running the service is not supposed to be able to read the messages either.
Jon Paterson, a researcher at Zimperium Mobile Security Labs, wanted to test that promise from a different angle. Instead of trying to break the encryption while messages travel across the internet (the "wire"), he asked two questions:
- If an attacker manages to take remote control of a phone, how easily can they get at the content of Secret Chats?
- How are those chats stored on the phone itself?
The work was done against the Android version of the app, on Android OS version 4.4.2. The report notes that Telegram had more than 50 million users at the time.
The report opens by quoting a CryptoFail blog post that is critical of a cryptography contest Telegram had announced. In that contest, Telegram challenged people to recover an email address that had been encrypted with its app, for a prize of $200,000 USD worth of Bitcoin. The quoted author argues the contest is useless: neither users nor developers learn anything from it, and Telegram can still point at it and say that nobody won, so the software must be secure. The researcher's own stated intention was to see whether encrypted messages could be read without being on the wire at all.
The setup
Before the steps, here is what the researcher started with:
- Target: Telegram for Android, running on Android OS version 4.4.2.
- Precondition: the attacker must first get remote control of the phone. The researcher simulated this with an attack that starts from an app or client-side weakness and then uses a kernel exploit, CVE-2014-3153, also known as TowelRoot.
- A correction about rooting: the report explicitly corrects an earlier version of itself. The post was not on a rooted or jailbroken device. Access to the plain-text secret-chat database was obtained using the researcher's implementation of CVE-2014-3153, and claims that the device was rooted or jailbroken are described as incorrect and misleading.
- **The researcher refers to what happened "on either phone" when the self-destruct timer failed.
- The goal: create secret messages inside the Android app and then try to find them unencrypted somewhere on the device.
A few of those terms deserve a plain explanation, because the rest of the article depends on them.
What is a kernel exploit? Every phone has an operating system, and at the core of the operating system sits the kernel. The kernel is the part that decides which app is allowed to touch which file, which memory, and which hardware. Apps normally run with limited permissions, like a hotel guest who can open their own room but not the staff-only floors. A kernel exploit is a bug in the kernel that lets an attacker break those rules and gain the highest level of control over the device. CVE-2014-3153 is the identifier of one such bug; "CVE" is a public catalogue number given to known security flaws so people can refer to them unambiguously. TowelRoot is the name under which this particular exploit became widely known.
What is rooting or jailbreaking? On Android, "rooting" means deliberately removing the operating system's restrictions so the owner has full administrator access; on iOS the equivalent is called "jailbreaking". It is something a user chooses to do. The report is careful to say the test phone was not in that state: the attacker got in through the exploit instead. This distinction matters because a critic could otherwise dismiss the finding by saying "well, the phone was already unlocked anyway".
What is process memory? When an app runs, the operating system gives it a region of the phone's working memory (RAM) to keep everything it is currently doing: the screen it is drawing, the messages it is showing, the keys it is using. This region is called the process memory of that app. It is temporary and disappears when the app closes, unlike a file saved on storage. Dumping process memory means making a copy of that whole region so it can be searched offline, like photocopying every sheet of paper on someone's desk at once instead of reading them one by one.
Finding it
The researcher's starting assumption was that Secret-Chat messages would be encrypted in memory, or at least in the local database on the phone. The report frames the opposite expectation as naive. Taking a screenshot as the attacker triggers a notification to both users, so one might assume security and privacy are a top priority for Telegram. But believing an attacker will settle for a screenshot instead of taking complete control of the device is optimistic.

Rather than hunting for the more common mistakes you would expect in a program that was never designed with security in mind, the researcher gave Telegram the benefit of the doubt and simulated the full attack chain: a client-side or app weakness leading to code execution, then a kernel exploit to raise privileges and take control of the device. The report lists two example techniques for attacking a phone remotely, and notes that this would be even easier for nation-state actors with more resources, time and money:
- Client-side vulnerability: Chrome exploit, Pwn2Own Autumn 2013.
- Kernel exploit: CVE-2014-3153 (TowelRoot).
A client-side vulnerability is a flaw in software running on the victim's own device, such as the browser. "Client-side" simply means "on the user's side" as opposed to "on the server's side". Pwn2Own is a well-known annual contest where security researchers demonstrate such attacks against browsers and phones; the report cites a Chrome exploit from its Autumn 2013 edition as an example of how an attacker gets a first foothold.
With the Secret Chat feature showing its lock icon, the researcher dumped the process memory of Telegram and searched it for the words that had been sent and received in the conversation.


The words Woof, Text, Shlookido, Cookiedo, Tambalul and NotSoEncryptedInMemory were found in the process memory, not encrypted. The last one was deliberately named to make the point. Any attacker with access to the device could read the Secret-Chat messages in clear text straight out of Telegram's memory. That discovery prompted the researcher to look for an even easier route to the same content, and one was found.
Exploitation
Step 1: Dump process memory and search for message strings
After obtaining code execution through the simulated client-side and kernel exploit chain, the researcher dumped the memory of the Telegram process and searched it for the words that had been sent and received in the Secret Chat. The strings appeared in clear text, including the deliberately named NotSoEncryptedInMemory. This shows that the decrypted message content lives in the app's address space while the chat is in use.
"Address space" is just the technical name for the slice of memory that belongs to one running program. The point is simple: while you are reading a Secret Chat, the readable text of that chat is sitting in the phone's memory, and anyone who can look at that memory can read it too.
Step 2: Inspect the app's private data directory
Using the shell obtained from running CVE-2014-3153, the researcher looked at the app's files under:
/data/data/org.telegram.messenger/
Line by line, this is a single path on the Android file system, not a command:
/data/data/is the area on an Android phone where each installed app keeps its private files. Normally one app cannot read another app's folder there; that separation is one of the main protections Android offers.org.telegram.messengeris the unique package name of the Telegram app, the same kind of identifier you see in an app store link. So the full path means "the private folder that belongs to Telegram".
A shell is a text interface where you type commands and the computer executes them. Getting a shell on a phone means the attacker can type commands into the device as if sitting at it, which is why the kernel exploit mattered: it is what turned a remote compromise into command-level access to the app's private folder.
In the app's "files" folder there was a file called Cache4.db.

Step 3: Examine Cache4.db
The researcher noticed table names such as "enc_chats" and "enc_tasks_v2", assumed "enc" stood for encrypted, fetched the file and examined it. The file contained the secret messages in plain text.
A .db file is a database file, the kind of file that stores information in tables with rows and columns, much like a spreadsheet. Many apps use a small database engine called SQLite for this. The table names are labels inside that file. Seeing a prefix like "enc" (short for encrypted) suggests the contents were meant to be scrambled, but a name is only a name: it does not guarantee anything about what is actually stored inside. That is exactly what the researcher checked, and the messages were readable as ordinary text.

Step 4: Test the Delete function and self-destruct timer
The report then turns to Telegram's "Delete" messages function, with the aim of retrieving sensitive information that a user had previously deleted, either from memory or from Cache4.db. This is an interesting goal for an attacker because people delete precisely the messages they most want kept private.
- Memory: the researcher set options, then Set Self Destruct to 5 seconds, and expected the message to be deleted, but nothing happened on either phone. The report treats this as looking like a bug rather than a security issue.
- The message was then deleted by clicking options, then delete.
- An inspection of Cache4.db showed no signs of the conversation. A deleted message might be more interesting to an attacker, so the researcher then looked at memory again and was able to find the original conversation after it had been deleted from the memory.
A self-destruct timer is a setting that is supposed to make a message vanish automatically after a set number of seconds, like a note that burns itself. Here the timer did not remove the message on either phone, which the report describes as looking like a bug. Deleting the message manually did remove it from the database file, but the text was still recoverable from memory afterwards. In plain terms: deleting a message from the screen and from the database does not necessarily erase it from the phone's working memory.
Root cause
The report's conclusion is that Telegram focused purely on data in transit and did not protect data at rest on the phone itself. Those two phrases are worth separating:
- Data in transit is information while it is travelling, for example between two phones over the internet. Protecting it means encrypting the connection.
- Data at rest is information while it is stored, for example in a file or in memory on the device. Protecting it means encrypting the stored copy.
Concretely, two storage locations held Secret-Chat content in clear text:
- Process memory: decrypted message strings were present in the Telegram process and could be recovered by searching a memory dump.
- The local database Cache4.db: despite table names prefixed with "enc", the file contained the secret messages in plain text.
The report says Telegram's communication was supposed to be encrypted and that it was broken as well. The report adds that Telegram's communication was supposed to be encrypted, and that it was broken as well. Existing defences did not help because the attack did not attempt to break the protocol in the middle: it bypassed the encryption by simulating an active attack on the device, after which the app's own memory and files were available to the attacker.
An active attack means the attacker does something, such as controlling a machine the victim talks to, rather than only listening quietly. A passive attack is just eavesdropping. Telegram's newer contest, quoted in the report, said that "this time contestants can not only monitor traffic, but also act as the Telegram server and use active attacks, which vastly increases their capabilities." The researcher's approach follows the same logic: why fight the lock on the front door when you can get inside the house and read the letters on the desk?
Impact
An attacker who gains remote control of a device, for example through a client-side vulnerability plus a kernel exploit to raise privileges, can read Secret-Chat messages in clear text from the Telegram process memory and from Cache4.db. The report stresses that this affects users who believe the app provides the security to chat freely, and that Telegram's encryption does not protect users any better than any other page or app that uses SSL against this class of attacker. Deleted messages can also be recovered from memory after deletion, although in the researcher's test the database no longer contained the conversation.
SSL (now usually called TLS) is the technology that puts the padlock in your browser's address bar and encrypts traffic between your computer and a website. The comparison in the report is blunt: against an attacker who already controls the device, Telegram's protection is no stronger than the padlock on any ordinary website.
The conditions matter. The attack requires compromise of the device first. The report's point is that once that compromise happens, the Secret Chat's end-to-end encryption provides no further protection for the message content stored on the phone.
Fix
The report does not describe a vendor fix. It records that Telegram's security team was contacted several times and had not responded for over 30 days, and the vulnerability was made public on 23/2/2015 under Zimperium's 30-day zero-day policy. A zero-day is a flaw the vendor has not yet fixed, and a disclosure policy is a company's published rule for how long it waits before telling the public. The timeline given is:
- 17/1/2015: vulnerability found.
- 18/1/2015: vulnerability responsibly disclosed as ZVD-2015-0100, ZVD-2015-0101 and ZVD-2015-0102 according to the 30-day zero-day policy; no response from vendor.
- 23/1/2015: asked vendor to comment; no response.
- 3/2/2015: asked vendor to comment; no response.
- 6/2/2015: asked vendor to comment; no response.
- 23/2/2015: vulnerability made public.
"Responsibly disclosed" means telling the maker first and giving them time to fix it before the details become public. The identifiers ZVD-2015-0100, ZVD-2015-0101 and ZVD-2015-0102 are Zimperium's own reference numbers for the three issues it reported.
The researcher's recommendation is that Telegram, or any messaging software, should encrypt chat strings in memory as well as encrypting the conversations in the Cache4.db file. The report also recommends adding protection to the phone that can detect device-level cyberattacks, and notes that Zimperium's Mobile Threat Defence system detected the entire attack chain used to obtain the content of the secret messages.
Variants to test
If you want to check other apps for the same pattern, these are the tests the report's findings suggest. Each one is described as a positive result, meaning the sign that the problem is present.
- Memory scraping of other "secure" messengers: dump the process memory while a supposedly end-to-end encrypted conversation is open and search for the plain-text strings you sent. A positive result is the message text appearing verbatim in the dump.
- Local database inspection: list the app's private files directory and open any SQLite database found there, paying attention to tables whose names suggest encryption. A positive result is message content readable in clear text despite an "enc"-style prefix.
- A positive result is recovering the deleted content from either location.
- Self-destruct timers: set a short self-destruct interval and observe whether the message is actually removed on both devices. A positive result is the message persisting beyond the configured interval.
- Screenshot notifications: take a screenshot of a Secret Chat and check whether both participants are notified, to establish what protection the app does implement before testing what it does not.

Jon Paterson (@shellprompt) published this research through Zimperium Mobile Security Labs; the report credits the Zimperium Mobile Threat Defence system with detecting the full attack chain.
Glossary
- Active attack: an attack where the attacker does something, such as controlling a server the victim talks to, rather than only listening.
- Address space: the region of memory that belongs to one running program.
- Android: the operating system made by Google that runs on most non-Apple phones.
- App (application): a program installed on a phone, such as Telegram.
- Bitcoin: a digital currency; the report quotes a prize value in it.
- Cache4.db: the database file found in Telegram's private files folder, which held the secret messages in plain text.
- Client-side: on the user's own device, as opposed to on a server.
- Client-side vulnerability: a flaw in software running on the victim's device, such as a browser.
- Code execution: getting a program to run instructions of the attacker's choosing on the target device.
- CVE: a public catalogue number for a known security flaw, such as CVE-2014-3153.
- Database: a file that stores information in tables of rows and columns, often managed by SQLite on phones.
- Data at rest: information while it is stored, for example in a file or in memory.
- Data in transit: information while it is travelling, for example between two phones over the internet.
- Delete function: the app feature that removes a message from the conversation.
- Disclosure policy: a company's published rule for how long it waits before making a vulnerability public.
- Dump (memory dump): a copy of a program's memory taken so it can be searched or examined.
- Encryption: scrambling information so that only the intended recipient can unscramble it.
- End-to-end encryption: encryption performed on the sender's device and reversed on the receiver's device, so the service provider cannot read the content.
- Exploit: a technique that takes advantage of a bug to do something the software was not meant to allow.
- Files folder: the directory inside an app's private area where it keeps its own files.
- iOS: the operating system made by Apple that runs on iPhones.
- Jailbreaking: deliberately removing an iPhone's restrictions to gain full administrator access.
- Kernel: the core part of an operating system that controls access to memory, files and hardware.
- Kernel exploit: a bug in the kernel that lets an attacker gain the highest level of control over a device.
- Memory (RAM): the phone's working memory, where a running app keeps what it is currently doing.
- Nation-state actor: an attacker backed by a government, with large resources, time and money.
- Package name: the unique identifier of an Android app, such as org.telegram.messenger.
- Passive attack: an attack that only listens to traffic without altering anything.
- Plain text (clear text): information stored or sent without any encryption, readable by anyone who can see it.
- Process: a running instance of a program.
- Process memory: the memory belonging to one running program.
- Protocol: the agreed set of rules two programs follow to communicate.
- Pwn2Own: an annual security contest where researchers demonstrate attacks against browsers and phones.
- Remote control (remote compromise): taking over a device over a network without physical access to it.
- Rooting: deliberately removing an Android phone's restrictions to gain full administrator access.
- Secret Chat: Telegram's one-on-one chat mode in which messages are meant to be encrypted with a key held only by the two participants.
- Self-destruct timer: a setting meant to make a message vanish automatically after a set time.
- Shell: a text interface where you type commands and the computer executes them.
- Screenshot: a picture of what is currently on the screen.
- SQLite: a small database engine commonly used by phone apps.
- SSL (TLS): the technology that encrypts traffic between a device and a website and shows the padlock in a browser.
- String: a piece of text, such as a word or a sentence, as handled by a program.
- Table: a named grid of rows and columns inside a database.
- TowelRoot: the public name of the CVE-2014-3153 kernel exploit.
- Vendor: the company that makes the software, here Telegram.
- Wire: informal term for the network path between two devices.
- Zero-day: a vulnerability the vendor has not yet fixed.