Files
wekan/models/cardTextNotes.js
T
Lauri Ojansivu 4bd6a7f088 Dragging a checklist item on one's own board is no longer reported as a cross-board attack.
Dragging a checklist item within its card sets cardId and checklistId
to where the item already is. The ChecklistBleed deny rule
(GHSA-gv8h-5p3p-6hx7) checked only that the destination board was
writable, so for a comment-only member or a Worker - whose own board is
one they cannot write to - an ordinary drag tripped the high-severity
canary checklist-item.cross-board-move and named them in Admin Panel /
Problems / Security as if they had attacked another board.

The board the document is already on is no destination now. That board
is the one of its SOURCE CARD, which the allow rule decides on - not
the document's own denormalized boardId, as the reporter's patch read
it: the insert hooks kept a boardId the client sent, so an item on the
attacker's card could carry a victim board's id and would have passed
as staying while moved onto a victim card. Those hooks (checklists,
checklist items, and now text notes on the server) set boardId from the
card always. A move to another unwritable board, and an unknown
destination, are still denied and still reported.

Thanks to Raymond-Voogt and xet7 !

Fixes #6813.
2026-10-27 14:52:06 +02:00

125 lines
3.3 KiB
JavaScript

import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import { ReactiveCache } from '/imports/reactiveCache';
const { SimpleSchema } = require('/imports/simpleSchema');
const CardTextNotes = new Mongo.Collection('card_text_notes');
/**
* A markdown text note attached to a card (GitHub issue #595): a small,
* separate, editable block of markdown text a card can carry in addition to
* its own description, so a card is not limited to a single description
* field for everything it needs to say. Modeled on Checklists - a per-card
* collection of small named sub-documents - rather than on Attachments,
* because a text note is edited in place, not uploaded/downloaded.
*/
CardTextNotes.attachSchema(
new SimpleSchema({
boardId: {
/**
* the board ID, denormalized from the card so the board publication
* can publish text notes with a single reactive cursor filtered by
* boardId, the same pattern used by Checklists/CardComments/Attachments.
*/
type: String,
},
cardId: {
/**
* the ID of the card the text note is on
*/
type: String,
},
title: {
/**
* the title of the text note
*/
type: String,
defaultValue: '',
},
text: {
/**
* the markdown text of the note
*/
type: String,
optional: true,
defaultValue: '',
},
createdAt: {
/**
* creation date of the text note
*/
type: Date,
// eslint-disable-next-line consistent-return
autoValue() {
if (this.isInsert) {
return new Date();
} else if (this.isUpsert) {
return { $setOnInsert: new Date() };
} else {
this.unset();
}
},
},
modifiedAt: {
type: Date,
// eslint-disable-next-line consistent-return
autoValue() {
if (this.isInsert || this.isUpsert || this.isUpdate) {
return new Date();
} else {
this.unset();
}
},
},
userId: {
/**
* the ID of the user who created the text note
*/
type: String,
// eslint-disable-next-line consistent-return
autoValue() {
if (this.isInsert && !this.isSet) {
return this.userId;
}
},
},
}),
);
CardTextNotes.helpers({
card() {
return ReactiveCache.getCard(this.cardId);
},
user() {
return ReactiveCache.getUser(this.userId);
},
});
CardTextNotes.before.insert((userId, doc) => {
doc.createdAt = new Date();
if (!doc.userId) {
doc.userId = userId;
}
});
// #6813: on the server the board is ALWAYS the card's, not what the client
// sent - a text note on its own card could otherwise carry another board's id
// (published to that board, and mistaken for being on it).
if (Meteor.isServer) {
CardTextNotes.before.insert(async (userId, doc) => {
if (!doc.cardId) return;
const card = await ReactiveCache.getCard(doc.cardId);
if (card && card.boardId) doc.boardId = card.boardId;
});
}
if (Meteor.isServer) {
const { ensureIndex } = require('/server/lib/mongoStartup');
Meteor.startup(async () => {
await ensureIndex(CardTextNotes, { cardId: 1, createdAt: 1 });
await ensureIndex(CardTextNotes, { boardId: 1 });
});
}
export default CardTextNotes;