Commit graph

28 commits

Author SHA1 Message Date
Oneric 8684964c5d Only allow exact id matches
This protects us from falling for obvious spoofs as from the current
upload exploit (unfortunately we can’t reasonably do anything about
spoofs with exact matches as was possible via emoji and proxy).

Such objects being invalid is supported by the spec, sepcifically
sections 3.1 and 3.2: https://www.w3.org/TR/activitypub/#obj-id

Anonymous objects are not relevant here (they can only exists within
parent objects iiuc) and neither is client-to-server or transient objects
(as those cannot be fetched in the first place).
This leaves us with the requirement for `id` to (a) exist and
(b) be a publicly dereferencable URI from the originating server.
This alone does not yet demand strict equivalence, but the spec then
further explains objects ought to be fetchable _via their ID_.
Meaning an object not retrievable via its ID, is invalid.

This reading is supported by the fact, e.g. GoToSocial (recently) and
Mastodon (for 6+ years) do already implement such strict ID checks,
additionally proving this doesn’t cause federation issues in practice.

However, apart from canonical IDs there can also be additional display
URLs. *omas first redirect those to their canonical location, but *keys
and Mastodon directly serve the AP representation without redirects.

Mastodon and GTS deal with this in two different ways,
but both constitute an effective countermeasure:
 - Mastodon:
   Unless it already is a known AP id, two fetches occur.
   The first fetch just reads the `id` property and then refetches from
   the id. The last fetch requires the returned id to exactly match the
   URL the content was fetched from. (This can be optimised by skipping
   the second fetch if it already matches)
   05eda8d193/app/helpers/jsonld_helper.rb (L168)
   63f0979799

 - GTS:
   Only does a single fetch and then checks if _either_ the id
   _or_ url property (which can be an object) match the original fetch
   URL. This relies on implementations always including their display URL
   as "url" if differing from the id. For actors this is true for all
   investigated implementations, for posts only Mastodon includes an
   "url", but it is also the only one with a differing display URL.
   2bafd7daf5 (diff-943bbb02c8ac74ac5dc5d20807e561dcdfaebdc3b62b10730f643a20ac23c24fR222)

Albeit Mastodon’s refetch offers higher compatibility with theoretical
implmentations using either multiple different display URL or not
denoting any of them as "url" at all, for now we chose to adopt a
GTS-like refetch-free approach to avoid additional implementation
concerns wrt to whether redirects should be allowed when fetching a
canonical AP id and potential for accidentally loosening some checks
(e.g. cross-domain refetches) for one of the fetches.
This may be reconsidered in the future.
2024-03-25 14:05:05 -01:00
Oneric f07eb4cb55 Sanity check fetched user data
In order to properly process incoming notes we need
to be able to map the key id back to an actor.
Also, check collections actually belong to the same server.

Key ids of Hubzilla and Bridgy samples were updated to what
modern versions of those output. If anything still uses the
old format, we would not be able to verify their posts anyway.
2024-03-25 14:05:05 -01:00
Oneric 59a142e0b0 Never fetch resource from ourselves
If it’s not already in the database,
it must be counterfeit (or just not exists at all)

Changed test URLs were only ever used from "local: false" users anyway.
2024-03-25 14:05:05 -01:00
Oneric fee57eb376 Move actor check into fetch_and_contain_remote_object_from_id
This brings it in line with its name and closes an,
in practice harmless, verification hole.

This was/is the only user of contain_origin making it
safe to change the behaviour on actor-less objects.

Until now refetched objects did not ensure the new actor matches the
domain of the object. We refetch polls occasionally to retrieve
up-to-date vote counts. A malicious AP server could have switched out
the poll after initial posting with a completely different post
attribute to an actor from another server.
While we indeed fell for this spoof before the commit,
it fortunately seems to have had no ill effect in practice,
since the asociated Create activity is not changed. When exposing the
actor via our REST API, we read this info from the activity not the
object.

This at first thought still keeps one avenue for exploit open though:
the updated actor can be from our own domain and a third server be
instructed to fetch the object from us. However this is foiled by an
id mismatch. By necessity of being fetchable and our longstanding
same-domain check, the id must still be from the attacker’s server.
Even the most barebone authenticity check is able to sus this out.
2024-03-25 14:05:05 -01:00
Oneric 2bcf633dc2 Document Pleroma.Object.Fetcher 2024-03-25 14:05:05 -01:00
Alexander Strizhakov 17f28c0507
mastodon pins 2021-03-25 13:03:40 +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
Haelwenn (lanodan) Monnier 921f926e96
Remove OStatus in testsuite 2020-09-08 18:43:57 +02:00
Haelwenn (lanodan) Monnier 82895a4012
SideEffects: port ones from ActivityPub.do_create and ActivityPub.insert 2020-07-15 11:40:23 +02:00
lain 3c2c32b460 Merge branch 'remake-remodel' into develop 2020-03-19 18:00:55 +01: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
Egor Kislitsyn 22018adae6
Fix Dialyzer warnings 2020-02-25 18:34:56 +04:00
lain e9993acdbb Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remake-remodel 2019-12-04 16:35:59 +01:00
lain e835cd97f6 Containment: Add a catch-all clause to contain_origin. 2019-11-12 12:07:17 +01:00
Ariadne Conill 5b60d82592 object containment: handle all cases where ID is invalid (missing, nil, non-string) 2019-11-08 14:51:28 -06:00
lain 1bd1f62af5 Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remake-remodel 2019-11-05 15:21:00 +01:00
Ariadne Conill 44e64af5e7 object: containment: simplify the pattern match for OStatus testsuite hack 2019-10-18 15:39:15 +00:00
Ariadne Conill e99fdfc32d object: containment: only allow OStatus references in test suite environment 2019-10-18 15:37:14 +00:00
Ariadne Conill 7295a05cee object: containment: also allow OStatus object IDs through when comparing origins 2019-10-18 14:50:10 +00:00
Ariadne Conill bf2107743f object: containment: don't try to contain ostatus objects 2019-10-18 14:50:10 +00:00
lain 081e8206ab Transmogrifier: Use new ingestion pipeline for Likes. 2019-10-16 17:03:21 +02:00
Ariadne Conill 739bbe0d3b security: detect object containment violations at the IR level
It is more efficient to check for object containment violations at the IR
level instead of in the protocol handlers.  OStatus containment is especially
a tricky situation, as the containment rules don't match those of IR and
ActivityPub.

Accordingly, we just always do a final containment check at the IR level
before the object is added to the IR object graph.
2019-07-14 17:47:08 +00:00
Egor 58a094b605 Add copyright info to containment.ex 2019-06-14 09:26:36 +00:00
William Pitcock e71ddf23ba containment: remove pointless moduledoc line 2019-05-07 16:11:22 +00:00
Haelwenn (lanodan) Monnier 69a5074893
Remove H1 in @moduledoc 2019-05-06 04:53:12 +02:00
rinpatch 35ac672b8d Remove containment tests from transmogrifier and fix thread visibility solver 2019-04-17 17:59:15 +03:00
rinpatch 627e5a0a49 Merge branch 'develop' into feature/database-compaction 2019-04-17 12:22:32 +03:00
William Pitcock e8caecb5c7 object: move object containment out of transmogrifier into it's own module 2018-12-04 04:52:09 +00:00