<?xml version="1.0" encoding="UTF-8"?>
  <?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
  <!-- generated by https://github.com/cabo/kramdown-rfc version 1.7.19 (Ruby 3.0.2) -->


<!DOCTYPE rfc  [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">

]>


<rfc ipr="trust200902" docName="draft-gondwana-dkim2-modification-alegbra-00" category="std" consensus="true" submissionType="IETF" obsoletes="4686" tocInclude="true" sortRefs="true" symRefs="true">
  <front>
    <title abbrev="Email Modification Algebra">A method for describing changes made to an email</title>

    <author initials="B." surname="Gondwana" fullname="Bron Gondwana">
      <organization>Fastmail Pty Ltd</organization>
      <address>
        <postal>
          <street>Level 2, 114 William Street</street>
          <code>3000</code>
          <country>Australia</country>
        </postal>
        <phone>+61 457 416 436</phone>
        <email>brong@fastmailteam.com</email>
      </address>
    </author>

    <date year="2024" month="November" day="03"/>

    
    
    <keyword>Internet-Draft</keyword>

    <abstract>


<?line 30?>

<t>This memo describes a method for describing the changes made to an email
during common email modifications, for example those caused by mailing lists
and forwarders.</t>

<t>While this is general enough to be used for any changes, it is anticipated that
this method will normally be used for removing added data rather than large
complex changes.</t>



    </abstract>



  </front>

  <middle>


<?line 40?>

<section anchor="background-and-motivations"><name>Background and motivations</name>

<t>Currently, when an email is sent with a DKIM signature, the message can go
through multiple forwarders and still be authenticated, however if a single
change is made to a header which is covered by the signature, or to the body,
then the signature no longer validates - and it's impossible for the receiver
to know what was changed, or even if the entire messages content was replaced
by an attacker.</t>

<t>By producing a way to describe changes, the recipient can examine the sections
which were changed and determine whether the change was malicious.  Because
each step signs its own changes in DKIM2, this also allows the recipient to
identify exactly which intermediary introduced the malicious change, and
adjust their reputation accordingly.</t>

</section>
<section anchor="difference-format-headers"><name>Difference format - headers</name>

<t>For headers, the format is to completely replace all headers with
a particular name.  For example if you replace the subject and
from address in an email, then you need to include the complete
old headers for each of those:</t>

<t>Header: "DKIM2-Diff-Header:"</t>

<texttable>
      <ttcol align='left'>Command</ttcol>
      <ttcol align='left'>Input</ttcol>
      <c>i</c>
      <c>DKIM2 matching header number</c>
      <c>b</c>
      <c>replace headers with base64 octet value</c>
      <c>t</c>
      <c>replace headers with raw text characters value</c>
</texttable>

<t>Example for a message which has had Subject and From replaced,
and Reply-To added.</t>

<figure><artwork><![CDATA[
From: brong@fastmailteam.com.dmarc.fail
To: dkim2@lists.ietf.org
Reply-To: dkim2@lists.ietf.org
DKIM2-Diff-Header: i=3;
                   t=Subject,A replacement for DKIM;
                   b=From,YnJvbmdAZmFzdG1haWx0ZWFtLmNvbQo=;
                   t=Reply-To
]]></artwork></figure>

</section>
<section anchor="difference-format-body"><name>Difference format - body</name>

<t>This difference format for the body is inspired by <xref target="RFC3284"/>
(The VCDIFF Generic Differencing and Compression Data Format).</t>

<t>Since the transport for the differences is a 7-bit mime header,
this format has been made simple and human readable.  It is a
simple program describing ranges of data to copy from the output
to recreate the input.</t>

<t>Header: "DKIM2-Diff-Body:"</t>

<texttable>
      <ttcol align='left'>Command</ttcol>
      <ttcol align='left'>Input</ttcol>
      <c>i</c>
      <c>DKIM2 matching header number</c>
      <c>c</c>
      <c>copy offset-length from new-message body</c>
      <c>b</c>
      <c>insert octets from base64 encoded value</c>
      <c>t</c>
      <c>insert raw text of value</c>
</texttable>

<t>Example:</t>

<figure><artwork><![CDATA[
DKIM2-Diff-Body: i=2;
                 c=0-19452;
                 c=20312-150
]]></artwork></figure>

<t>Example - appended to some base64 content; so we need to add back the
last few characters (and the mime trailer)</t>

<figure><artwork><![CDATA[
DKIM2-Diff-Body: i=2;
                 c=0-19452;
                 t=aX==;
                 c=20312-150
]]></artwork></figure>

<t>Example - a URL was substituted in the content of the body (complex, but still
easily doable!)</t>

<figure><artwork><![CDATA[
DKIM2-Diff-Body: i=3;
                 c=0-3542;
                 b=PGEgaHJlZj0iaHR0cHM6Ly93d3cuZXhhb
                   XBsZS5jb20iPkV4YW1wbGU8L2E+Cg==;
                 c=3623-84743
]]></artwork></figure>

