Files
wekan/server/permissions/cardCommentReactions.js
T
Lauri Ojansivu f02da1bfd2 Fix RepointBleed: board-owned rule, webhook and custom-field documents cannot be moved to another board.
Triggers, Actions, Rules and Integrations were allowed to a board admin of the
board the document was on BEFORE an update; nothing refused the update itself
changing boardId. Any registered user, admin of a board they created, could
move a rule trigger to '*' or unset its board - which the rule matcher matched
on every board - and have a send-email action mail them cards, comments and
attachments from every private board; or move a webhook integration onto a
private board and receive its activity, or rewrite its comments through a
two-way hook. Custom fields accepted a board list if the caller could write to
ANY board in it, so a field could be planted on (or pulled from) a board
without access; comment reactions could be moved onto another comment.

A shared deny rule now refuses any client update that changes those
documents' board, custom fields need write access on every board they are put
on or taken off, and the rule matcher runs a rule only for activity on its own
board. Refusals record RepointBleed in Admin Panel -> Problems (high: no client
changes these fields). Unit, negative (every board-owned permissions file) and
browser tests.

Thanks to xet7 !
2026-10-02 10:34:38 +03:00

51 lines
2.5 KiB
JavaScript

import CardCommentReactions from '/models/cardCommentReactions';
import Boards from '/models/boards';
import { allowIsBoardMemberCommentOnly } from '/server/lib/utils';
const { denyForeignReactionChange } = require('/models/lib/reactionOwnership');
import { tripCanaryDeny } from '/server/lib/canary';
import { denyBoardRepoint } from '/server/lib/boardRepointGuard';
// Reacting to a comment is a form of commenting, so it follows the same rule as
// CardComments.insert: members who may comment (Normal / Comment-only) are
// allowed, but ReadOnly / No-comments members are not. Previously this used bare
// allowIsBoardMember, letting read-only members add/remove reactions the UI
// hides from them (read-only-write privilege escalation class).
CardCommentReactions.allow({
async insert(userId, doc) {
return allowIsBoardMemberCommentOnly(userId, await Boards.findOneAsync(doc.boardId));
},
async update(userId, doc) {
return allowIsBoardMemberCommentOnly(userId, await Boards.findOneAsync(doc.boardId));
},
async remove(userId, doc) {
return allowIsBoardMemberCommentOnly(userId, await Boards.findOneAsync(doc.boardId));
},
fetch: ['boardId'],
});
// Being allowed to react is not being allowed to react AS SOMEBODY ELSE.
//
// The rule above is board membership and nothing more, and the whole reaction
// list is one field - so a member could `$set` `reactions` to anything: add a
// colleague's userId to a reaction they never made, or remove one they did.
// Same shape as GHSA-pqr4-rxgp-hv2m (REST comment delete): a per-user object
// gated only by "are you on this board". It is integrity rather than
// confidentiality - reactions are visible to the whole board already - but it
// puts words in another person's mouth.
//
// `toggleReaction()` only ever touches Meteor.userId(), so no legitimate client
// sends anything else. Refuse an update that changes any OTHER user's presence
// in any reaction, and refuse the modifier forms ($push/$pull/dotted paths) that
// cannot be checked this way and that no client uses.
CardCommentReactions.deny({
update(userId, doc, fieldNames, modifier) {
if (!denyForeignReactionChange(userId, doc, modifier)) return false;
return tripCanaryDeny('reaction.foreign', { userId });
},
fetch: ['reactions'],
});
// RepointBleed: the allow rule decides by the reaction's board; it may not be
// moved to another board or onto another comment.
CardCommentReactions.deny(denyBoardRepoint('cardCommentReactions', ['boardId', 'cardCommentId']));