mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 04:49:41 -05:00
(CWE-284, CWE-639). WeKan boards are membership-scoped, but the DDP collection write policies for Cards, Lists and Swimlanes (`server/permissions/cards.js`, `server/permissions/lists.js`, `server/permissions/swimlanes.js`) authorized an update by checking only the CURRENT (pre-update) `boardId` of the document — i.e. the attacker's own source board — and never validated the NEW `boardId` supplied in the update modifier. Because every logged-in user can create a board where they are admin, an attacker could take a document they own and, in a single `/cards/update`, `/lists/update` or `/swimlanes/update` DDP call, `$set` its `boardId` (plus `swimlaneId`/`listId`) to a victim's private board: the allow rule saw the attacker's own source board, approved the write, and the document was relocated into a board the attacker is not a member of and cannot even read. This let an unprivileged user inject arbitrary cards/lists/swimlanes (attacker-controlled titles, descriptions, assignees, etc.) into any private board by id, defeating board-level access control. The REST API for the same operation (`PUT /api/boards/:boardId/lists/:listId/cards/:cardId` with `newBoardId`) was not affected because it correctly calls `Authentication.checkBoardWriteAccess(req.userId, newBoardId)` on the destination board; only the DDP allow/deny layer was vulnerable. Fixed by adding a `denyCrossBoardMove` helper in `server/lib/utils.js` and a `Cards.deny`/`Lists.deny`/ `Swimlanes.deny` `update` rule on each collection that rejects any update whose modifier `$set`s a `boardId` on which the caller does not have write access, so a cross-board move is only allowed into a destination board where the user is an active write-capable member. Affected Wekan v9.35 and earlier. Thanks to 0xzap, xet7 and Claude.
47 lines
1.9 KiB
JavaScript
47 lines
1.9 KiB
JavaScript
import Cards from '/models/cards';
|
|
import Boards from '/models/boards';
|
|
import { allowIsBoardMemberWithWriteAccess, denyCrossBoardMove } from '/server/lib/utils';
|
|
|
|
// Centralized update policy for Cards
|
|
// Security: deny any direct client updates to 'vote' fields; require write access otherwise
|
|
export const canUpdateCard = async function(userId, doc, fields) {
|
|
if (!userId) return false;
|
|
const fieldNames = fields || [];
|
|
// Block direct updates to voting fields; voting must go through Meteor method 'cards.vote'
|
|
if (fieldNames.some(f => typeof f === 'string' && (f === 'vote' || f.indexOf('vote.') === 0))) {
|
|
return false;
|
|
}
|
|
// Block direct updates to poker fields; poker must go through Meteor methods
|
|
if (fieldNames.some(f => typeof f === 'string' && (f === 'poker' || f.indexOf('poker.') === 0))) {
|
|
return false;
|
|
}
|
|
// ReadOnly users cannot edit cards
|
|
return allowIsBoardMemberWithWriteAccess(userId, await Boards.findOneAsync(doc.boardId));
|
|
};
|
|
|
|
Cards.allow({
|
|
async insert(userId, doc) {
|
|
// ReadOnly users cannot create cards
|
|
return allowIsBoardMemberWithWriteAccess(userId, await Boards.findOneAsync(doc.boardId));
|
|
},
|
|
async update(userId, doc, fields) {
|
|
return await canUpdateCard(userId, doc, fields);
|
|
},
|
|
async remove(userId, doc) {
|
|
// ReadOnly users cannot delete cards
|
|
return allowIsBoardMemberWithWriteAccess(userId, await Boards.findOneAsync(doc.boardId));
|
|
},
|
|
fetch: ['boardId'],
|
|
});
|
|
|
|
// Security (GHSA-gm7v-pc38-53jr): the allow rule above only checks write access
|
|
// on the card's SOURCE board, so a client could move a card into a private board
|
|
// it is not a member of by setting a new boardId. Deny any cross-board move where
|
|
// the caller lacks write access to the destination board.
|
|
Cards.deny({
|
|
async update(userId, doc, fieldNames, modifier) {
|
|
return await denyCrossBoardMove(userId, modifier);
|
|
},
|
|
fetch: [],
|
|
});
|