<t>The decision whether to use 'b' or 't' is up to the system creating the diff, however
't' has a limited set of characters that are safe to use in headers.</t>

</section>
<section anchor="signature-coverage"><name>Signature coverage.</name>

<t>Each DKIM2 signature implicitly covers all DKIM2-Diff-Body and DKIM2-Diff-Header headers
with an <spanx style="verb">i=N</spanx> value for the same and lower N values as the <spanx style="verb">i=</spanx> on the DKIM2 header.</t>

</section>
<section anchor="iterative-application"><name>Iterative application</name>

<t>To get back to the original message and confirm that it was unchanged, it is necessary
to apply this algorith iteratively.</t>

<t>For example if you receive a message at <spanx style="verb">i=7</spanx> for which there is a modification to the
headers at <spanx style="verb">i=5</spanx> and a modification to both headers and body at <spanx style="verb">i=3</spanx>, to recreate the
original message you would first apply the header changes from <spanx style="verb">i=5</spanx>, then apply the
header and body changes for <spanx style="verb">i=3</spanx>.  If this doesn't create a message which validates
with the initial i=1 signature, then some hop has corrupted the message, and you can
check every single DKIM signature in reverse to find the first one where the message
no longer validates.</t>

</section>
<section anchor="security"><name>Security</name>

<t>TBA</t>

</section>
<section anchor="iana-considerations"><name>IANA Considerations</name>

<t>TBA</t>

</section>


  </middle>

  <back>




    <references title='Informative References' anchor="sec-informative-references">



<reference anchor="RFC3284">
  <front>
    <title>The VCDIFF Generic Differencing and Compression Data Format</title>
    <author fullname="D. Korn" initials="D." surname="Korn"/>
    <author fullname="J. MacDonald" initials="J." surname="MacDonald"/>
    <author fullname="J. Mogul" initials="J." surname="Mogul"/>
    <author fullname="K. Vo" initials="K." surname="Vo"/>
    <date month="June" year="2002"/>
    <abstract>
      <t>This memo describes VCDIFF, a general, efficient and portable data format suitable for encoding compressed and/or differencing data so that they can be easily transported among computers. [STANDARDS-TRACK]</t>
    </abstract>
  </front>
  <seriesInfo name="RFC" value="3284"/>
  <seriesInfo name="DOI" value="10.17487/RFC3284"/>
</reference>




    </references>



<?line 162?>

<section anchor="changes-from-earlier-versions"><name>Changes from Earlier Versions</name>

<t>[[This section to be removed by RFC Editor]]</t>

</section>


  </back>

<!-- ##markdown-source:
H4sIAAAAAAAAA61Ya3PbthL9jl+Bm/vB6VTUyJLsJOp4pnZiJel1MmniJmke
cw2SoISYBDgAaIW3j99+zwIkpfiRT9V0piaJBXbP7tk9SJIkzCtfygU/5pX0
a5PzwlieS5dZlSq94tla6JV0vBK55N5wobmshCqZSFMrrxb8lJ74C5OrQmXC
K6P5cbmSqRUsN5kWFTbPrSh8sjI63wgtkvxSVdOk2jFJRClXMEkmE+aatFLO
4e15W8P4+en5kmGZXBnbLrjzOWvqHM9uwUzqTCnpTz4/fHjIVG0X3NvG+elk
8mgyZZey3RibYxftpdXSJ0/IF+a80Pl/RWk0TmilY7Va8I/eZCPujPVWFg5/
tRX98Zkx0QAbu2A8YRw/pXHgyZg/7SIKL2OoJxYAfPPe2NWCL4XzAahXvuVn
CIG+OJwj/YKfyStZ8umI7+/P+TtVlkpU/E34GNZlJsfOswnAiY+N9gTFMeK0
AqvD63odgrn34+E+nx884PP9Qz6fHd4LH0POFjyFd6ufi84ZL0U1zkzFmDa2
QiKu5IIpXWwfyPT18vFs+nC+YIwlScJFSodmnrHztUJdyMr09YIyEXeUkV/L
u0spb2woNVNVpnvHd6sDqaDt5FdR1SVM18ZhN9E4mfO05bSe7EvlvGPIK63e
CJtL68aMvVurYARn8d9KagnMuNSmWa3JjVTysBMdIXTbuzniypOB0F5lqka9
5dhEeOZj2CHKDZLFA3hl2X6zkwUuV+SVyHO8Qr0KbgVgsLSL5qWwK8kQMiL6
2p85jhBXKs9Lydi/+YnILlcW+c45xVUZpCVCwtjjxlqpfdmO+GYt9QAnOe3w
Ac75NRLy5D/PX3CnVlr4xspRSEUlnRMrAlHzlUFINqBRNaVXBPEWwHCu8xQn
wiMeSAKE4BjxtdmgdC1XBc5xiBZex1DIiSHPfC3xp4WbKlvTl8zAKiaPvNlx
DsjBgl6mJm9HjI77dg3g5qDtCvtdofZDI+BJcFP5PeS4qg26RxqjCLZWZh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