Skip to content

Commit dbae160

Browse files
committed
merge
1 parent 6185341 commit dbae160

File tree

1 file changed

+39
-16
lines changed

1 file changed

+39
-16
lines changed

proposals/2278-deleting-content.md

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ should purge old messages for a given room.
99
It originally also specified how media for purged events should be purged from
1010
disk, however this was split out into a new MSC [by
1111
request](https://github.com/matrix-org/matrix-doc/pull/1763#discussion_r320289119)
12-
during review.
12+
during review. This proposal also solves
13+
https://github.com/vector-im/riot-meta/issues/168 - the ability to garbage
14+
collect attachments from redacted events.
1315

1416
## Proposal
1517

@@ -21,25 +23,30 @@ propose:
2123
```
2224
DELETE /_matrix/media/r0/download/{serverName}/{mediaId}
2325
```
24-
with a JSON dict as a request body.
2526

2627
The API would return:
2728
* `200 OK {}` on success
2829
* `403` with error `M_FORBIDDEN` if invalid access_token or not authorised to delete.
2930
* `404` with error `M_NOT_FOUND` if the content described in the URL does not exist on the local server.
3031

3132
The user must be authenticated via access_token or Authorization header as the
32-
original uploader, or however the server sees fit in order to delete the content.
33+
original uploader, or server admin (as determined by the server implementation).
3334

3435
Servers may wish to quarantine the deleted content for some timeframe before
3536
actually purging it from storage, in order to mitigate abuse.
3637

37-
XXX: We might want to provide an undelete API too to let users rescue
38-
their content that they accidentally deleted, as you would get on a
39-
typical desktop OS file manager. Perhaps `DELETE` with `{ undo: true }`?
38+
If `serverName` is not the local server, the local cache (if any) of the content
39+
should be deleted. This proposal makes no effort to delete the remote content.
4040

41-
XXX: We might also want to let admins quarantine rather than delete attachments
42-
without a timelimit by passing `{ quarantine: true }` or similar.
41+
Overlapping or near-overlapping authorised requests to `DELETE` for existing
42+
content may either return 200 or 404 based on implementation choice.
43+
44+
*XXX: We might want to provide an undelete API too to let users rescue
45+
their content that they accidentally deleted, as you would get on a
46+
typical desktop OS file manager. Perhaps `DELETE` with `?undo=true`?*
47+
48+
*XXX: We might also want to let admins quarantine rather than delete attachments
49+
without a timelimit by passing `?quarantine=true` or similar.*
4350

4451
Server admins may choose to mark some content as undeletable in their
4552
implementation (e.g. for sticker packs and other content which should never be
@@ -58,17 +65,19 @@ only one referring event, and so when a client deems that the event should
5865
be deleted, it is safe to also delete the attachment without breaking any
5966
other events.
6067

61-
It seems reasonable to consider the special case of forwarding encrypted
62-
attachments between rooms as a 'copy by reference' - if the original
63-
event gets deleted, the others should too. If this isn't desired, then
64-
the attachment should be reencrypted.
68+
It seems reasonable to consider the special case of clients forwarding
69+
encrypted attachments between rooms as a 'copy by reference' - if the
70+
original event gets deleted, the copies should too. If this isn't desired,
71+
then the attachment should have been reencrypted and stored as a separate
72+
instance in the media repo.
6573

6674
### Unencrypted rooms
6775

68-
It's common for MXC URLs to be shared between unencrypted events - e.g. reusing
69-
sticker media, or when forwarding messages between rooms, etc. In this instance,
70-
the homeserver (not media server) should count the references to a given MXC URL
71-
by events which refer to it.
76+
It's common for MXC URLs to be shared between unencrypted events - e.g.
77+
reusing sticker media, or when forwarding messages between rooms, etc. In
78+
this instance, the homeserver (not media server) should count the references
79+
to a given MXC URL by events which refer to it (including state events such as
80+
avatar URLs in `m.room.membership` events.)
7281

7382
If all events which refer to it have been purged or redacted, the HS should delete
7483
the attachment - either by internally deleting the media, or if using an
@@ -93,6 +102,20 @@ being referenced in multiple rooms), but the room admin may want to still
93102
purge the content from their server. This can be achieved by DELETEing the
94103
content independently from redacting the membership events.
95104

105+
*N.B. we can't currently distinguish an E2EE attachment with unknown refering
106+
events, from a non-E2EE attachment with zero references which should be GCd.
107+
So we use mime-types as a heuristic to recognise E2EE attachments, and to stop
108+
them from being GC'd This would of course be vulnerable to an attacker lying
109+
about their mime-type in order to stop their repository entries being GC'd,
110+
but given E2EE attachments already let you bypass the GC, this doesn't feel
111+
like a big issue.*
112+
113+
Encrypted attachments should be stored with a mime-type of
114+
`application/aes-encrypted` (to be registered), and attachments
115+
with this mime-type which have never been referenced by an event should
116+
be exempt from GC. For backwards compatibility, this rule may also be
117+
applied to attachments with mime-type of `application/octet-stream`.
118+
96119
## Tradeoffs
97120

98121
Assuming that encrypted events don't reuse attachments is controversial but

0 commit comments

Comments
 (0)