Files
wekan/server/lib/boardRepointGuard.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

34 lines
1.7 KiB
JavaScript

// RepointBleed: Triggers, Actions, Rules and Integrations are allowed to a
// board admin of the document's board - the board the document is on BEFORE
// the update. Nothing stopped the update itself from changing boardId, so an
// admin of their own board could move a rule trigger to another board, to '*'
// (every board) or unset it, and a webhook integration onto a private board -
// and receive that board's activity, or mail its cards to themselves. No client
// code changes these documents' boardId, so a change is an attempt.
// Pure apart from the record: tested by tests/repointBleed.test.cjs.
// Does this update write boardId - by $set/$unset/$inc/... or as the target of
// a $rename?
export function changesBoardId(fieldNames, modifier, fields = ['boardId']) {
if (Array.isArray(fieldNames) && fieldNames.some(name => fields.includes(name))) return true;
const rename = modifier && modifier.$rename;
return !!(rename && typeof rename === 'object' && Object.values(rename).some(name => fields.includes(name)));
}
// A deny rule for a collection whose documents belong to one board. `fields`
// names what ties a document to its board (and to its parent on the board).
export function denyBoardRepoint(collectionName, fields = ['boardId']) {
return {
update(userId, doc, fieldNames, modifier) {
if (!changesBoardId(fieldNames, modifier, fields)) return false;
try {
require('/server/lib/securityLog').record({
key: 'authz.repoint', action: 'blocked', source: `ddp:${collectionName}.update`, userId,
detail: `Tried to move a ${collectionName} document from board ${doc && doc.boardId} to another board.`,
});
} catch (e) { /* logging must never break the guard */ }
return true;
},
};
}