<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<!-- generated by https://github.com/cabo/kramdown-rfc version 1.7.17 (Ruby 3.3.3) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-barnes-mls-replace-00" category="info" consensus="true" submissionType="IETF" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.22.0 -->
  <front>
    <title abbrev="MLS Replace">The MLS Replace Proposal</title>
    <seriesInfo name="Internet-Draft" value="draft-barnes-mls-replace-00"/>
    <author fullname="Richard Barnes">
      <organization>Cisco</organization>
      <address>
        <email>rlb@ipv.sx</email>
      </address>
    </author>
    <author fullname="Marta Mularczyk">
      <organization>Amazon</organization>
      <address>
        <email>mulmarta@amazon.com</email>
      </address>
    </author>
    <author fullname="Mark Xue">
      <organization>Germ Network, Inc.</organization>
      <address>
        <email>mark@germ.network</email>
      </address>
    </author>
    <date year="2024" month="July" day="08"/>
    <area>Security</area>
    <workgroup>Messaging Layer Security</workgroup>
    <keyword>messaging layer security</keyword>
    <keyword>end-to-end encryption</keyword>
    <keyword>post-compromise security</keyword>
    <abstract>
      <?line 45?>

<t>Post-compromise security is one of the core security guarantees provided by the
Messaging Layer Security (MLS) protocol.  MLS provides post-compromise security
for a member when the member's leaf node in the MLS ratchet tree is updated,
either by that member sending a Commit message, or by an Update proposal from
that member being committed.  Unfortunately, Update proposals can only be
committed in the epoch in which they are sent, leading to missed opportunities
for post-compromise security.  This document defines a Replace proposal that
allows the fresh leaf node in an Update proposal to be applied in a future
epoch, thus enabling post-compromise security for the affected member even if
their Update proposal is received too late to be committed.</t>
    </abstract>
    <note removeInRFC="true">
      <name>About This Document</name>
      <t>
        The latest revision of this draft can be found at <eref target="https://bifurcation.github.io/mls-replace/draft-barnes-mls-replace.html"/>.
        Status information for this document may be found at <eref target="https://datatracker.ietf.org/doc/draft-barnes-mls-replace/"/>.
      </t>
      <t>
        Discussion of this document takes place on the
        Messaging Layer Security Working Group mailing list (<eref target="mailto:mls@ietf.org"/>),
        which is archived at <eref target="https://mailarchive.ietf.org/arch/browse/mls/"/>.
        Subscribe at <eref target="https://www.ietf.org/mailman/listinfo/mls/"/>.
      </t>
      <t>Source for this draft and an issue tracker can be found at
        <eref target="https://github.com/bifurcation/mls-replace"/>.</t>
    </note>
  </front>
  <middle>
    <?line 58?>

<section anchor="introduction">
      <name>Introduction</name>
      <t>Post-compromise security (PCS) is one of the core security guarantees provided
by the Messaging Layer Security (MLS) protocol.  MLS provides PCS for a member
when the member's leaf node in the MLS ratchet tree is updated, either by that
member sending a Commit message, or by an Update proposal from that member being
committed.  Unfortunately, Update proposals can only be committed in the epoch
in which they are sent, for example, if an Update proposal is sent within an
epoch, but not received by the sender of the Commit that ends the epoch until
after the Commit is sent.</t>
      <t>This situation leads to missed opportunities for PCS.  Unlike Add and Remove
proposals, which can be "re-originated" by a committer if they are received
late, Update proposals can only be sent by the member whose leaf the Update
would replace.  If an Update proposal is not included in the Commit ending its
epoch, then it can only be discarded.  The PCS benefits of the Update are lost.</t>
      <t>In this document, we define a Replace proposal that fills this gap.  Where the
Update proposal specifies only the new leaf node, a Replace specifies both the
leaf node and the leaf index where the leaf node should be inserted.  This
allows any member of the group to take a leaf node value that another member has
previously produced (e.g., in an Update proposal), and propose that the latter
member's representation in the group be replaced with the new leaf node value.</t>
      <t>The new flexibility that this mechanism introduces can be abused by a malicious
member to undermine PCS.  The malicious member can issue a Replace proposal that
rolls back a victim member's leaf to an earlier, compromised version.  To
prevent these attacks, we also introduce a <tt>leaf_node_epoch</tt> extension that
allows a LeafNode to be annotated with the epoch in which it was created.  This
allows the recipients of a Replace proposal to ensure that the new leaf node was
created after the one it replaces.</t>
    </section>
    <section anchor="conventions-and-definitions">
      <name>Conventions and Definitions</name>
      <t>The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL
NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>",
"<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted as
described in BCP 14 <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only when, they
appear in all capitals, as shown here.</t>
      <?line -18?>

<t>This document makes use of the terms defined in <xref target="RFC9420"/>.</t>
    </section>
    <section anchor="leaf-node-epoch-extension">
      <name>Leaf Node Epoch Extension</name>
      <t>The <tt>leaf_node_epoch</tt> extension simply describes the epoch in which a LeafNode
was created:</t>
      <figure anchor="fig-leaf-node-epoch">
        <name>Content of the `leaf_node_epoch` extension</name>
        <artwork><![CDATA[
uint64 leaf_node_epoch;
]]></artwork>
      </figure>
    </section>
    <section anchor="replace-proposal">
      <name>Replace Proposal</name>
      <t>A Replace proposal replaces the indicated LeafNode in the tree with the value
provided in the proposal.</t>
      <figure anchor="fig-replace">
        <name>Content of the Replace proposal</name>
        <artwork><![CDATA[
struct {
    uint32 replaced;
    LeafNode leaf_node;
} Replace;
]]></artwork>
      </figure>
      <t>A Replace proposal is invalid if the LeafNode is invalid for an Update proposal
for the indicated leaf according to <xref section="7.3" sectionFormat="of" target="RFC9420"/>, or if the leaf
node at index <tt>removed</tt> is blank.  In addition, the recipient of a Replace
proposal <bcp14>MUST</bcp14> verify the following properties of the new LeafNode and reject
the proposal as invalid if any one of them is false:</t>
      <ul spacing="normal">
        <li>
          <t>The <tt>leaf_node_source</tt> field of the LeafNode is be set to <tt>update</tt>.</t>
        </li>
        <li>
          <t>The <tt>extensions</tt> field of the LeafNode contains an extension of type
<tt>leaf_node_epoch</tt>.</t>
        </li>
        <li>
          <t>The epoch value in the <tt>leaf_node_epoch</tt> field is less than or equal to the
current epoch.</t>
        </li>
        <li>
          <t>If the current LeafNode contains a <tt>leaf_node_epoch</tt> extension, then the
epoch value in the <tt>leaf_node_epoch</tt> field is greater than or equal to the
value in the current LeafNode.</t>
        </li>
      </ul>
      <t>A member of the group applies a Replace proposal by taking the following steps:</t>
      <ul spacing="normal">
        <li>
          <t>Replace the LeafNode at index <tt>removed</tt> with the one contained in the Replace
proposal.</t>
        </li>
        <li>
          <t>Blank the intermediate nodes along the path from the leaf at index <tt>removed</tt>
to the root.</t>
        </li>
      </ul>
      <t>This mechanism is similar to the Update proposal described in <xref section="12.1.2" sectionFormat="of" target="RFC9420"/>, with the difference that the index of the leaf to be replaced is
made explicit, as opposed to being indicated by the <tt>sender</tt> field of the
enclosing FramedContent object.  A Replace proposal with the <tt>to_replace</tt> field
set to the same index as the <tt>sender</tt> field has the same effect as an Update
sending the same leaf node value.</t>
      <t>A Commit that contains a Replace proposal <bcp14>MUST</bcp14> contain an update path.</t>
    </section>
    <section anchor="proposal-list-validation">
      <name>Proposal List Validation</name>
      <t>This specification extends the validation rules in <xref section="12.2" sectionFormat="of" target="RFC9420"/>
with the following additional rules governing proposal lists that include
Replace proposals.  For a regular, i.e., not external, Commit, the list is
invalid if any of the following occurs (in addition to the rules in <xref section="12.2" sectionFormat="of" target="RFC9420"/>):</t>
      <ul spacing="normal">
        <li>
          <t>It contains a Replace proposal replacing the committer's leaf node.</t>
        </li>
        <li>
          <t>It contains multiple Replace proposals for the same leaf node.</t>
        </li>
        <li>
          <t>It contains both a Replace proposal and an Update or Remove proposal for the
same leaf node.</t>
        </li>
      </ul>
      <t>Replace proposals are not allowed in external Commits.</t>
    </section>
    <section anchor="security-considerations">
      <name>Security Considerations</name>
      <t>As noted above, the Replace proposal introduces a risk that a malicioius group
member could roll back a victim group member to an earlier, compromised
LeafNode.  Thus while the Replace and <tt>leaf_node_epoch</tt> mechanisms are
notionally separate, using Replace proposals requires the use of the
<tt>leaf_node_epoch</tt> extension in order to avoid roll-back attacks.  In a group
where Replace proposals might be used, the application <bcp14>SHOULD</bcp14> ensure that all
leaf nodes contain a <tt>leaf_node_epoch</tt> extension.</t>
      <ul empty="true">
        <li>
          <t><strong>TODO:</strong> It might be worth defining a flag that says <tt>leaf_node_epoch</tt> is
