Files
wekan/server/permissions/checklistItems.js
T
Lauri Ojansivu 51111e1958 StampBleed and UploadBleed: documents on one's own card stamped with another board, and unauthorized attachment uploads.
StampBleed (found reviewing the patch for #6813): checklists, checklist
items and text notes carry a denormalized boardId, by which the board
publication publishes them, and items a checklistId, by which a
checklist draws them. The insert allow rules check write access on the
document's card only, and the server's insert hooks kept a boardId the
client sent. So a member of any board could insert, on their own card,
a document stamped with a private board's id - published to that
board's members - and an item with that board's checklist id, drawn in
it. 4bd6a7f088 made the server take boardId from the card; now the
forged insert is refused outright and recorded, for those three and for
a direct attachment insert with a foreign meta.boardId. WeKan's own
client never sends a mismatch.

UploadBleed: Meteor-Files' upload pipeline (_FilesCollectionStart_
attachments / Write and its HTTP twin) inserts the stored attachment
SERVER-side, so the allow rules were never asked, and the attachments'
onBeforeUpload only cleaned the file name: any DDP client, signed in or
not, could put a file on any card of any board - published to its
members with an addAttachment activity and its notifications - and the
admin's uploads-blocked switch was skipped too. The upload is
authorized on every chunk now: signed in, allowed to edit the card (or
write the board, for a background or map image), uploads not blocked,
and a card attachment's board, list and swimlane are its card's.

Both are recorded in Admin Panel / Problems (authz.card-child-stamp,
authz.attachment-upload), once per upload. tests/stampBleed.test.cjs and
tests/uploadBleed.test.cjs run the real decisions, and fail on a card
child with no insert board check or a FilesCollection without a server
upload check; upload-stamp-bleed.e2e.js attacks the running server.

Thanks to xet7 !
2026-10-27 15:38:58 +02:00

75 lines
3.5 KiB
JavaScript

import Boards from '/models/boards';
import Cards from '/models/cards';
import ChecklistItems from '/models/checklistItems';
import { denyCrossBoardMoveByChecklistItem, sourceBoardOfCardChild } from '/server/lib/utils';
import { tripCanaryDeny } from '/server/lib/canary';
import { denyForgedCardChildInsert } from '/server/lib/cardChildStamp';
import { canEditCardOrLinkedCard } from '/server/lib/linkedCardPermission';
const { workerMayToggleChecklistItem } = require('/models/lib/workerChecklistItemToggle');
ChecklistItems.allow({
async insert(userId, doc) {
// ReadOnly users cannot create checklist items
return await canEditCardOrLinkedCard(userId, await Cards.findOneAsync(doc.cardId));
},
// wekan/wekan#3307: a Worker cannot edit or delete a checklist item, but may
// still CHECK/UNCHECK it - the same field-level carve-out workerCardWrite.js
// gives a Worker on a card (see models/lib/workerChecklistItemToggle.js).
async update(userId, doc, fieldNames, modifier) {
const card = await Cards.findOneAsync(doc.cardId);
// #6798: without recording first - a Worker checking an item is ALLOWED
// below, and a recorded refusal here disabled the Worker's account
// (server/permissions/cards.js canUpdateCard).
if (await canEditCardOrLinkedCard(userId, card, undefined, { recordDenial: false })) {
return true;
}
if (workerMayToggleChecklistItem(userId, modifier)) {
const board = await Boards.findOneAsync(doc.boardId);
if (board && board.hasWorker(userId)) return true;
}
// Refused after all: ask again, recording the denial as before.
return await canEditCardOrLinkedCard(userId, card);
},
async remove(userId, doc) {
// ReadOnly users cannot delete checklist items
return await canEditCardOrLinkedCard(userId, await Cards.findOneAsync(doc.cardId));
},
fetch: ['userId', 'cardId', 'boardId'],
});
// Security (GHSA-gv8h-5p3p-6hx7): the allow rule above only checks write access
// on the item's SOURCE card/board, so a DDP client could move a checklist item
// into a private board it is not a member of by $set-ting a new cardId or
// checklistId (boardId is then denormalized from the destination card). Deny any
// move whose destination board the caller cannot write to.
// #1618: the person responsible for an item must be an active member of its
// board (models/lib/checklistItemSchedule.js).
ChecklistItems.deny({
async update(userId, doc, fieldNames, modifier) {
const set = modifier && modifier.$set;
if (!set || !Object.prototype.hasOwnProperty.call(set, 'assigneeId')) return false;
const { mayBeAssigned } = require('/models/lib/checklistItemSchedule');
return !mayBeAssigned(await Boards.findOneAsync(doc.boardId), set.assigneeId);
},
fetch: ['boardId'],
});
ChecklistItems.deny({
async update(userId, doc, fieldNames, modifier) {
// #6813: the source board from the source card, as the allow rule.
if (!(await denyCrossBoardMoveByChecklistItem(userId, modifier, await sourceBoardOfCardChild(doc)))) return false;
return tripCanaryDeny('checklist-item.cross-board-move', { userId });
},
fetch: ['cardId'],
});
// StampBleed: an insert on one's own card stamped with another board's id
// (or, for an item, another card's checklist) is refused and recorded
// (server/lib/cardChildStamp.js).
ChecklistItems.deny({
async insert(userId, doc) {
return await denyForgedCardChildInsert(doc, { source: 'ddp:checklist-item-insert', checklist: true });
},
fetch: [],
});