From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id A24056DE141E for ; Fri, 31 May 2019 00:49:17 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.194 X-Spam-Level: X-Spam-Status: No, score=-0.194 tagged_above=-999 required=5 tests=[AWL=0.007, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id U-hZniYl_D1J for ; Fri, 31 May 2019 00:49:16 -0700 (PDT) Received: from che.mayfirst.org (che.mayfirst.org [162.247.75.118]) by arlo.cworth.org (Postfix) with ESMTPS id D006C6DE140C for ; Fri, 31 May 2019 00:49:14 -0700 (PDT) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/simple; d=fifthhorseman.net; i=@fifthhorseman.net; q=dns/txt; s=2019; t=1559288954; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : from; bh=dJz/A+2Qgi2jtbhS6gN7T/OIZ3qACO3H9qLB1Gzrbsc=; b=gyQDdVyIu3REyf6pm06hyGKGPvc8LTYU0s75nLgkOIX0+rHkgvUJEDly D2Mx5HwFKyBw0MkDo0U1ne0ULKdBDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fifthhorseman.net; i=@fifthhorseman.net; q=dns/txt; s=2019rsa; t=1559288953; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : from; bh=dJz/A+2Qgi2jtbhS6gN7T/OIZ3qACO3H9qLB1Gzrbsc=; b=VXRl6GMJTRzS2YdsiUFmny7y1n6v9l2d/4BfRFnY849ysIBF3IguNA7f JxJ2BxXM3EqyyPtmNzoYJedJ9ZL20gIZOfxRp3zJ3iLZCLh8xwJpp5zIUi 25FCbQ6RliAnXb4/Q6kPQiBIvnoxSx8JyJbeI5FWzuNzm2ArcjmAM4aIzd 10rq1IxjkpaB1fVmun8WFyOJyE4T72BM50uvQzYrs78jqDiKc7oTYSSsIy nvT1nr2cRV5qYMuZurxOt/72KziTbxycJ3Noky7F8K+PKQDw/1+RqvpPfi qIq8SpMWUEt5Koa+8HOZJAcXaPUOB+g92whHlz+BMNAt2377mjr5Gw== Received: from fifthhorseman.net (unknown [38.109.115.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by che.mayfirst.org (Postfix) with ESMTPSA id C25F1F99F for ; Fri, 31 May 2019 03:49:13 -0400 (EDT) Received: by fifthhorseman.net (Postfix, from userid 1000) id 31C151FF65; Fri, 31 May 2019 03:49:10 -0400 (EDT) From: Daniel Kahn Gillmor To: Notmuch Mail Subject: [PATCH v3 1/4] test: add test for "Mixed-Up Mime" message mangling Date: Fri, 31 May 2019 03:48:39 -0400 Message-Id: <20190531074842.16789-2-dkg@fifthhorseman.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190531074842.16789-1-dkg@fifthhorseman.net> References: <20190531074842.16789-1-dkg@fifthhorseman.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 May 2019 07:49:17 -0000 Some MTAs mangle e-mail messages in transit in ways that are repairable. Microsoft Exchange (in particular, the version running today on Office365's mailservers) appears to mangle multipart/encrypted messages in a way that makes them undecryptable by the recipient. I've documented this in section 4.1 "Mixed-up encryption" of draft -00 of https://tools.ietf.org/html/draft-dkg-openpgp-pgpmime-message-mangling Fortunately, it's possible to repair such a message, and notmuch can do that so that a user who receives an encrypted message from a user of office365.com can still decrypt the message. Enigmail already knows about this particular kind of mangling. It describes it as "broken PGP email format probably caused by an old Exchange server", and it tries to repair by directly changing the message held by the user. if this kind of repair goes wrong, the repair process can cause data loss (https://sourceforge.net/p/enigmail/bugs/987/, yikes). The tests introduced here are currently broken. In subsequent patches, i'll introduce a non-destructive form of repair for notmuch so that notmuch users can read mail that has been mangled in this way, and the tests will succeed. Signed-off-by: Daniel Kahn Gillmor --- test/T351-pgpmime-mangling.sh | 36 ++++++++++++++++++++++++++++++ test/corpora/mangling/mixed-up.eml | 33 +++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100755 test/T351-pgpmime-mangling.sh create mode 100644 test/corpora/mangling/mixed-up.eml diff --git a/test/T351-pgpmime-mangling.sh b/test/T351-pgpmime-mangling.sh new file mode 100755 index 00000000..f65b8a24 --- /dev/null +++ b/test/T351-pgpmime-mangling.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +test_description='PGP/MIME message mangling' +. $(dirname "$0")/test-lib.sh || exit 1 + +add_gnupg_home +add_email_corpus mangling + +bodytext='["body"][0]["content"][1]["content"]="The password is \"abcd1234!\", please do not tell anyone.\n"' + +test_begin_subtest "show 'Mixed-Up' mangled PGP/MIME message correctly" +test_subtest_known_broken +output=$(notmuch show --format=json --decrypt=true id:mixed-up@mangling.notmuchmail.org) +test_json_nodes <<<"$output" \ + 'body:[0][0][0]'"$bodytext" + +test_begin_subtest "reply to 'Mixed-Up' mangled PGP/MIME message correctly" +test_subtest_known_broken +output=$(notmuch reply --format=json --decrypt=true id:mixed-up@mangling.notmuchmail.org) +test_json_nodes <<<"$output" \ + 'body:["original"]'"$bodytext" + +test_begin_subtest "repaired 'Mixed-up' messages can be found with index.repaired=mixedup" +test_subtest_known_broken +output=$(notmuch search --output=messages property:index.repaired=mixedup) +test_expect_equal "$output" id:mixed-up@mangling.notmuchmail.org + +test_begin_subtest "index cleartext of 'Mixed-Up' mangled PGP/MIME message" +test_expect_success 'notmuch reindex --decrypt=true id:mixed-up@mangling.notmuchmail.org' + +test_begin_subtest "search cleartext of 'Mixed-Up' mangled PGP/MIME message" +test_subtest_known_broken +output=$(notmuch search --output=messages body:password) +test_expect_equal "$output" id:mixed-up@mangling.notmuchmail.org + +test_done diff --git a/test/corpora/mangling/mixed-up.eml b/test/corpora/mangling/mixed-up.eml new file mode 100644 index 00000000..a09f6191 --- /dev/null +++ b/test/corpora/mangling/mixed-up.eml @@ -0,0 +1,33 @@ +From: test_suite@notmuchmail.org +To: test_suite@notmuchmail.org +Subject: Here is the password +Date: Sat, 01 Jan 2000 12:00:00 +0000 +Message-ID: +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="=-=-=" + +--=-=-= +Content-Type: text/plain; charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + +--=-=-= +Content-Type: application/pgp-encrypted +Content-Transfer-Encoding: base64 + +VmVyc2lvbjogMQ0K + +--=-=-= +Content-Type: application/octet-stream +Content-Transfer-Encoding: base64 + +LS0tLS1CRUdJTiBQR1AgTUVTU0FHRS0tLS0tDQoNCmhJd0R4RTAyM3ExVXF4WUJCQUNwNzBlN0tQ +eTlPWWFoZUlya0x6bWhxMWxScW15NTFhTDFqQkwwSy9xTjdyZksNCkJaRUcxY1I4amVMalRGZFBL +UExWS0pJODByN0ZnS0kweXd2V3ZsNlIxYUUxVHk1Qm5WWFQ5WHpDckVIN2ZxQ2wNClNLSzgyRXZv +bFhUb2hBWkhVcmg2SzY2ZVFRVFRJQUMxbjdCMEE4aEVyemtnYU00K3NlTjNMbHZlelQ2VExOS00N +CkFUcHFzRWJNMk1WckdndzBiM29Vc0dHQVBFdDJNbWpORVlzcmlLbnF3dDZkSkRaYy8vWHloamdN +UWF5aUQ4ZGENCk4xZ1Qzb3FndS9nS0NwQlpEWXpIZjlPdFZpMlVubEZEV3k2cnJNWkxqV0RuSXY0 +dmU5UG4vcW9sd0hWanpkSjENClpmak5DNXQwejNYQURLR3JqTjl3dXRyNHFtN1NUVzFySEFYSFA2 +OFRRVHhJMHFnSktqUFhOS1dFdzZnPQ0KPXBKRzQNCi0tLS0tRU5EIFBHUCBNRVNTQUdFLS0tLS0N +Cg== +--=-=-=-- -- 2.20.1