Node.js based forum software built for the modern web
fix(security): reject array cid in createTopicFromPosts moderator gate
Julian Lam2be4c5c436bc
diff --git a/src/topics/fork.js b/src/topics/fork.jsindex db8e5ea85b..df8758a9d3 100644--- a/src/topics/fork.js+++ b/src/topics/fork.js@@ -35,6 +35,11 @@ module.exports = function (Topics) {if (!cid) {cid = await posts.getCidByPid(mainPid);}+ // A one-element array cid would make isModerator return a (truthy) array,+ // bypassing the isAdminOrMod gate below. Coerce to a scalar.+ if (Array.isArray(cid)) {+ cid = cid[0];+ }const [mainPost, isAdminOrMod] = await Promise.all([posts.getPostData(mainPid),