<?xml version="1.0" encoding="utf-8"?>
<!-- name="GENERATOR" content="github.com/mmarkdown/mmark Mmark Markdown Processor - mmark.miek.nl" -->
<rfc version="3" ipr="trust200902" docName="draft-gondwana-email-mailpath-01" submissionType="IETF" category="std" xml:lang="en" xmlns:xi="http://www.w3.org/2001/XInclude" indexInclude="true" consensus="true">

<front>
<title abbrev="Email Mailpath">Email extension for specifying the next hop path for delivery</title><seriesInfo value="draft-gondwana-email-mailpath-01" stream="IETF" status="standard" name="Internet-Draft"></seriesInfo>
<author role="editor" initials="B." surname="Gondwana" fullname="Bron Gondwana"><organization>Fastmail</organization><address><postal><street>Level 2, 114 William St</street>
<city>Melbourne</city>
<code>VIC 3000</code>
<country>Australia</country>
</postal><email>brong@fastmailteam.com</email>
<uri>https://www.fastmail.com</uri>
</address></author><date year="2022" month="October" day="11"></date>
<area>Applications</area>
<workgroup>DMARC</workgroup>
<keyword>email</keyword>
<keyword>dmarc</keyword>
<keyword>mail headers</keyword>

<abstract>
<t>Much work has been put into adding authentication methods (DKIM, ARC),
source verification (SPF) and policy support (DMARC) to email flows,
however all these specifications have focused on looking backwards
through email flow only, and only add new headers to messages, causing
them all to be susceptible to replay or re-use.</t>
<t>In particular, in early 2022, a type of attack called &quot;DKIM Replay&quot; was
widely seen, where correctly DKIM-signed messages were sent to a different
envelope sender.  The &quot;To&quot; address would not be aligned, but such messages
can also be the result of legitimate mailflow, so these messages were
delivered to end-recipient mailboxes, and caused reputation issues for the
signers of the original message.</t>
</abstract>

</front>

<middle>

<section anchor="introduction"><name>Introduction</name>
<t>NOTE: this is an early draft of an idea.  Expect significant revision.</t>
<t>Goals:</t>

<ol spacing="compact">
<li>to ensure that there's never a message that can be replayed to an
arbitrary server with authentication claims from this protocol.</li>
<li>to be able to build up an ecosystem over time such that if every hop
in a mail flow supports this specification, then additional trust
properties can apply to the mail flow.</li>
</ol>
</section>

<section anchor="conventions-used-in-this-document"><name>Conventions Used In This Document</name>
<t>The key words &quot;MUST&quot;, &quot;MUST NOT&quot;, &quot;REQUIRED&quot;, &quot;SHALL&quot;, &quot;SHALL
NOT&quot;, &quot;SHOULD&quot;, &quot;SHOULD NOT&quot;, &quot;RECOMMENDED&quot;, &quot;NOT RECOMMENDED&quot;,
&quot;MAY&quot;, and &quot;OPTIONAL&quot; in this document are to be interpreted as
described in BCP 14 <xref target="RFC2119"></xref> <xref target="RFC8174"></xref> when, and only when,
they appear in all capitals, as shown here.</t>
</section>

<section anchor="discussion-on-design"><name>Discussion on Design</name>
<t>The presence of Mailpath-Disposition and the checking of Mailpath-Disposition on delivery is sufficient to ensure that mail can't be replayed down additional paths.  I did consider stripping signatures at each stage (and removal entirely when delivering to a host outside the ecosystem of mailpath supporting servers) but it doesn't actually win anything since you can't replay a mailpath message to another domain, since the disposition specifies an explicit path.</t>
<t>At the moment there's no encryption of headers TO the destination.  We could
also add encryption of headers, which might useful - since we're doing a DNS
lookup and the record could return a public key to encrypt things for.</t>
</section>

<section anchor="mailpath-a-chain-of-custody"><name>Mailpath - a chain of custody</name>
<t>The Mailpath process adds information at three different stages of an email's
lifecycle within each site along the email's flow (&quot;site&quot; is maybe a single
server, or maybe a complex system all under the control of a single organisation
and with its own internal trust patterns).</t>
<t>I'll use &quot;site&quot; in the rest of this document, but maybe there's a better term?</t>

<section anchor="email-ingress"><name>Email Ingress</name>
<t>Upon receiving the email, the site adds two headers:</t>
<t>&quot;Mailpath-Authentication-Results&quot; - as with ARC, a list of all the checks which were
done and the results of those checks at the time of Ingress.</t>
<t>&quot;Mailpath-Receipt-Signature&quot; - a signature of the state of the message as it arrived,
covering the &quot;Mailpath-Authentication-Results&quot; and any other headers required to
confirm alignment.</t>
<t>These headers have an i=(number) field, similar to ARC.</t>
</section>

