Telegram & how unwanted people can adb your device (since 3 feb 2023)
Source Reddit Cybersecurity
Discussion
A configuration in the Telegram Android app allows app data to be backed up via Android's backup system, potentially exposing sensitive tokens and settings. This backup capability, controlled by the android:allowBackup attribute, can be exploited via adb backup commands if the device is accessible. The exposed data includes authentication tokens and user preferences, which could allow an attacker to hijack sessions without needing email or SMS verification if two-factor authentication is not enabled. The app stores salted and hashed PINs, which could be brute-forced offline. This issue was observed in the app's manifest as of February 3, 2023, and relates to the use of Android's BackupAgentHelper mechanism.
r/cybersecurity (opens in a new tab)u/nikitasius0 points0 comments
Hi folks!
Here's 4 feb 2014: https://github.com/DrKLO/Telegram/blame/9aeb8be8938e6083376142a782166a15edf46743/TMessagesProj/src/main/AndroidManifest.xml#L58
Old days, probably default config.
Here's 28 feb 2014: https://github.com/DrKLO/Telegram/blame/2628a581478f1a30197ed0fc37165b17a3c97c98/TMessagesProj/src/main/AndroidManifest.xml#L87
true -> false 24 days after. Guess to fix it.
Here is today https://github.com/DrKLO/Telegram/blame/2628a581478f1a30197ed0fc37165b17a3c97c98/TMessagesProj/src/main/AndroidManifest.xml#L99-L101 - 3 feb 2023 it was modified.
What does this mean?
android:allowBackup="true" allows the app's data to be included in Android's backup system (cloud backup via Google and, under the right conditions via adb backup or bmgr backupnow), need fullBackupOnly afaik to work w/o agent.
Here is the agent:
BackupAgent extends BackupAgentHelper :
https://github.com/DrKLO/Telegram/blob/b7561f0c641b521df0000bda2704664d792d6a1a/TMessagesProj/src/main/java/org/telegram/messenger/BackupAgent.java#L13-L14 (12.9.2 release - latest)
There are:
saved_tokens, saved_tokens_login, prefs
Here are your tokens, your settings (shared prefs).
So, via adb get tokens & settings (shared prefs)
- launch your session on another device w/o email/sms using tokens straight to chats if you don't have 2fa
- hashcat your pin (prefs contain salt & sha256 of salt'pin'salt) to get your pin and try it this device (if you "forgot it) or "elsewhere (pins and password must be unique per device/service!) https://github.com/DrKLO/Telegram/blob/b7561f0c641b521df0000bda2704664d792d6a1a/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java#L849-L852 (12.9.2 release - latest)
Sure, they could dump your chats anyway or run your account anywhere cause it have a "central server". But enabling such "backups" for me it's kinda yelling "it's not us it's they/them/🐷".
Android backup refs:
- https://developer.android.com/identity/data/autobackup#EnablingAutoBackup
- https://developer.android.com/identity/data/autobackup#ImplementingBackupAgent
Folks you're welcome to comment 🍻
Links cited in the discussion
- https://github.com/DrKLO/Telegram/blame/9aeb8be8938e6083376142a782166a15edf46743/TMessagesProj/src/main/AndroidManifest.xml#L58
- https://github.com/DrKLO/Telegram/blame/2628a581478f1a30197ed0fc37165b17a3c97c98/TMessagesProj/src/main/AndroidManifest.xml#L87
- https://github.com/DrKLO/Telegram/blame/2628a581478f1a30197ed0fc37165b17a3c97c98/TMessagesProj/src/main/AndroidManifest.xml#L99-L101
- https://github.com/DrKLO/Telegram/blob/b7561f0c641b521df0000bda2704664d792d6a1a/TMessagesProj/src/main/java/org/telegram/messenger/BackupAgent.java#L13-L14
- https://github.com/DrKLO/Telegram/blob/b7561f0c641b521df0000bda2704664d792d6a1a/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java#L849-L852
- https://developer.android.com/identity/data/autobackup#EnablingAutoBackup
- https://developer.android.com/identity/data/autobackup#ImplementingBackupAgent
References
- github.com/DrKLO/Telegram/blame/9aeb8be8938e6083376142a782166a15edf46743/TMessagesProj/src/main/AndroidManifest.xml (opens in a new tab)
- reddit.com/r/cybersecurity/comments/1vme3ah/telegram_how_unwanted_people_can_adb_your_device/ (opens in a new tab)
- github.com/DrKLO/Telegram/blame/2628a581478f1a30197ed0fc37165b17a3c97c98/TMessagesProj/src/main/AndroidManifest.xml (opens in a new tab)
- github.com/DrKLO/Telegram/blame/2628a581478f1a30197ed0fc37165b17a3c97c98/TMessagesProj/src/main/AndroidManifest.xml (opens in a new tab)
- github.com/DrKLO/Telegram/blob/b7561f0c641b521df0000bda2704664d792d6a1a/TMessagesProj/src/main/java/org/telegram/messenger/BackupAgent.java (opens in a new tab)
- github.com/DrKLO/Telegram/blob/b7561f0c641b521df0000bda2704664d792d6a1a/TMessagesProj/src/main/java/org/telegram/messenger/SharedConfig.java (opens in a new tab)
- developer.android.com/identity/data/autobackup (opens in a new tab)
- developer.android.com/identity/data/autobackup (opens in a new tab)