Skip to content

Node.js based forum software built for the modern web

fix: update signature parsing logic to handle values with equal signs in them, closes #12538

Julian Lam596a5e4ba29b
diff --git a/src/middleware/activitypub.js b/src/middleware/activitypub.js
index 0adad036b6..247726f38e 100644
--- a/src/middleware/activitypub.js
+++ b/src/middleware/activitypub.js
@@ -76,7 +76,10 @@ middleware.validate = async function (req, res, next) {
await activitypub.actors.assert(actor);
const compare = await db.getObjectField(`userRemote:${actor}:keys`, 'id');
const { signature } = req.headers;
- const keyId = new Map(signature.split(',').filter(Boolean).map(v => v.split('='))).get('keyId');
+ const keyId = new Map(signature.split(',').filter(Boolean).map((v) => {
+ const index = v.indexOf('=');
+ return [v.substring(0, index), v.slice(index + 1)];
+ })).get('keyId');
if (`"${compare}"` !== keyId) {
winston.verbose('[middleware/activitypub] Key ownership cross-check failed.');
return res.sendStatus(403);