required.  That would be a good use of an MLS flags extension, along the lines
of [I-D.ietf-tls-tlsflags] (real reference not working right now), which would
be a nice thing to include in the MLS extensions document.</t>
        </li>
      </ul>
      <ul empty="true">
        <li>
          <t><strong>TODO:</strong> Unlike an Update proposal, a Replace proposal is not signed by the
current (i.e. prior to update) key of the replaced member. This allows a
malicious insider Bob to issue a Replace proposal for Alice that changes her
signature key to one chosen by Bob (assuming Bob can obtain a valid
credential for that key). This is not possible with Update proposals.
It may be good to prevent this scenario e.g. by having a leaf node extension
<tt>signature_under_previous_key</tt> required for Replace proposals that change
the signature key.</t>
        </li>
      </ul>
    </section>
    <section anchor="iana-considerations">
      <name>IANA Considerations</name>
      <ul empty="true">
        <li>
          <t><strong>TODO:</strong> Register new proposal type Replace</t>
        </li>
      </ul>
      <ul empty="true">
        <li>
          <t><strong>TODO:</strong> Register new extension type leaf_node_epoch</t>
        </li>
      </ul>
    </section>
  </middle>
  <back>
    <references anchor="sec-normative-references">
      <name>Normative References</name>
      <reference anchor="RFC2119">
        <front>
          <title>Key words for use in RFCs to Indicate Requirement Levels</title>
          <author fullname="S. Bradner" initials="S." surname="Bradner"/>
          <date month="March" year="1997"/>
          <abstract>
            <t>In many standards track documents several words are used to signify the requirements in the specification. These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t>
          </abstract>
        </front>
        <seriesInfo name="BCP" value="14"/>
        <seriesInfo name="RFC" value="2119"/>
        <seriesInfo name="DOI" value="10.17487/RFC2119"/>
      </reference>
      <reference anchor="RFC8174">
        <front>
          <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
          <author fullname="B. Leiba" initials="B." surname="Leiba"/>
          <date month="May" year="2017"/>
          <abstract>
            <t>RFC 2119 specifies common key words that may be used in protocol specifications. This document aims to reduce the ambiguity by clarifying that only UPPERCASE usage of the key words have the defined special meanings.</t>
          </abstract>
        </front>
        <seriesInfo name="BCP" value="14"/>
        <seriesInfo name="RFC" value="8174"/>
        <seriesInfo name="DOI" value="10.17487/RFC8174"/>
      </reference>
      <reference anchor="RFC9420">
        <front>
          <title>The Messaging Layer Security (MLS) Protocol</title>
          <author fullname="R. Barnes" initials="R." surname="Barnes"/>
          <author fullname="B. Beurdouche" initials="B." surname="Beurdouche"/>
          <author fullname="R. Robert" initials="R." surname="Robert"/>
          <author fullname="J. Millican" initials="J." surname="Millican"/>
          <author fullname="E. Omara" initials="E." surname="Omara"/>
          <author fullname="K. Cohn-Gordon" initials="K." surname="Cohn-Gordon"/>
          <date month="July" year="2023"/>
          <abstract>
            <t>Messaging applications are increasingly making use of end-to-end security mechanisms to ensure that messages are only accessible to the communicating endpoints, and not to any servers involved in delivering messages. Establishing keys to provide such protections is challenging for group chat settings, in which more than two clients need to agree on a key but may not be online at the same time. In this document, we specify a key establishment protocol that provides efficient asynchronous group key establishment with forward secrecy (FS) and post-compromise security (PCS) for groups in size ranging from two to thousands.</t>
          </abstract>
        </front>
        <seriesInfo name="RFC" value="9420"/>
        <seriesInfo name="DOI" value="10.17487/RFC9420"/>
      </reference>
    </references>
    <?line 221?>

<section numbered="false" anchor="acknowledgments">
      <name>Acknowledgments</name>
      <t>TODO acknowledge.</t>
    </section>
  </back>
  <!-- ##markdown-source:
H4sIAAAAAAAAA6Va23IbNxJ9x1dgmYeVXSQVOa5NoiSOZdlOVCVbXlnebCqV
sjAzIIloZsAFMJIZl/Mt+y37ZXu6gbnw5lSSh1jkDNDobvQ5fWEmk4kIJpT6
WI6uFlq+OH8tL/WyVLmWr5xdWq/KkVBZ5vQtlgxej0Sugp5btzqWpp5ZIQqb
16qCpMKpWZhkytXaT6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