<section anchor="email-modification"><name>Email Modification</name>
<t>If the site performs any modification to the email content or the DKIM signed headers;
e.g. to, from, subject, ... then it adds a &quot;Mailpath-Modification&quot; header specifying
which fields were changed, and why.</t>
<t>TBD: do we want a registry of change reason codes, e.g. &quot;SRS rewrite&quot;, &quot;mailing list&quot;, &quot;virus/malware scan&quot;,
&quot;add disclaimer&quot; - or just plain text?</t>
</section>

<section anchor="email-egress"><name>Email Egress</name>
<t>The site looks up whether the next hop advertises support for Mailpath (see below for how)
and based on this it creates a &quot;Mailpath-Disposition&quot; header specifying where the email is going next.</t>
<t>The site also adds a &quot;Mailpath-Transit-Signature&quot; covering all the Ingress and Modification headers
as well as the regular contents of a DKIM or ARC signature, and also the Mailpath-Disposition header.</t>
<t>E.g.</t>

<artwork>Mailpath-Disposition: protocol=mailbox; to=example@fastmail.com

Mailpath-Authentication-Results: i=2; spf=fail; arc=pass; mailpath=pass
Mailpath-Disposition: i=2; protocol=smtp; mx=example.com; to=fred@example.com;
 mailpath=selector._mailpath.example.com
Mailpath-Transit-Signature: (...)
Mailpath-Action: i=2; changeto=yes; changebody=no; changefrom=srs; ...

Mailpath-Authentication-Results: i=3; spf=fail; arc=pass; mailpath=pass
Mailpath-Disposition: i=3; protocol=smtp; mx=example.com; to=fred@example.com;
 mailpath=none
Mailpath-Transit-Signature: (...)
Mailpath-Action: i=2; changeto=yes; changebody=no; changefrom=srs; ...
</artwork>
</section>
</section>

<section anchor="advertising-support-for-mailpath"><name>Advertising support for Mailpath</name>
<t>A site advertises support for mailpath by creating a record for the hostname in the each MX record.  This might be a TXT
on that hostname, or a sub-name, or indeed a <tt>_srv</tt> record on the site's domain(s).  I'm happy to be guided by advice on this
from those with more DNS structure experience.</t>
<t>The important thing is, having calculated the next hop for a message, the site does a DNS lookup to see if Mailpath is supported.
The record will contain a version, a &quot;yes or no&quot; and - potentially (TBD) a key which can be used to sign information to it.</t>
</section>

<section anchor="delayed-srs"><name>Delayed SRS</name>
<t>An option when deploying this, since we're checking for feature support on the NEXT hop of email flow, is to delay SRS
rewriting (TBD - a reference for <eref target="https://en.wikipedia.org/wiki/Sender_Rewriting_Scheme">SRS</eref>).  Instead of performing
SRS immediately, a site could request that the next hop perform SRS only if exiting the mailpath ecosystem, or otherwise
pass the same request on.</t>
<t>In this case, a flow which consisted entirely of mailpath-aware sites could avoid doing SRS entirely by using the
Mailpath-Modification statements and list of involved sites to know which site to direct the bounces to, with a
additional Mailpath-Bounce headers specifying that they were responsible for forwarding the bounce back the way
it came.</t>
</section>

<section anchor="operational-considerations-cost"><name>Operational considerations - cost</name>
<t>The major additional cost will be borne by mailing list servers which expand one message to lots of copies.  I consider that acceptable and even somewhat desirable, given that most of them already do SRS rewriting.  They can still batch message to the same domain, since this spec (unlike Marc's EVE spec) only specifies the destination MX domain, not the explicit target address(es).  THOUGH - I still see benefits in Marc's one to stop replay to arbitrary mailboxes on the same domain, i.e. spamming all gmail users with a replay of a single message to gmail.</t>
<t>Another way to work around the replay issue is to strip some signature material on delivery to the next hop or to a mailbox, so gmail could deliver a raw message to their users' mailboxes which COULD NOT be replayed over the wire to a gmail MX as if it was signed by the source.  The retention of all the key material on delivery does allow more replay attacks if you only control the destination mailbox and not any of the servers along the way.</t>
</section>

<section anchor="security-considerations"><name>Security considerations</name>
<t>DNS lookups will need the same security checks as MX lookups, in particular
an attacker would could either suppress these DNS lookups (hence: break the
chain of custody and reduce trust in the messages) or fake them (leading
a naive forwarding server to look like a replay rather than a legitimate actor).</t>
<t>Obviously the crypto will need to be checked by people who know more about
this stuff than me!</t>
<t>I'm sure the &quot;delayed SRS&quot; stuff has some gnarly edges I haven't considered.</t>
<t>Maybe the list will come up with other things.</t>
</section>

<section anchor="iana-considerations"><name>IANA considerations</name>
<t>TBD.  We'll need to register the headers at least, and maybe the DNS records</t>
</section>

<section anchor="acknowledgements"><name>Acknowledgements</name>
<t>TBD</t>
</section>

</middle>

<back>
<references><name>Normative References</name>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
</references>

</back>

</rfc>
