Add ProtoXEP: OpenPGP for XMPP Pubsub

Specifies an OpenPGP for XMPP (XEP-0373) profile for the pubsub use case.
This commit is contained in:
Jérôme Poisson 2022-10-09 22:33:55 +02:00
parent 45c2d1e8be
commit b06ddd6b8c
1 changed files with 203 additions and 0 deletions

203
inbox/pubsub-encryption.xml Normal file
View File

@ -0,0 +1,203 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE xep SYSTEM 'xep.dtd' [
<!ENTITY % ents SYSTEM 'xep.ent'>
%ents;
]>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep>
<header>
<title>OpenPGP for XMPP Pubsub</title>
<abstract>Specifies an OpenPGP for XMPP (XEP-0373) profile for the pubsub use case.</abstract>
&LEGALNOTICE;
<number>xxxx</number>
<status>ProtoXEP</status>
<type>Standards Track</type>
<sig>Standards</sig>
<approver>Council</approver>
<dependencies>
<spec>XMPP Core</spec>
<spec>XEP-0001</spec>
<spec>XEP-0004</spec>
<spec>XEP-0060</spec>
<spec>XEP-0373</spec>
<spec>XEP-0374</spec>
</dependencies>
<supersedes/>
<supersededby/>
<shortname>oxps</shortname>
<author>
<firstname>Jérôme</firstname>
<surname>Poisson</surname>
<email>goffi@goffi.org</email>
<jid>goffi@jabber.fr</jid>
</author>
<revision>
<version>0.0.1</version>
<date>2022-10-09</date>
<initials>jp</initials>
<remark><p>First draft.</p></remark>
</revision>
</header>
<section1 topic='Introduction' anchor='intro'>
<p>&xep0060; and &xep0163; are widely used XMPP features. However, items are published in plain text, making them readable by server administrators or anybody having administrator level access on the pubsub/PEP services.</p>
<p>Although this is not a problem for data intended to be published publicly, there are many cases where it may be desirable to make the data inaccessible to anybody but the selected recipients, or in other words to end-to-end encrypt the data.</p>
<p>This specification aims to provide an easy way to e2e encrypt items of a pubsub node, and to share access with other entities. It is compatible with all existing pubsub/PEP features, which makes it possible to use securily features such a geolocation, private blogs, private calendar events, data forms, etc. This specification is based on &xep0373;.</p>
</section1>
<section1 topic='Requirements' anchor='reqs'>
<p>The design goals of this XEP are:</p>
<ul>
<li>work with basic standard pubsub/PEP service, no extra feature needed;</li>
<li>be generic and work with any protocol using pubsub: once decrypted, the items should be parsable as if they were plain text;</li>
<li>be able to share with other entities the means to decipher the elements;</li>
<li>be able to easily share the means of decrypting items with new entities, even after the items have been published;</li>
<li>be able to modify the means of decryption to make the new elements inaccessible to certain entities even if they have had access to the previous elements;</li>
</ul>
</section1>
<section1 topic='Glossary' anchor='glossary'>
<ul>
<li><strong>e2ee</strong>: end-to-end encryption</li>
<li><strong>Shared Secret</strong>: a cryptographically strong random string used to symmetrically encrypt items</li>
<li><strong>Encrypted Node</strong>: pubsub node whose items are end-2-end encrypted using this protocol.</li>
</ul>
</section1>
<section1 topic='Overview' anchor='overview'>
<p>To encrypt a pubsub node, each item is symmetrically encrypted with a shared secret using OpenPGP symmetric encryption. The secret is shared with other entities using e2e encrypted messages with &xep0374;. If an entity's access is revoked or a shared secret may have been compromised, a new shared secret is generated and new items are encrypted with it.</p>
</section1>
<section1 topic='Use Cases' anchor='usecases'>
<section2 topic='Encrypting Pubsub Item' anchor='encrypt'>
<p>Juliet wants to create a private blog (using &xep0277;) that she only share with her confidante and her lover. To make sure that her family, who manages her XMPP server, can't read the content, she want to use end-to-end encryption.</p>
<p>To do so, her client generates a "shared secret" by generating a cryptographically strong key that will be used to symmetrically encrypt new items. This key MUST be associated with an ID, which MUST be an unique sequence of characters usable in an XML attribute. She will later share this key with entities allowed to access the blog as explained below.</p>
<p>From now on, all items that Juliet publishes on the node SHOULD be symmetrically encrypted with the shared secret by using OpenPGP symmetric encryption.</p>
<p>To publish an encrypted item, an &lt;encrypted/&gt; element qualified by the 'urn:xmpp:openpgp:pubsub:0' namespace MUST be used as payload. This element MUST contain a 'secret' attribute whose value is the ID of the shared secret used. The content of the element is a base64 encoded Symmetric-Key Encrypted Session Key Packet as specified at <cite>RFC 4880</cite> <link url='http://tools.ietf.org/html/rfc4880#section-5.3'>§ 5.3</link> (in a similar way as <link url='https://xmpp.org/extensions/xep-0373.html#backup-encryption'>secret key backup is encoded in XEP-0373</link>). The encrypted content is the item payload that would normally be used.</p>
<p>The encrypted node SHOULD have a "whitelist" access model as specified in &xep0060;. Juliet's client ensure that either by creating a new node with suitable access model, or by changing the access model of existing node.</p>
<example caption="Juliet publish an encrypted item"><![CDATA[
<iq
type='set'
from='juliet@capulet.lit/chamber'
to='pubsub.capulet.lit'
id='encrypted1'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='123abc'>
<item id="encrypt_123">
<encrypted xmlns='urn:xmpp:openpgp:pubsub:0' key='1234-abcd-5678-efgh'>
<!-- BASE64_OPENPGP_SYMMETRICALLY_ENCRYPTED_ITEM -->
</encrypted>
</item>
</publish>
</pubsub>
</iq>]]></example>
</section2>
<section2 topic='Transmit Shared Secret' anchor='transmit_secret'>
<p>Now that Juliet has started to publish encrypted items on a blog, she wants to share the secret key with her confidante and her lover. To do so she uses a e2ee &MESSAGE; stanza as specified in &xep0374;, in which she encrypt a &lt;shared-secret/&gt; element qualified by the 'urn:xmpp:openpgp:pubsub:0' namespace. This element MUST have the following attributes:</p>
<ul>
<li>a 'timestamp' attribute whose value is the datetime of the shared key generation. Datetime format is specified in &xep0082;.</li>
<li>a 'jid' attribute with bare JID of the pubsub/PEP service;</li>
<li>a 'node' attribute with the name of the encrypted node;</li>
<li>an 'id' attribute with the ID of the shared secret;</li>
<li>if the key is revoked (due to <link url='#revocation_rotation'>shared secret rotation</link>), it must have a 'revoked' attribute with the value "true".</li>
</ul>
<p>The &lt;shared-secret/&gt; SHOULD have a 'type' attribute whose value is the pubsub#type that the node would have if it were plain text (i.e. the semantic type information of decrypted data in the node, usually the namespace of the decrypted payload). </p>
<p>The content of the &lt;shared-secret/&gt; element MUST be the base64 encoded shared secret.</p>
<p>Entities MUST always use the most recently generated shared secret to encrypt new items (the 'timestamp' attribute is used to check generation date and time).</p>
<p>
Following example only show the &lt;shared-secret&gt; payload, as it is normally put as an encrypted payload of &lt;openpgp/&gt; element of a &xep0374; message.
</p>
<example caption="shared-secret payload (normally encrypted as part of XEP-0374 message)"><![CDATA[
<shared-secret
xmlns='urn:xmpp:openpgp:pubsub:0'
jid='pubsub.capulet.lit'
node='123abc'
id='1234-abcd-5678-efgh'
type='http://www.w3.org/2005/Atom'
>
<!-- BASE64_ENCODED_SHARED_SECRET -->
</shared-secret>
]]></example>
<p><strong>note:</strong> we use a &xep0374; &MESSAGE; instead of PEP or Pubsub to transmit the shared secret for several reasons:</p>
<ul>
<li>Shared secret would have to be encrypted for all entities allowed to decrypt the items, and re-encrypted each time there is a new entity. While acceptable for a small number of entities, this doesn't scale as well as separated &MESSAGE;;</li>
<li>The item containing the shared secret would need to keep all previous shared secrets in case of secret rotation (see <link url='#revocation_rotation'>below</link>). At some point, there would be a risk to reach stanza maximum size limit of one server;</li>
<li>Using a well-known pubsub node or pubsub item id would mean than the location of the encrypted shared secret would be known. While not enough to get the secret, that's better to hide it in encrypted messages flow;</li>
</ul>
</section2>
<section2 topic='Revocation and Shared Secret Rotation' anchor='revocation_rotation'>
<p>If there is any doubt about the compromise of a shared secret or if access to the encrypted node is revoked for an entity, the shared secret SHOULD BE rotated.</p>
<p>To rotate a key, a &xep0374; message must be sent to all people which got the shared secret, with an encrypted &lt;revoke/&gt; element qualified by the 'urn:xmpp:openpgp:pubsub:0' namespace, which MUST have an 'id' attribute whose value is the shared secret ID. Optionally, the &lt;revoke/&gt; element MAY have one or more &lt;reason/&gt; child element(s) which contain a human readable message explaining the reason of the revocation. The &lt;reason/&gt; element MAY contain an 'xml:lang' attribute with the language code of the text, and there MAY be several &lt;reason/&gt; elements if and only if they have distinct xml:lang. A revoked key MUST NOT be used to encrypt new items.</p>
<p>Then a new shared secret MUST be generated and transmitted to all participants (excluding those who have seen their access revoked) as explained in <link url='#transmit_secret'>Transmit Shared Secret.</link></p>
<p>Note that if an entity's access is revoked, it SHOULD also be removed from the node's whitelist (if "whitelist" has been used as access model as recommended).</p>
<p>
Following example only show the &lt;revoke/&gt; payload, as it is normally put as an encrypted payload of &lt;openpgp/&gt; element of a &xep0374; message.
</p>
<example caption="revoke Payload (normally encrypted as part of XEP-0374 message)"><![CDATA[
<revoke xmlns='urn:xmpp:openpgp:pubsub:0' id='1234-abcd-5678-efgh'>
<reason>Revoked access from an entity</reason>
</revoke>
]]></example>
<p>Items published before the key rotation SHOULD NOT be re-encrypted as it would be resource intensive, and revoked entities may have made a copy.</p>
<p>When access to the shared secret is granted to a new entity, all previously used keys SHOULD be transmitted (with their 'revoked' attribute set to "true" as explained in <link url='#transmit_secret'>Transmit Shared Secret.</link>) along with the currently used shared secret. This allows the new entity to decrypt the items encrypted with the old keys. The &lt;shared-secret/&gt; elements can either be sent in the same encrypted payload of a single &xep0374; &MESSAGE;, or split into multiple encrypted &MESSAGE;, it's up to the implementation to decide which is better (keep in mind that too many shared secrets in a single message may reach the maximum stanza size limit at some point, even if this limit is not likely to be reached for most usual cases).</p>
</section2>
</section1>
<section1 topic='Business Rules' anchor='rules'>
<p>When &xep0470; are used, the attachment node SHOULD have the same access model (i.e. whitelist as recommended in <link url="#security">Security Considerations</link>) as the encrypted node, with authorized entities synchronized (this should be done automatically for <link url='https://xmpp.org/extensions/xep-0470.html#full-compliance'>fully compliant services</link>). The items published to attachment node itself MUST be encrypted using this protocol. Due to <link url='https://xmpp.org/extensions/xep-0470.html#validity-check'>validity check of attachment items</link>, the encrypted element MUST be a child of a XEP-0470's &lt;attachments/&gt; element, instead of being the &lt;item/&gt; payload as usual. Note that this will prevent the <link url="https://xmpp.org/extensions/xep-0470.html#summary-node">summary feature</link> to work with encrypted elements, and the end-user client will have to do the summary itself, this is an inevitable trade-off when using e2ee.</p>
<p>The "pubsub#type" of an encrypted item is always "urn:xmpp:openpgp:pubsub:0", thus no information is leaked on the content of the node, and all encrypted node can easily be retrieved by using &xep0462;.</p>
<p>Note that encrypted items MAY be mixed with plain text items: for instance if a blog is public, but some of its items are private. However the proper handling of this use case is out of scope of this specification.</p>
<p>To transmit the shared secret, an other e2e encryption algorithm than &xep0374; MAY be used as long as the elements containing the secret are end-to-end encrypted. For instance, &xep0384; (version 2 or more) with &xep0420; could be used. As OpenPGP is necessary to decrypt items, &xep0374; seems the most appropriate choice.</p>
</section1>
<section1 topic='Discovering Support' anchor='disco'>
<p>If a client supports the protocol specified in this XEP, it MUST advertise it by including the "urn:xmpp:openpgp:pubsub:0" discovery feature in response to a &xep0030; information request:</p>
<example caption="Service Discovery information request"><![CDATA[
<iq type='get'
from='juliet@example.org/balcony'
to='romeo@example.org/orchard'
id='disco1'>
<query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>]]></example>
<example caption="Service Discovery information response"><![CDATA[
<iq type='result'
from='romeo@example.org/orchard'
to='juliet@example.org/balcony'
id='disco1'>
<query xmlns='http://jabber.org/protocol/disco#info'>
...
<feature var='urn:xmpp:openpgp:pubsub:0'/>
...
</query>
</iq>]]></example>
</section1>
<section1 topic='Security Considerations' anchor='security'>
<ul>
<li>To limit the surface of attack, the access model of an encrypted node should be set to "whitelist" and only people having the shared key should be allowed to retrieve encrypted items.</li>
<li>If the shared key is compromised, or a user access is revoked, the key MUST be rotated. However, only new items are encrypted with the new key, any previous item should be considered as compromised too.</li>
<li>Sometimes client may use metadata to construct item ID, this is notably the case for some &xep0277; implementation, as the resulting item ID is used to generate user friendly URLs. To avoid metadata leakage, clients SHOULD NOT derivate the item ID from any data of the item when pubsub encryption is used.</li>
<li>Some protocols define prefixes for nodes, this is for instance the case for <link url='https://xmpp.org/extensions/xep-0277.html#comments'>XEP-0277 Comments</link>. If the prefix is not essential to make the feature work (which is the case for XEP-0277 comments), the client SHOULD NOT use the usual prefix to avoid leaking informations on the content of the node. The prefix defined in &xep0470; MUST be used as usually, as it is essential to retrieve the attachment node, and it's generic and thus doesn't leak information on the node content.</li>
<li>To decrypt archives and future items, clients most probably cache plain text version of items, and shared secret. If one device with access to an encrypted node is compromised, all items from the node should be considered compromised, and shared secret should be rotated.</li>
<li>For the same reason, client SHOULD encrypt data at rest (even if the device is stolen, data should not be accessible without some cryptographic key).</li>
<li>Note that only the shared key sender is authenticated (by &xep0374;), not the items publishers, meaning that encrypted items could be published by anybody in possession of the shared secret. Pubsub items authentication will be treated in a separated XEP.</li>
</ul>
</section1>
<section1 topic='IANA Considerations' anchor='iana'>
<p>TODO</p>
</section1>
<section1 topic='XMPP Registrar Considerations' anchor='registrar'>
<p>TODO</p>
</section1>
<section1 topic='XML Schema' anchor='schema'>
<p>TODO</p>
</section1>
<section1 topic='Acknowledgements' anchor='acks'>
<p></p>
</section1>
</xep>