mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
AssignedBleed follow-up, GHSA-r4gm-mjj9-g3x8. An assigned-only member (isNormalAssignedOnly, isCommentAssignedOnly, isReadAssignedOnly, and custom roles through those flags) sees only the cards assigned to them. The Board Email View checked board.isVisibleBy() alone, so it published the title, description and email metadata of every card in a list or label, counted them, and searched them. It now merges assignedOnlyCardScope into its folder and search selector for the page and the count, and a reply on another card is refused. An audit of every path that returns or changes a card found the same shape - "a member of the board, so every card of it" - elsewhere, all fixed here: - reads: the board publication's ancestor cards, linked source cards with their subtasks and dependency targets, and comment reactions; All Boards tile counts; a board's activities from linked boards; the Chat view and the All Boards feed, which also let card MEMBERS through (assignees is the rule); My Attachments' card; GET /api/user/cards; position history of a card; the cross-board subtask picker; Scrum rollover counts; and the notification publications, which kept sending the full documents of cards named in old notifications - also to members removed from the board; - writes on a card the member cannot see: the canonical canEditCardOrLinkedCard / editableCardIds (every Cards.allow update, checklists, items, attachments, text notes, custom fields, the shared description, card methods) now ask the card - the role's `write` is a board answer, and the card is read when a caller passed it without assignees; DDP and REST comments, button rules on a card, checklist moves, issue state, watching, the card-opened webhook, moveBoardObjects, moveSwimlane and attachment moves; - REST writes: checkBoardWriteAccess refuses assigned-only members, as checkBoardAccess already does for reads - those routes act on any card, list or swimlane by id. The GHSA-f396 canary still fires for a role without the write capability. A refusal no view would produce is recorded under AssignedBleed in Admin Panel -> Problems (authz.assigned, medium: never disables); opening a view, searching and REST calls are narrowed or refused without a record. tests/boardRoleViews.test.cjs runs the Email View selector, pins every path above, and fails when any server file that serves card data has no role rule and no stated exemption; the "assignee or card member" rule is rejected anywhere in server/ and models/. server/lib/tests/editableCardIds adds an assigned-only case for both edit checks (meteor test; not run here). Seven guards that pinned the old lines now pin the new ones. Thanks to crypto-nidh, binary-lover and xet7 !
74 lines
4.2 KiB
JavaScript
74 lines
4.2 KiB
JavaScript
// #1931: an existing card from ANOTHER board as a subtask, for a user who may
|
|
// write both boards. The same-board picker works from the open board's cards;
|
|
// a card of another board is looked up and attached here, with every check
|
|
// on the server: write access to the parent's and the child's board, no loop
|
|
// through any parent, and only an ordinary card.
|
|
import { Meteor } from 'meteor/meteor';
|
|
import { check, Match } from 'meteor/check';
|
|
import { DDPRateLimiter } from 'meteor/ddp-rate-limiter';
|
|
import Boards from '/models/boards';
|
|
import Cards from '/models/cards';
|
|
import { allowIsBoardMemberWithWriteAccess } from '/server/lib/utils';
|
|
import { canEditCardOrLinkedCard } from '/server/lib/linkedCardPermission';
|
|
const { assignedOnlyCardScope } = require('/models/lib/boardCardScope');
|
|
|
|
const { cardParentIds, withParentAdded, collectAllAncestorIds, wouldCreateParentCycle } = require('/models/lib/cardParents');
|
|
|
|
const NOT_ATTACHABLE = ['template-card', 'cardType-linkedCard', 'cardType-linkedBoard'];
|
|
|
|
async function writableBoard(userId, boardId) {
|
|
const board = boardId && await Boards.findOneAsync(boardId);
|
|
return board && !board.archived && allowIsBoardMemberWithWriteAccess(userId, board) ? board : null;
|
|
}
|
|
|
|
Meteor.methods({
|
|
// Cards of `boardId` the caller may attach under `parentCardId`.
|
|
async crossBoardSubtaskCandidates(parentCardId, boardId, term) {
|
|
check(parentCardId, String);
|
|
check(boardId, String);
|
|
check(term, Match.Optional(String));
|
|
if (!this.userId) throw new Meteor.Error('not-authorized');
|
|
const parent = await Cards.findOneAsync(parentCardId, { fields: { boardId: 1, parentId: 1, parentIds: 1, assignees: 1, listId: 1 } });
|
|
const target = await writableBoard(this.userId, boardId);
|
|
// Board roles apply here as in every view (GHSA-r4gm-mjj9-g3x8): the parent
|
|
// is a card the caller may edit, and the candidates are only the cards
|
|
// they see on the target board - an assigned-only member, their own.
|
|
if (!parent || !(await writableBoard(this.userId, parent.boardId)) || !target ||
|
|
!(await canEditCardOrLinkedCard(this.userId, parent))) {
|
|
throw new Meteor.Error('not-authorized');
|
|
}
|
|
const ancestors = await collectAllAncestorIds(cardParentIds(parent),
|
|
ids => Cards.find({ _id: { $in: ids } }, { fields: { parentId: 1, parentIds: 1 } }).fetchAsync());
|
|
const selector = { boardId, archived: false, type: { $nin: NOT_ATTACHABLE },
|
|
_id: { $nin: [parentCardId, ...ancestors] }, parentId: { $ne: parentCardId }, parentIds: { $ne: parentCardId },
|
|
...(assignedOnlyCardScope(target, this.userId) || {}) };
|
|
const q = String(term || '').trim().slice(0, 100);
|
|
if (q) selector.title = { $regex: q.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), $options: 'i' };
|
|
return Cards.find(selector, { fields: { title: 1 }, sort: { sort: 1 }, limit: 50 }).fetchAsync();
|
|
},
|
|
|
|
async addCrossBoardSubtask(parentCardId, childCardId) {
|
|
check(parentCardId, String);
|
|
check(childCardId, String);
|
|
if (!this.userId) throw new Meteor.Error('not-authorized');
|
|
const parent = await Cards.findOneAsync(parentCardId);
|
|
const child = await Cards.findOneAsync(childCardId);
|
|
if (!parent || !child || child.archived || NOT_ATTACHABLE.includes(child.type)) throw new Meteor.Error('not-found');
|
|
// Attaching changes the child and adds to the parent: both are cards the
|
|
// caller may edit, which for an assigned-only member means their own.
|
|
if (!(await writableBoard(this.userId, parent.boardId)) || !(await writableBoard(this.userId, child.boardId)) ||
|
|
!(await canEditCardOrLinkedCard(this.userId, parent)) || !(await canEditCardOrLinkedCard(this.userId, child))) {
|
|
throw new Meteor.Error('not-authorized');
|
|
}
|
|
const ancestors = await collectAllAncestorIds(cardParentIds(parent),
|
|
ids => Cards.find({ _id: { $in: ids } }, { fields: { parentId: 1, parentIds: 1 } }).fetchAsync());
|
|
if (wouldCreateParentCycle(child._id, parent._id, ancestors)) throw new Meteor.Error('subtask-cycle');
|
|
await Cards.updateAsync(child._id, { $set: withParentAdded(child, parent._id) });
|
|
return true;
|
|
},
|
|
});
|
|
|
|
for (const name of ['crossBoardSubtaskCandidates', 'addCrossBoardSubtask']) {
|
|
DDPRateLimiter.addRule({ type: 'method', name, connectionId: () => true }, 30, 10000);
|
|
}
|