mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
feat: origin checking on received Update activities
This commit is contained in:
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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': {
|
||||
|
||||
Reference in New Issue
Block a user