XEP-0359: Unique and Stable Stanza IDs

Abstract
This specification describes unique and stable IDs for messages.
Author
Florian Schmaus
Copyright
© 2015 – 2023 XMPP Standards Foundation. SEE LEGAL NOTICES.
Status

Experimental

WARNING: This Standards-Track document is Experimental. Publication as an XMPP Extension Protocol does not imply approval of this proposal by the XMPP Standards Foundation. Implementation of the protocol described herein is encouraged in exploratory implementations, but production systems are advised to carefully consider whether it is appropriate to deploy implementations of this protocol before it advances to a status of Draft.
Type
Standards Track
Version
0.7.0 (2023-02-20)
Document Lifecycle
  1. Experimental
  2. Proposed
  3. Stable
  4. Final

1. Introduction

This XEP introduces unique and stable IDs for messages, which are beneficial in various ways. For example, they can be used together with Message Archive Management (XEP-0313) [1] to uniquely identify a message within an archive. They are also useful in the context of Multi-User Chat (XEP-0045) [2] conferences, as they allow to identify a message reflected by a MUC service back to the originating entity.

2. Use Cases

2.1 Unique stanza IDs

Example 1. The stanza ID extension.
<stanza-id xmlns='urn:xmpp:sid:0'
           id='de305d54-75b4-431b-adb2-eb6b9e546013'
           by='room@muc.example.com'/>

In order to create a <stanza-id/> extension element, the creating XMPP entity generates and sets the value of the 'id' attribute, and puts its own XMPP address as value of the 'by' attribute. The value of the 'id' attribute must be unique and stable, i.e. it MUST NOT change later for some reason within the scope of the 'by' value. Thus the IDs defined in this extension MUST be unique and stable within the scope of the generating XMPP entity. It is RECOMMENDED that the ID generating service uses UUID and the algorithm defined in RFC 4122 [3] to generate the IDs.

2.2 Origin generated stanza IDs

Some use cases require the originating entity, e.g. a client, to generate the stanza ID. In this case, the client MUST use the <origin-id/> element extension element qualified by the 'urn:xmpp:sid:0' namespace. Note that originating entities often want to conceal their XMPP address and therefore the <origin-id/> element has no 'by' attribute.

Example 2. A message stanza with the origin ID extension.
<message xmlns='jabber:client'
         to='room@muc.example.com'
         type='groupchat'>
  <body>Typical body text</body>
  <origin-id xmlns='urn:xmpp:sid:0' id='de305d54-75b4-431b-adb2-eb6b9e546013'/>
</message>

The server or component MAY add a <stanza-id/> element. In that case, it MUST preserve the content of the <origin-id/> element.

Example 3. A message stanza with the stanza ID extension.
<message xmlns='jabber:client'
         to='room@muc.example.com'
         type='groupchat'>
  <body>Typical body text</body>
  <stanza-id xmlns='urn:xmpp:sid:0'
             id='5f3dbc5e-e1d3-4077-a492-693f3769c7ad'
             by='room@muc.example.com'/>
  <origin-id xmlns='urn:xmpp:sid:0' id='de305d54-75b4-431b-adb2-eb6b9e546013'/>
</message>

3. Business Rules

  1. The values of the 'id' attribute SHOULD be unpredictable.
  2. Stanza ID generating entities, which encounter a <stanza-id/> element where the 'by' attribute matches the 'by' attribute they would otherwise set, MUST delete that element even if they are not adding their own stanza ID.
  3. Entities, which are routing stanzas, SHOULD NOT strip any elements qualified by the 'urn:xmpp:sid:0' namespace from message stanzas unless the preceding rule applied to those elements.
  4. Stanzas MUST possess, in the direct child level of the stanza, at most one <stanza-id/> extension element with the same XMPP address as value of the 'by' attribute.
  5. Every <stanza-id/> extension element MUST have the 'id' attribute and the 'by' attribute set.
  6. Every <stanza-id/> and <origin-id/> extension element MUST always possess an 'id' attribute and MUST NOT have any child elements or text content.
  7. The value of the 'by' attribute MUST be the XMPP address of the entity assigning the unique and stable stanza ID. For one-on-one messages the assigning entity is the account. In groupchats the assigning entity is the room. Note that XMPP addresses are normalized as defined in RFC 6122 [4].

