Skip to content

Node.js based forum software built for the modern web

feat: add domain blocklist check in activitypub middleware

Julian Lam8e5e208607a6
diff --git a/src/middleware/activitypub.js b/src/middleware/activitypub.js
index 0a8a89324d..86d316d7d7 100644
--- a/src/middleware/activitypub.js
+++ b/src/middleware/activitypub.js
@@ -76,6 +76,14 @@ middleware.assertPayload = helpers.try(async function (req, res, next) {
return res.sendStatus(403);
}
+ // Domain check against blocklists
+ const { hostname } = new URL(req.body.actor);
+ const isAllowed = await activitypub.blocklists.check(hostname);
+ if (!isAllowed) {
+ activitypub.helpers.log(`[middleware/activitypub] Blocked incoming activity from ${hostname} due to blocklist.`);
+ return res.sendStatus(403);
+ }
+
// Sanity-check payload schema
const required = ['id', 'type', 'actor', 'object'];
if (!required.every(prop => req.body.hasOwnProperty(prop))) {