feat: origin checking on received Update activities

This commit is contained in:
Julian Lam
2024-01-30 12:11:10 -05:00
parent 0e59f3124e
commit 6930973d7a
2 changed files with 10 additions and 2 deletions

View File

@@ -281,5 +281,6 @@
"activitypub.invalid-id": "Unable to resolve the input id, likely as it is malformed.",
"activitypub.get-failed": "Unable to retrieve the specified resource.",
"activitypub.pubKey-not-found": "Unable to resolve public key, so payload verification cannot take place."
"activitypub.pubKey-not-found": "Unable to resolve public key, so payload verification cannot take place.",
"activitypub.origin-mismatch": "The received object's origin does not match the sender's origin"
}

View File

@@ -24,7 +24,14 @@ inbox.create = async (req) => {
};
inbox.update = async (req) => {
const { object } = req.body;
const { actor, object } = req.body;
// Origin checking
const actorHostname = new URL(actor).hostname;
const objectHostname = new URL(object.id).hostname;
if (actorHostname !== objectHostname) {
throw new Error('[[error:activitypub.origin-mismatch]]');
}
switch (object.type) {
case 'Note': {