akkoma/test/pleroma/web/mastodon_api/views
Oneric 0c2b33458d Restrict media usage to owners
In Mastodon media can only be used by owners and only be associated with
a single post. We currently allow media to be associated with several
posts and until now did not limit their usage in posts to media owners.
However, media update and GET lookup was already limited to owners.
(In accordance with allowing media reuse, we also still allow GET
lookups of media already used in a post unlike Mastodon)

Allowing reuse isn’t problematic per se, but allowing use by non-owners
can be problematic if media ids of private-scoped posts can be guessed
since creating a new post with this media id will reveal the uploaded
file content and alt text.
Given media ids are currently just part of a sequentieal series shared
with some other objects, guessing media ids is with some persistence
indeed feasible.

E.g. sampline some public media ids from a real-world
instance with 112 total and 61 monthly-active users:

  17.465.096  at  t0
  17.472.673  at  t1 = t0 + 4h
  17.473.248  at  t2 = t1 + 20min

This gives about 30 new ids per minute of which most won't be
local media but remote and local posts, poll answers etc.
Assuming the default ratelimit of 15 post actions per 10s, scraping all
media for the 4h interval takes about 84 minutes and scraping the 20min
range mere 6.3 minutes. (Until the preceding commit, post updates were
not rate limited at all, allowing even faster scraping.)
If an attacker can infer (e.g. via reply to a follower-only post not
accessbile to the attacker) some sensitive information was uploaded
during a specific time interval and has some pointers regarding the
nature of the information, identifying the specific upload out of all
scraped media for this timerange is not impossible.

Thus restrict media usage to owners.

Checking ownership just in ActivitDraft would already be sufficient,
since when a scheduled status actually gets posted it goes through
ActivityDraft again, but would erroneously return a success status
when scheduling an illegal post.

Independently discovered and fixed by mint in Pleroma
1afde067b1
2024-05-22 20:30:18 +02:00
..
account_view_test.exs Merge pull request 'Return last_status_at as date, not datetime' (#681) from katafrakt/akkoma:fix-last-status-at into develop 2024-02-17 11:37:19 +00:00
conversation_view_test.exs Bump Copyright to 2021 2021-01-13 07:49:50 +01:00
list_view_test.exs Bump Copyright to 2021 2021-01-13 07:49:50 +01:00
marker_view_test.exs Bump Copyright to 2021 2021-01-13 07:49:50 +01:00
notification_view_test.exs Support elixir1.15 2023-08-03 17:44:09 +01:00
poll_view_test.exs little refactor and tests 2021-01-25 19:46:36 +03:00
scheduled_activity_view_test.exs Restrict media usage to owners 2024-05-22 20:30:18 +02:00
status_view_test.exs Migrate to phoenix 1.7 (#626) 2023-08-15 10:22:18 +00:00
subscription_view_test.exs Bump Copyright to 2021 2021-01-13 07:49:50 +01:00
suggestion_view_test.exs v2 Suggestions: rudimentary API response 2021-11-26 14:34:10 -06:00