From f39a5284ee208a8ba8194b4317b77114e38d73d9 Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Mon, 1 Aug 2016 18:51:08 +0200 Subject: [feat] Remove senders X-Leap-* headers if the email came with them We use the X-Leap-Signature and X-Leap-Encryption to signal the signature and encryption status of emails. An attacker could add this headers and trick bitmask to believe that the email was signed and/or encrypted. Now we remove this headers from the original email if they are present before adding ours. - Resolves: #7429 --- changes/next-changelog.rst | 1 + src/leap/mail/incoming/service.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/changes/next-changelog.rst b/changes/next-changelog.rst index 21b1010..2731460 100644 --- a/changes/next-changelog.rst +++ b/changes/next-changelog.rst @@ -11,6 +11,7 @@ I've added a new category `Misc` so we can track doc/style/packaging stuff. Features ~~~~~~~~ - `#8031 `_: Adapt to the new KeyManager API without key types. +- `#7429 `_: Remove senders X-Leap-* headers if the email came with them. - `#1234 `_: Description of the new feature corresponding with issue #1234. - New feature without related issue number. diff --git a/src/leap/mail/incoming/service.py b/src/leap/mail/incoming/service.py index fea3ecb..da63dd8 100644 --- a/src/leap/mail/incoming/service.py +++ b/src/leap/mail/incoming/service.py @@ -459,6 +459,7 @@ class IncomingMail(Service): signkey.fingerprint) return decrmsg.as_string() + self._remove_headers(msg) if msg.get_content_type() == MULTIPART_ENCRYPTED: d = self._decrypt_multipart_encrypted_msg( msg, encoding, senderAddress) @@ -480,6 +481,10 @@ class IncomingMail(Service): msg.add_header(self.LEAP_ENCRYPTION_HEADER, self.LEAP_ENCRYPTION_DECRYPTED) + def _remove_headers(self, msg): + del msg[self.LEAP_ENCRYPTION_HEADER] + del msg[self.LEAP_SIGNATURE_HEADER] + def _decrypt_multipart_encrypted_msg(self, msg, encoding, senderAddress): """ Decrypt a message with content-type 'multipart/encrypted'. -- cgit v1.2.3