4. Referencing Other Stanzas

The <referenced-stanza/> element can be used to reference another stanza. The <referenced-stanza/> element MUST be qualified by the 'urn:xmpp:sid:0' namespace and MUST have an 'id' attribute and SHOULD have a 'by' attribute. The values of the attributes are the values of the referenced stanza's <stanza-id/> element.

Example 4. Example <referenced-stanza/> element
<referenced-stanza xmlns='urn:xmpp:sid:0' id='xep359-stanza-id' by='muc.example.org'/>

5. Discovering Support

An entity that follows the business rules, especially the rule on overriding the ID in elements where the by atttribute matches the 'by' attribute they would otherwise set, SHOULD announce the 'urn:xmpp:sid:0' namespace in its disco features allowing other entities to verify that those business rules are properly enforced.

Example 5. Client sends service discovery request to the room
<iq from='romeo@montague.tld/garden'
    id='somethingrandom'
    to='room@muc.example.com'
    type='get'>
  <query xmlns='http://jabber.org/protocol/disco#info' />
</iq>
Example 6. Servers includes the stanza ID namespace in its features
<iq from='room@muc.example.com'
    to='romeo@montague.tld/garden'
    id='somethingrandom'
    type='result'>
  <query xmlns='http://jabber.org/protocol/disco#info'>
    …
    <feature var='urn:xmpp:sid:0'/>
    …
  </query>
</iq>

6. Security Considerations

The value of origin-id is spoofable and hence SHOULD not be used when referencing other stanzas. The value tuple of 'id' and 'by' of the stanza-id element is unspoofable iff all involved implementations follow the requirements of this specification.

The value of the 'id' attribute should not provide any further information besides the opaque ID itself. Entities observing the value MUST NOT be able to infer any information from it, e.g. the size of the message archive. The value of 'id' MUST be considered a non-secret value.

Before processing the stanza ID of a message and using it for deduplication purposes or for MAM catchup, the receiving entity SHOULD ensure that the stanza ID could not have been faked, by verifying that the entity referenced in the by attribute does annouce the 'urn:xmpp:sid:0' namespace in its disco features.

7. IANA Considerations

This document requires no interaction with the Internet Assigned Numbers Authority (IANA) [5].

8. XMPP Registrar Considerations

8.1 Protocol Namespaces

This specification defines the following XML namespaces:

The XMPP Registrar [6] shall include the foregoing namespaces in its registry of protocol namespaces (see <https://xmpp.org/registrar/namespaces.html>) and in its disco features registry (<https://xmpp.org/registrar/disco-features.html>) as defined in Service Discovery (XEP-0030) [7].

Registration
<var>
  <name>urn:xmpp:sid:0</name>
  <desc>Indicates that an entity adds stanza-ids and follows the business rules described in the XEP</desc>
  <doc>XEP-0359</doc>
</var>

9. XML Schema

<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='urn:xmpp:sid:0'
    elementFormDefault='qualified'>

  <xs:annotation>
    <xs:documentation>
      The protocol documented by this schema is defined in
      XEP-0359: https://www.xmpp.org/extensions/xep-0359.html
    </xs:documentation>
  </xs:annotation>

  <xs:element name='stanza-id'>
    <xs:complexType>
      <xs:attribute name='id' type='xs:string' use='required'/>
      <xs:attribute name='by' type='xs:string' use='required'/>
    </xs:complexType>
  </xs:element>

  <xs:element name='origin-id'>
    <xs:complexType>
      <xs:attribute name='id' type='xs:string' use='required'/>
    </xs:complexType>
  </xs:element>

  <xs:element name='referenced-stanza'>
    <xs:complexType>
      <xs:attribute name='id' type='xs:string' use='required'/>
      <xs:attribute name='by' type='xs:string' use='optional'/>
    </xs:complexType>
  </xs:element>

</xs:schema>

10. Acknowledgements

Thanks to Thijs Alkemade, Georg Lukas, and Maxime Buquet for providing feedback.


Appendices

Appendix A: Document Information

Series
XEP
Number
0359
Publisher
XMPP Standards Foundation
Status
Experimental
Type
Standards Track
Version
0.7.0
Last Updated
2023-02-20
Approving Body
XMPP Council
Dependencies
XMPP Core
Supersedes
None
Superseded By
None
Short Name
stanza-id
Source Control
HTML

This document in other formats: XML  PDF

Appendix B: Author Information

Florian Schmaus
Email
flo@geekplace.eu
JabberID
flo@geekplace.eu

Copyright

This XMPP Extension Protocol is copyright © 1999 – 2024 by the XMPP Standards Foundation (XSF).

Permissions

Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.

Disclaimer of Warranty

## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##

Limitation of Liability

In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.

IPR Conformance

This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at <https://xmpp.org/about/xsf/ipr-policy> or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).

Visual Presentation

The HTML representation (you are looking at) is maintained by the XSF. It is based on the YAML CSS Framework, which is licensed under the terms of the CC-BY-SA 2.0 license.

Appendix D: Relation to XMPP

The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 6120) and XMPP IM (RFC 6121) specifications contributed by the XMPP Standards Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this document has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.

