Commit graph

109 commits

Author SHA1 Message Date
Oneric
ef029d23db fed/fetch: don't serve unsanitised object data for some activities
When the object associated with the activity was preloaded
(which happens automatically with Activity.normalize used in the
 controller) Object.normalize’s "id_only" option did not actually work.
This option and it’s usage were introduced to fix display of Undo
activities in e88f36f72b.
For "Undo"s (and "Delete"s) there is no object preloaded
(since it is already gone from the database) thus this appeared
to work and for the particular case considered there in fact did.
Create activities use different rendering logic and thus remained
unaffected too.

However, for all other types of Activities (yes, including Update
which really _should_ include a properly sanitised, full object)
this new attempt at including "just the id", lead to it instead
including the full, unsanitised data of the referenced object.

This is obviously bad and can get worse due to access restrictions
on the activity being solely performed based on the addressing
of the activity itself, not of the (unintentionally) embedded
object.

Starting with the obvious, this leaks all "internal" fields
but as already mentioned in 8243fc0ef4
all current "internal" fields from Constants.object_internal_fields
are already publicised via MastoAPI etc anyway. Assuming matching
addressing of the referenced object and activity this isn't problematic
with regard to confidentiality.
Except, the internal "voters" field recording who voted for a poll
is currently just omitted from Constants.object_internal_fields
and indeed confidential information (fix in subsequent commit).
Fortunately this list is for the poll as a whole and there are no
inlined lists for individual choices. While this thus leaks _who_
voted for a poll, it at least doesn't directly expose _what_ each voter
chose if there are multiple voters.

As alluded to before, the access restriction not being aware
of the misplaced object data into account makes the issue worse.
If the activity addressing is not a subset of the referenced object’s
addressing, this will leak private objects to unauthorised users.
This begs the question whether such mismatched addressing can occur.
For remote activities the answer is ofc a resounding YES,
but we only serve local ActivityPub objects and for the latter
it currently(!) seems like a "no".
For all intended interactions, the user interacting must already have
access to the object of interest and our ActivityPub Builder
already uses a subset of the original posts addressing for
posts not publicly accessible. This addressing creation logic
was last touched six years ago predating the introduction of this
exposure blunder.
The rather big caveat her being, until it was fixed just yesterday in
dff532ac72 it was indeed possible to
interact with posts one is not allowed to actually see. Combined, this
allowed unauthorised access to private posts. (The API ID of such
private posts can be obtained e.g. from replies one _is_ allowed to see)

During the time when ActivityPub C2S was supported there might have been
more ways to create activities with mismatched addressing and sneak a
peek on private posts. (The AP id can be obtained in an analogous way)

Replaces and fixes e88f36f72b.
Since there never were any users of the
bugged "id_only" option it is removed.

This was reported by silverpill <silverpill@firemail.cc> as an
ActivityPub interop issue, since this blunder of course also
leads to invalid AP documents by adding an additional layer
in form of the "data" key and directly exposing the internal
Pleroma representation which is not always identical to valid AP.

Fixes: https://akkoma.dev/AkkomaGang/akkoma/issues/1017
2025-11-24 00:00:00 +00:00
Oneric
b41a13df56 federation/out: add full replies collection to objects
Until now only a limited number of self-replies were inlined as an
anonymous, unordered ActivityPub collection. Notably the advertised
replies might be private posts.

However, providing all (non-private) replies allows for better thread
consistency across instances if the remote server cooperates.
The collection existing as a stndalone object has two advantages
for this. For one, if it was still anonymous, _all_ replies would need
to be inlined, which might be too bloated in pathological cases.
Secondly, it allows remote servers to update the thread by traversing
the reply collection independent of the original post. (If the remote
part knows about chronological ordering, it can in theory
even efficiently resume from where it previously stopped)
2025-06-07 21:02:31 +02:00
Oneric
1c2eb4d799 cosmetic/object: drop is_ prefix from is_tombstone_object?
The question mark suffix already implies it being an indicator function
2025-02-14 22:10:25 +01:00
Oneric
cd8e6a4235 transmogrifier: gracefully ignore duplicated object deletes
The object lookup is later repeated in the validator, but due to
caching shouldn't incur any noticeable performance impact.
It’s actually preferable to check here, since it avoids the otherwise
occuring user lookup and overhead from starting and aborting a
transaction
2025-01-07 20:27:28 +01:00
Oneric
bcfbfbcff5 Don't try to cleanup remote attachments
The cleanup attachment worker was run for every deleted post,
even if it’s a remote post whose attachments we don't even store.
This was especially bad due to attachment cleanup involving a
particularly heavy query wasting a bunch of database perf for nil.

