Download content/client-server-api/modules/message_retention.md from abr00kx/taper: direct link, hf CLI and curl.
- Browser
- Download file 17.2 kB
-
https://huggingface.co/abr00kx/taper/resolve/main/content/client-server-api/modules/message_retention.md
- Command line
-
hf download hf://abr00kx/taper/content/client-server-api/modules/message_retention.md
-
curl -L -o message_retention.md https://huggingface.co/abr00kx/taper/resolve/main/content/client-server-api/modules/message_retention.md
Message Retention
Taper does not keep message history. Every message event, every copy of it, and every piece of data derived from it has a fixed, short lifetime. Once that lifetime ends, the event is gone from every conforming server and client.
This is a core property of the protocol, not an optional module. A server or client that keeps message content past its expiry does not conform to this specification, whatever else it implements.
The retention ceiling
The retention ceiling is 21 days (1814400000 milliseconds).
No message event, and no data derived from one, may be retained by any conforming implementation for longer than the retention ceiling. The ceiling is fixed by this specification. Servers, rooms and users MAY choose a shorter lifetime, but nothing can make it longer: not server configuration, not room state, not user preference, not a room version.
{{% boxes/warning %}} The ceiling cannot be extended by any means, including "legal hold", "compliance archiving" or "export" features. An implementation that offers such a feature does not conform to this specification. {{% /boxes/warning %}}
Definitions
Message event
: Any event that is not a state event. This includes t.room.message,
t.room.encrypted, t.reaction, t.sticker, call events, redactions,
replacements and all custom non-state event types.
Derived data
: Anything produced from a message event or its content, including:
decrypted plaintext; search indexes; push notification payloads and the
notification list returned by GET /notifications;
URL previews; thumbnails and media referenced by the event; relation
aggregations (such as reaction counts and edit history); thread summaries;
cached /context and /messages responses; and logs.
Effective lifetime : The lifetime that applies to an event in a given room. It is the smallest of:
- the retention ceiling;
- the room's
max_lifetime, if the room has ant.room.retentionstate event; - the server's own configured maximum, if the server has one. The server
advertises this through the
t.retentioncapability.
Different servers in the same room can have different effective lifetimes for it, because a server's own maximum only applies to that server.
Reference time
: The reference time of an event is the earlier of its origin_server_ts
and the time at which the server holding the copy first received it. Using
the earlier time means a sender cannot set a future origin_server_ts to
keep its events around for longer.
Expiry time : The event's reference time plus the effective lifetime.
Effect on the history visibility default
On its own, a short lifetime would still let anyone joining a room read up to
three weeks of conversation that happened before they arrived. Taper therefore
also changes the default history visibility to
joined: unless a room explicitly opts in, a user who joins sees no history
from before their join. Rooms that do opt in to shared, invited or
world_readable still only expose events that have not expired.
Events
{{% event event="t.room.retention" %}}
Server behaviour
Purging
A server MUST purge each message event no later than its expiry time. Purging an event means:
- The server MUST stop returning the event, or anything derived from it, from every API, client-server and server-server alike. This applies from the expiry time onwards, even if deletion from storage is still in progress.
- The server MUST irrecoverably delete the event's content,
sender,type,origin_server_ts, signatures,unsigneddata, and all derived data. This covers primary storage, replicas, caches, search indexes, logs and backups. - The server MAY keep an event stub for as long as it needs one to keep
the room DAG consistent. A stub contains only the event ID, room ID,
depth,prev_events, and the fact that the event was purged. Its only uses are to stop the server fetching the event again, and to let the server continue to accept events that reference it inprev_events.
When the effective lifetime of a room is shortened, for example by a new
t.room.retention event, every event whose new expiry time has already passed
MUST be purged at once. When it is lengthened, events that have already been
purged stay purged, and no event's expiry time can ever pass the retention
ceiling.
Servers MUST use crypto-shredding, as set out in Encryption at rest: event content is encrypted at rest with keys that rotate at least daily, and each key is destroyed once every event it protects has expired.
{{% boxes/rationale %}} Backups and replicas are the usual way "deleted" data survives. Destroying the key makes every copy in every backup unreadable at the same moment, so backups do not need separate purging. {{% /boxes/rationale %}}
Servers MUST NOT write the content of events, decrypted or otherwise, to logs.
State events
State events carry the room's configuration and authorisation, so they cannot simply be deleted. They are handled as follows:
- An event in the current state of a room is kept for as long as it is
part of the current state, with one privacy rule: an
t.room.memberevent whosemembershipisleave(notjoin,inviteorban) MUST be purged once its expiry time passes, because absent membership is equivalent toleaveunder room authorisation rules and keeping departed members' leave events indefinitely leaks historical room membership. - When a room has no remaining
join,inviteorbanmembers and all of its events have passed their expiry time, servers SHOULD delete the empty room. - A state event that has been superseded (it is no longer in the current state) MUST be purged by its expiry time, as for message events, with one exception: if it is in the auth chain of an event the server still holds, the server keeps it, but only in redacted form, using the redaction algorithm of the room version. Its full content MUST still be deleted by the expiry time.
- A server MUST NOT return
prev_contentorreplaces_stateinunsignedwhen they point to an event whose expiry time has passed.
Clients MUST NOT use state events to carry conversational content in order to get around retention.
Client-server API
Once an event has expired, servers MUST NOT include it in the response of any
endpoint. This covers /sync,
/messages,
/context,
/event,
/relations,
/threads,
/search and
/notifications. If a client asks
for a specific expired event, the server MUST respond with 404 and the
error code T_EXPIRED.
Servers MUST include expires_ts in the unsigned section of every message
event they serve to clients. This is the event's expiry time on this server,
in milliseconds since the Unix epoch. Clients use it to schedule their own
deletion.
The following are subject to the same limit:
- To-device messages. A to-device message that has not been delivered within the retention ceiling MUST be discarded.
- Delayed events. Servers MUST NOT accept a
delayed event whose delay exceeds the retention ceiling.
The
max_delay_msvalue of thet.delayed_eventscapability MUST NOT be greater than1814400000. - Reports. When a server stores a report about content, the copy of the reported event's content it keeps for moderators MUST be deleted no later than the event's own expiry time. The report itself (who reported which event ID, when, and why) may be kept longer.
- Push. Event content sent to a push gateway is derived data. Push gateways MUST NOT persist it (see the Push Gateway API).
- Application services. An application service sees events through its homeserver and MUST follow this module for every event it receives. Bridges cannot make remote, non-Taper networks follow this module, and SHOULD tell users so.
Federation
Servers MUST NOT send expired events over federation. They MUST NOT accept a non-state PDU, through any API, whose expiry time has already passed when it arrives. See Message retention in the server-server API.
Client behaviour
A client MUST delete each event, and everything derived from it, from local
storage by the event's expires_ts at the latest. This covers:
- the event itself and its decrypted plaintext;
- local search indexes;
- cached media and thumbnails for media the event references;
- notifications the client has shown through the operating system, where the operating system allows them to be withdrawn;
- draft replies or quotes that include the event's content.
When a client receives an t.room.retention event that shortens a room's
lifetime, it MUST apply the new lifetime to every event it holds for that
room, using each event's reference time.
Local storage
Deleting a row from a database does not remove it from the device. SQLite and similar engines leave deleted records in free pages, write-ahead logs and journals, and flash storage keeps old copies of blocks after they have been overwritten. Forensic tools recover deleted messages from exactly these places. Clients therefore MUST make expired data unrecoverable, not just unreachable:
- Clients MUST encrypt every stored event, its plaintext and all derived data with keys that rotate at least once per day, and MUST destroy each key once every item it protects has expired. Destroying the key is what makes the data unrecoverable. Deleting the records as well is RECOMMENDED but not sufficient on its own.
- Clients MUST keep these keys only in memory or in storage that the operating
system does not back up or sync (for example, iOS Keychain items marked
ThisDeviceOnly, or Android Keystore keys). They MUST NOT be derivable from any secret that is backed up. - Clients MUST exclude their message stores, search indexes and media caches from operating system and cloud backups (for example, iCloud Backup, Android Auto Backup and Google Drive backup). If a platform does not allow this, the encrypted data may be backed up, provided the keys are not.
Operating system surfaces
The operating system keeps its own records of what an application showed. These records are outside the client's control once written, so clients SHOULD avoid creating them:
- Clients SHOULD NOT include message content, sender names or room names in operating system notifications by default. A generic notification ("New message") is RECOMMENDED. Operating systems keep notification history in databases that the client cannot delete from.
- Clients SHOULD hide message content from the snapshots the operating system takes for its app switcher, for example by showing a blank or blurred view when the client moves to the background.
- Clients SHOULD mark message input fields so the system keyboard does not
learn from them, where the platform allows (for example, Android's
IME_FLAG_NO_PERSONALIZED_LEARNING). - Clients SHOULD NOT add rooms, messages or contacts to system-wide search indexes, share sheets, or "suggested contacts" features.
Clients MUST NOT offer built-in features that export, archive or back up message content beyond its expiry time. This does not stop a determined user from photographing a screen. The guarantee is that no conforming software keeps the history.
Clients SHOULD tell users, when they open a room, how long its messages live.
Media
Media uploaded to the content repository also expires. A piece of media, including its thumbnails, MUST be deleted from every server that stores it, the origin server and any server caching a remote copy, no later than the retention ceiling after it was uploaded. There is one exception: media is kept for as long as the server can see that it is referenced from:
- the current state of a room (for example
t.room.avatar); - a user's current profile (for example
avatar_url); or - a user's account data (for example image packs).
When the last such reference goes away, the retention ceiling starts again from that moment.
URL previews generated by
GET /preview_url are derived data and
MUST NOT be cached for longer than the retention ceiling.
End-to-end encryption
Deleting ciphertext is not enough if decryption keys outlive it. Clients and servers therefore MUST also follow these rules:
rotation_period_msint.room.encryptionMUST NOT be greater than86400000(one day), androtation_period_msgsMUST NOT be greater than 100. Clients MUST treat larger values as these limits. Clients MUST also rotate when a member leaves or a device list changes (see Group encryption).- Clients MUST discard an inbound Megolm session no later than the retention
ceiling after the last message they decrypted with it. In any case, they
MUST discard it no later than the retention ceiling plus
86400000milliseconds after they received the session. - Server-side key backup: servers MUST delete
each backed-up session no later than the retention ceiling plus
86400000milliseconds after the session was first uploaded. Clients MUST NOT upload a session again once it is past this point. - Clients MUST NOT include in a key export, or in a
RoomKeyBundle, any session they would be required to discard under these rules.
Deniability
Retention limits how long conforming software keeps a conversation. It does not stop someone who kept a copy anyway, so Taper also aims to make any copy useless as proof. A copy of a Taper conversation, however it was obtained, should not show a third party what a user said. The protocol achieves this through several mechanisms:
- No signatures on message content. In room version 13 and later, event hashes, signatures and IDs do not cover message content, and all message content is end-to-end encrypted. Its authenticity rests on Megolm and Olm, which convince the participants but could have been forged by any recipient.
- Published request keys. Servers sign federation requests with short-lived keys and publish the private keys once they retire them (see Publishing Keys). A logged request proves nothing once its key is published.
- No content to third parties. Push notifications carry only event IDs (see the Push Gateway API), so platform push providers never hold message content.
- No forensic residue. Clients crypto-shred local storage and keep content out of backups and operating system records (see client behaviour).
Servers MUST use room version 13, or a later room version that provides the same property, for new rooms.
The following are not deniable, and clients SHOULD make this clear to users:
- Metadata. Event signatures still show which user sent an event, of which type, in which room, and when. Room membership is in signed state.
- State that servers need. Membership, power levels, join rules and the other state listed in Encrypted state are signed in full and readable by servers. Other state, such as room names and topics, is end-to-end encrypted, but servers still see its type.
- Testimony. A participant can still describe what they read. Deniability removes proof, not witnesses.
- Older rooms. Rooms using a room version before 13 commit to message content in their event hashes.
Security considerations
- A malicious server, client or user can always keep a copy of anything it was sent. Retention is a guarantee about conforming software, and it limits what can be lost in a breach, seized or subpoenaed. It does not stop a participant from deliberately recording a conversation.
- State events in the auth chain survive in redacted form for as long as they are needed. They reveal room metadata, such as who was a member and when, but not message content.
- Because clocks drift, servers SHOULD start purging a short time before the expiry time instead of exactly on it.
- Operators remain bound by the law where they operate. This specification cannot override a legal obligation to preserve data, such as a litigation hold. An operator who preserves data under such an obligation is running non-conforming software for that data, and SHOULD tell affected users where the law allows it.