From 5b05e0194f43f99463b7f71e5c269481d983c893 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Sat, 13 Jul 2024 11:18:32 -0400 Subject: [PATCH] Add additional known obscured subjects from k-9/thunderbird-android. These additional subjects were extracted from the thunderbird-android source (which is inherited from k-9). The extraction was done with: ``` git clone https://github.com/thunderbird/thunderbird-android/ cd thunderbird-android/legacy/ui/legacy/src/main/res grep string\ name=\"encrypted_subject values-*/strings.xml | cut -f2 -d'>' | cut -f1 -d'<' | sort -u | sed -e 's/^/ "/' -e 's/$/",/' ``` (i did need to clean up one line's escaping to pass the linter's expectations) See also https://github.com/thunderbird/thunderbird-android/issues/8011 --- chatmaild/src/chatmaild/filtermail.py | 60 ++++++++++++++++++- .../src/chatmaild/tests/test_filtermail.py | 3 +- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/chatmaild/src/chatmaild/filtermail.py b/chatmaild/src/chatmaild/filtermail.py index 39b51226..8f23c595 100644 --- a/chatmaild/src/chatmaild/filtermail.py +++ b/chatmaild/src/chatmaild/filtermail.py @@ -14,6 +14,64 @@ from aiosmtpd.controller import Controller from .config import read_config +"""Generated from deltachat, draft-ietf-lamps-header-protection, and +encrypted_subject localizations in +https://github.com/thunderbird/thunderbird-android/ +""" +common_encrypted_subjects = { + "...", + "[...]", + "암호화된 메시지", + "Ĉifrita mesaĝo", + "Courriel chiffré", + "Dulrituð skilaboð", + "Encrypted Message", + "Fersifere berjocht", + "Kemennadenn enrineget", + "Krüptitud kiri", + "Krypterat meddelande", + "Krypteret besked", + "Kryptert melding", + "Mensagem criptografada", + "Mensagem encriptada", + "Mensaje cifrado", + "Mensaxe cifrada", + "Mesaj Criptat", + "Mesazh i Fshehtëzuar", + "Messaggio criptato", + "Messaghju cifratu", + "Missatge encriptat", + "Neges wedi'i Hamgryptio", + "Pesan terenkripsi", + "Salattu viesti", + "Şifreli İleti", + "Šifrēta ziņa", + "Šifrirana poruka", + "Šifrirano sporočilo", + "Šifruotas laiškas", + "Tin nhắn được mã hóa", + "Titkosított üzenet", + "Verschlüsselte Nachricht", + "Versleuteld bericht", + "Zašifrovaná zpráva", + "Zaszyfrowana wiadomość", + "Zifratu mezua", + "Κρυπτογραφημένο μήνυμα", + "Зашифроване повідомлення", + "Зашифрованное сообщение", + "Зашыфраваны ліст", + "Криптирано съобщение", + "Шифрована порука", + "დაშიფრული წერილი", + "הודעה מוצפנת", + "پیام رمزنگاری‌شده", + "رسالة مشفّرة", + "എൻക്രിപ്റ്റുചെയ്‌ത സന്ദേശം", + "加密邮件", + "已加密的訊息", + "暗号化されたメッセージ", +} + def check_openpgp_payload(payload: bytes): """Checks the OpenPGP payload. @@ -111,7 +169,7 @@ def check_encrypted(message): """ if not message.is_multipart(): return False - if message.get("subject") not in {"...", "[...]"}: + if message.get("subject") not in common_encrypted_subjects: return False if message.get_content_type() != "multipart/encrypted": return False diff --git a/chatmaild/src/chatmaild/tests/test_filtermail.py b/chatmaild/src/chatmaild/tests/test_filtermail.py index 049e09fb..74c28bb2 100644 --- a/chatmaild/src/chatmaild/tests/test_filtermail.py +++ b/chatmaild/src/chatmaild/tests/test_filtermail.py @@ -4,6 +4,7 @@ from chatmaild.filtermail import ( SendRateLimiter, check_armored_payload, check_encrypted, + common_encrypted_subjects, ) @@ -54,7 +55,7 @@ def test_filtermail_no_encryption_detection(maildata): def test_filtermail_encryption_detection(maildata): - for subject in ("...", "[...]"): + for subject in common_encrypted_subjects: msg = maildata( "encrypted.eml", from_addr="1@example.org",