Appendix E: Discussion Venue

The primary venue for discussion of XMPP Extension Protocols is the <standards@xmpp.org> discussion list.

Discussion on other xmpp.org discussion lists might also be appropriate; see <https://xmpp.org/community/> for a complete list.

Errata can be sent to <editor@xmpp.org>.

Appendix F: Requirements Conformance

The following requirements keywords as used in this document are to be interpreted as described in RFC 2119: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".

Appendix G: Notes

1. XEP-0313: Message Archive Management <https://xmpp.org/extensions/xep-0313.html>.

2. XEP-0045: Multi-User Chat <https://xmpp.org/extensions/xep-0045.html>.

3. RFC 4122: A Universally Unique IDentifier (UUID) URN Namespace <http://tools.ietf.org/html/rfc4122>.

4. RFC 6122: Extensible Messaging and Presence Protocol (XMPP): Address Format <http://tools.ietf.org/html/rfc6122>.

5. The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see <http://www.iana.org/>.

6. The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see <https://xmpp.org/registrar/>.

7. XEP-0030: Service Discovery <https://xmpp.org/extensions/xep-0030.html>.

Appendix H: Revision History

Note: Older versions of this specification might be available at https://xmpp.org/extensions/attic/

  1. Version 0.7.0 (2023-02-20)

    Add security consideration regarding spoofability and reference example

    fs
  2. Version 0.6.1 (2020-11-03)

    Correct example caption

    gh/@melvo
  3. Version 0.6.0 (2018-10-01)
    Defer due to lack of activity.
    XEP Editor (jsc)
  4. Version 0.5.0 (2017-08-23)
    dg
  5. Version 0.4.1 (2017-05-20)
    egp
  6. Version 0.4 (2016-10-30)

    Add ability to discover support

    dg
  7. Version 0.3.0 (2016-10-29)

    Rename client-id element to origin-id.

    Minor improvements.

    fs
  8. Version 0.2.1 (2015-09-22)

    Minor fixes (typos, s/JID/XMPP Address, etc.)

    fs
  9. Version 0.2 (2015-09-18)
    fs
  10. Version 0.1 (2015-07-14)

    Initial published version approved by the XMPP Council.

    XEP Editor (mam)
  11. Version 0.0.2 (2015-06-22)
    fs
  12. Version 0.0.1 (2015-06-01)

    First draft.

    fs

Appendix I: Bib(La)TeX Entry

@report{schmaus2015stanza-id,
  title = {Unique and Stable Stanza IDs},
  author = {Schmaus, Florian},
  type = {XEP},
  number = {0359},
  version = {0.7.0},
  institution = {XMPP Standards Foundation},
  url = {https://xmpp.org/extensions/xep-0359.html},
  date = {2015-06-01/2023-02-20},
}

END