Skip to content

Node.js based forum software built for the modern web

fix(activitypub): reject POST requests without HTTP signature header

Julian Lamc4b9d03b4743
diff --git a/src/middleware/activitypub.js b/src/middleware/activitypub.js
index 2f3b8c207e..ed6285912f 100644
--- a/src/middleware/activitypub.js
+++ b/src/middleware/activitypub.js
@@ -55,8 +55,12 @@ middleware.verify = async function (req, res, next) {
}
activitypub.helpers.log('[middleware/activitypub] HTTP signature verification passed.');
+ } else if (req.method === 'POST') {
+ // HTTP Signatures are mandatory for POST (ActivityPub S2S spec)
+ activitypub.helpers.log('[middleware/activitypub] HTTP signature required for POST but not present.');
+ return res.sendStatus(401);
} else {
- activitypub.helpers.log('[middleware/activitypub] HTTP signature verification skipped.');
+ activitypub.helpers.log('[middleware/activitypub] HTTP signature verification skipped (GET).');
}
next();
};