mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-09 09:52:13 +00:00
8684964c5d
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.
56 lines
2.2 KiB
JSON
56 lines
2.2 KiB
JSON
{
|
|
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1", {
|
|
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
|
|
"sensitive": "as:sensitive",
|
|
"movedTo": "as:movedTo",
|
|
"Hashtag": "as:Hashtag",
|
|
"ostatus": "http://ostatus.org#",
|
|
"atomUri": "ostatus:atomUri",
|
|
"inReplyToAtomUri": "ostatus:inReplyToAtomUri",
|
|
"conversation": "ostatus:conversation",
|
|
"toot": "http://joinmastodon.org/ns#",
|
|
"Emoji": "toot:Emoji"
|
|
}],
|
|
"id": "http://mastodon.example.org/users/relay",
|
|
"type": "Application",
|
|
"invisible": true,
|
|
"following": "http://mastodon.example.org/users/admin/following",
|
|
"followers": "http://mastodon.example.org/users/admin/followers",
|
|
"inbox": "http://mastodon.example.org/users/admin/inbox",
|
|
"outbox": "http://mastodon.example.org/users/admin/outbox",
|
|
"preferredUsername": "admin",
|
|
"name": null,
|
|
"summary": "\u003cp\u003e\u003c/p\u003e",
|
|
"url": "http://mastodon.example.org/@admin",
|
|
"manuallyApprovesFollowers": false,
|
|
"publicKey": {
|
|
"id": "http://mastodon.example.org/users/relay#main-key",
|
|
"owner": "http://mastodon.example.org/users/relay",
|
|
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtc4Tir+3ADhSNF6VKrtW\nOU32T01w7V0yshmQei38YyiVwVvFu8XOP6ACchkdxbJ+C9mZud8qWaRJKVbFTMUG\nNX4+6Q+FobyuKrwN7CEwhDALZtaN2IPbaPd6uG1B7QhWorrY+yFa8f2TBM3BxnUy\nI4T+bMIZIEYG7KtljCBoQXuTQmGtuffO0UwJksidg2ffCF5Q+K//JfQagJ3UzrR+\nZXbKMJdAw4bCVJYs4Z5EhHYBwQWiXCyMGTd7BGlmMkY6Av7ZqHKC/owp3/0EWDNz\nNqF09Wcpr3y3e8nA10X40MJqp/wR+1xtxp+YGbq/Cj5hZGBG7etFOmIpVBrDOhry\nBwIDAQAB\n-----END PUBLIC KEY-----\n"
|
|
},
|
|
"attachment": [{
|
|
"type": "PropertyValue",
|
|
"name": "foo",
|
|
"value": "bar"
|
|
},
|
|
{
|
|
"type": "PropertyValue",
|
|
"name": "foo1",
|
|
"value": "bar1"
|
|
}
|
|
],
|
|
"endpoints": {
|
|
"sharedInbox": "http://mastodon.example.org/inbox"
|
|
},
|
|
"icon": {
|
|
"type": "Image",
|
|
"mediaType": "image/jpeg",
|
|
"url": "https://cdn.niu.moe/accounts/avatars/000/033/323/original/fd7f8ae0b3ffedc9.jpeg"
|
|
},
|
|
"image": {
|
|
"type": "Image",
|
|
"mediaType": "image/png",
|
|
"url": "https://cdn.niu.moe/accounts/headers/000/033/323/original/850b3448fa5fd477.png"
|
|
}
|
|
}
|