This was uncovered by comparing statistics from
https://akkoma.dev/AkkomaGang/akkoma/issues/784 and
https://akkoma.dev/AkkomaGang/akkoma/issues/765#issuecomment-12256
2025-01-03 20:48:46 +01:00
Mark Felder
c241b5b09f Remove Fetcher.fetch_object_from_id!/2
It was only being called once and can be replaced with a case statement.
2024-04-12 20:26:28 +01:00
floatingghost
07a48b9293 giant massive dep upgrade and dialyxir-found error emporium (#371)
Co-authored-by: FloatingGhost <hannah@coffee-and-dreams.uk>
Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/371
2022-12-14 12:38:48 +00:00
Hélène
e88f36f72b ObjectView: do not fetch an object for its ID
Non-Create/Listen activities had their associated object field
normalized and fetched, but only to use their `id` field, which is both
slow and redundant. This also failed on Undo activities, which delete
the associated object/activity in database.

Undo activities will now render properly and database loads should
improve ever so slightly.
2022-09-11 19:52:59 +01:00
floatingghost
62e179f446 make conversation-id deterministic (#154)
Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/154
2022-08-06 20:59:15 +00:00
Alex Gleason
f2134e605b
Merge remote-tracking branch 'pleroma/develop' into cycles-base-url 2021-05-31 16:49:46 -05:00
Alex Gleason
51a9f97e87
Deprecate Pleroma.Web.base_url/0
Use Pleroma.Web.Endpoint.url/0 directly instead. Reduces compiler cycles.
2021-05-31 16:48:03 -05:00
Ivan Tashkinov
a996ab46a5 [#3213] Reorganized hashtags cleanup. Transaction-wrapped Hashtag.get_or_create_by_names/1. Misc. improvements. 2021-02-11 19:30:21 +03:00
Ivan Tashkinov
9948ff3356 [#3213] Added HashtagsCleanupWorker periodic job. 2021-01-31 18:24:19 +03:00
Ivan Tashkinov
ea4785213a [#3213] Switched to using embedded hashtags in Object.hashtags/1
(to avoid extra joins / preload in timeline queries).
2021-01-25 20:12:09 +03:00
Ivan Tashkinov
ca7f240643 [#3213] Ignoring of blank elements from objects.data->tag. 2021-01-21 20:50:06 +03:00
Ivan Tashkinov
e350898828 Merge remote-tracking branch 'remotes/origin/develop' into feature/object-hashtags-rework 2021-01-13 22:11:16 +03:00
Haelwenn (lanodan) Monnier
c4439c630f
Bump Copyright to 2021
grep -rl '# Copyright © .* Pleroma' * | xargs sed -i 's;Copyright © .* Pleroma .*;Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>;'
2021-01-13 07:49:50 +01:00
Ivan Tashkinov
0d521022fe [#3213] Removed PK from hashtags_objects table. Improved hashtags_transfer mix task (logging of failed ids). 2021-01-07 12:20:29 +03:00
lain
e1e7e4d379 Object: Rework how Object.normalize works
Now it defaults to not fetching, and the option is named.
2021-01-04 13:38:31 +01:00
Ivan Tashkinov
8d1a0c1afd [#3213] Made Object.object_data_hashtags/1 handle both AS2 and plain text hashtags. 2020-12-30 15:22:49 +03:00
Ivan Tashkinov
e0b5edb6d5 [#3213] Fixed Object.object_data_hashtags/1 to process only AS2 elements of data.tag (basing on #2984). 2020-12-30 14:42:35 +03:00
Haelwenn
3966add048 Revert "Merge branch 'features/hashtag-column' into 'develop'"
This reverts merge request !2824
2020-12-28 12:02:16 +00:00
Haelwenn
b122b6ffa3 Merge branch 'features/hashtag-column' into 'develop'
Insert text representation of hashtags into object["hashtags"]

See merge request pleroma/pleroma!2824
2020-12-28 10:14:58 +00:00
Haelwenn (lanodan) Monnier
18b536c176
Pleroma.Object/1: take %Object{} as argument instead 2020-12-28 11:05:24 +01:00
Ivan Tashkinov
14fae94c0e [#3213] Made Object.hashtags/1 work with :hashtags assoc. Adjusted tests. 2020-12-28 00:08:09 +03:00
Ivan Tashkinov
4134abef63 Merge remote-tracking branch 'remotes/origin/develop' into feature/object-hashtags-rework 2020-12-26 22:23:05 +03:00
Ivan Tashkinov
e369b1306b Added Hashtag entity and objects-hashtags association with auto-sync with data.tag on Object update. 2020-12-22 22:04:33 +03:00
Haelwenn (lanodan) Monnier
87b13c5430
Create Object.hashtags/1 wrapper 2020-12-22 05:15:34 +01:00
Ivan Tashkinov
ee221277b0 Encapsulation of tags / hashtags fetching from objects. 2020-12-21 22:54:26 +03:00
lain
713612c377 Cachex: Make caching provider switchable at runtime.
Defaults to Cachex.
2020-12-18 17:44:46 +01:00
lain
5221879c35 Fix linting. 2020-08-05 15:40:32 +02:00
lain
b5f0cef156 Apply 1 suggestion(s) to 1 file(s) 2020-08-05 11:33:21 +00:00
Haelwenn (lanodan) Monnier
4644a8bd10
Fix multiple-choice poll detection 2020-07-15 11:39:55 +02:00
lain
6dd1575c64 Merge branch 'issue/1509' into 'develop'
[#1509]  purge media from cache after delete

See merge request pleroma/pleroma!2539
2020-05-20 10:35:36 +00:00
Ivan Tashkinov
9b76565264 MediaController: enforced owner-only access in :show action.
Improved error response on denied access (now 403). Adjusted tests.
2020-05-18 09:51:53 +03:00
Maksim Pechnikov
cb40602a16 added media proxy invalidation 2020-05-15 21:39:42 +03:00
lain
5102468d0f Polls: Persist and show voters' count 2020-04-22 14:06:39 +02:00
Haelwenn
764a50f8a6 Merge branch 'feature/1482-activity_pub_transactions' into 'develop'
ActivityPub actions & side-effects in transaction

Closes #1482

See merge request pleroma/pleroma!2089
2020-03-02 07:58:01 +00:00
Haelwenn (lanodan) Monnier
6da6540036
Bump copyright years of files changed after 2020-01-07
Done via the following command:
git diff fcd5dd259a --stat --name-only | xargs sed -i '/Pleroma Authors/c# Copyright © 2017-2020 Pleroma Authors <https:\/\/pleroma.social\/>'
2020-03-02 06:08:45 +01:00
Alexander Strizhakov
ba87ed7335
fix for compiling 2020-03-01 12:01:39 +03:00
Alexander Strizhakov
32d1e04817
ActivityPub actions & side-effects in transaction 2020-03-01 12:01:39 +03:00
Ivan Tashkinov
7c3991f59e [#1505] Fixed replies serialization (included objects' ids instead of activities' ids). 2020-02-09 10:17:21 +03:00
Roman Chvanikov
8057157ee3 Make attachments cleanup optional 2020-01-31 01:20:37 +03:00
Roman Chvanikov
d6a532bf0f Delete attachments asynchronously 2020-01-19 19:45:20 +03:00
Roman Chvanikov
81133702d4 Delete attachments after object and cache cleanup 2020-01-17 20:20:37 +03:00
Roman Chvanikov
0709757e47 Check if object->data is array when looking up attachment objects to delete 2020-01-14 19:53:28 +03:00
Roman Chvanikov
88f0eed0f2 Delete attachments when status is deleted 2020-01-12 18:48:58 +00:00
Mark Felder
9ef912aecf Merge branch 'develop' into issue/1411 2019-12-11 15:02:53 -06:00
rinpatch
9f99640cfc ActivityPub: Fix deletes being exempt from MRF
Closes #1461
2019-12-05 21:45:57 +03:00
Maksim Pechnikov
88f7cf51d4 Merge branch 'develop' into issue/1411 2019-12-01 16:18:16 +03:00