mirror of
https://github.com/wekan/wekan.git
synced 2026-11-20 15:45:01 -05:00
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 !
47 lines
1.9 KiB
JavaScript
47 lines
1.9 KiB
JavaScript
import Cards from '/models/cards';
|
|
import CardTextNotes from '/models/cardTextNotes';
|
|
import { denyCrossBoardMoveByCard, sourceBoardOfCardChild } from '/server/lib/utils';
|
|
import { tripCanaryDeny } from '/server/lib/canary';
|
|
import { denyForgedCardChildInsert } from '/server/lib/cardChildStamp';
|
|
import { canEditCardOrLinkedCard } from '/server/lib/linkedCardPermission';
|
|
|
|
CardTextNotes.allow({
|
|
async insert(userId, doc) {
|
|
// ReadOnly users cannot create text notes
|
|
return await canEditCardOrLinkedCard(userId, await Cards.findOneAsync(doc.cardId));
|
|
},
|
|
async update(userId, doc) {
|
|
// ReadOnly users cannot edit text notes
|
|
return await canEditCardOrLinkedCard(userId, await Cards.findOneAsync(doc.cardId));
|
|
},
|
|
async remove(userId, doc) {
|
|
// ReadOnly users cannot delete text notes
|
|
return await canEditCardOrLinkedCard(userId, await Cards.findOneAsync(doc.cardId));
|
|
},
|
|
fetch: ['userId', 'cardId'],
|
|
});
|
|
|
|
// Same defense-in-depth as Checklists (GHSA-gv8h-5p3p-6hx7): the allow rule
|
|
// above only checks write access on the text note's SOURCE card/board, so a
|
|
// DDP client could move a text note into a private board it is not a member
|
|
// of by $set-ting a new cardId. Deny any move whose destination board the
|
|
// caller cannot write to.
|
|
CardTextNotes.deny({
|
|
async update(userId, doc, fieldNames, modifier) {
|
|
// #6813: the source board from the source card, as the allow rule.
|
|
if (!(await denyCrossBoardMoveByCard(userId, modifier, await sourceBoardOfCardChild(doc)))) return false;
|
|
return tripCanaryDeny('cardTextNote.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).
|
|
CardTextNotes.deny({
|
|
async insert(userId, doc) {
|
|
return await denyForgedCardChildInsert(doc, { source: 'ddp:card-text-note-insert' });
|
|
},
|
|
fetch: [],
|
|
});
|