mirror of
https://github.com/wekan/wekan.git
synced 2026-11-20 21:45:01 -05:00
AssignedBleed follow-up, GHSA-3cgr-47wm-9cc9. An assigned-only member
(isNormalAssignedOnly, isCommentAssignedOnly, isReadAssignedOnly) sees only
the cards assigned to them. 1a218ead02 applied that to the attachment API,
but six other paths asked only for board membership, which such a member
has:
- the /cdn/storage/attachments and /cfs/files/attachments downloads
(universalFileServer isAuthorizedForBoard) served any card's file;
- Attachments.protected, ostrio:files' own download check, likewise;
- the legacy /cfs/files/attachments route likewise;
- searchAttachmentDocumentText matched the extracted text of every card's
PDF/DOCX/XLSX/PPTX on the board and returned snippets with their
attachment and card ids - no id needed, and it supplied the ids for the
downloads;
- legacyBoardAttachments without a cardId published every legacy
attachment record of the board;
- linkedListCards published every card of the source list.
The downloads now also ask mayReadBoardAttachment(), which names the
refusing path in Admin Panel -> Problems (authz.assigned, medium: never
disables). The document search and the legacy publication are narrowed to
the member's cards (assignedOnlyCardIds); asking the publication for a card
not assigned to them is refused and recorded, as card details always pass
the open card. Linked-list cards take the source board's
assignedOnlyCardScope; searching and viewing a linked list are ordinary
use, so those are not recorded.
The board's own files - background (sidebar or API upload) and map image -
carry no card and are part of the board every member sees; they stay
readable, where the attachment API refused them to an assigned-only
member. Any other card-less file is still refused.
tests/assignedOnlyReads.test.cjs pins each path, the board-file rule and
the refusal source, and fails when any file in server/ or models/ that
serves attachment or document data lacks the rule without a stated
exemption. The Playwright spec checks both downloads refuse the hidden
card's file but not the member's own, that the search finds only the
member's card, and that the owner is unaffected. Four source guards that
pinned the old lines now pin the new ones.
Thanks to crypto-nidh and xet7 !
94 lines
5.1 KiB
JavaScript
94 lines
5.1 KiB
JavaScript
// #2809: linked whole lists (models/lib/linkedList.js).
|
|
import { Meteor } from 'meteor/meteor';
|
|
import { check } from 'meteor/check';
|
|
import { DDPRateLimiter } from 'meteor/ddp-rate-limiter';
|
|
import Boards from '/models/boards';
|
|
import Cards from '/models/cards';
|
|
import Lists from '/models/lists';
|
|
import { allowIsBoardMemberWithWriteAccess } from '/server/lib/utils';
|
|
import { canWriteInList } from '/server/lib/listPermissionGate';
|
|
|
|
const { isLinkedList, validLink } = require('/models/lib/linkedList');
|
|
const { assignedOnlyCardScope } = require('/models/lib/boardCardScope');
|
|
|
|
async function visibleBoard(userId, boardId) {
|
|
const board = boardId && await Boards.findOneAsync(boardId);
|
|
return board && !board.archived && typeof board.isVisibleBy === 'function' && board.isVisibleBy({ _id: userId }) ? board : null;
|
|
}
|
|
|
|
// The source list's cards, and its board's labels for the minicards - only
|
|
// to a subscriber who may see BOTH boards.
|
|
Meteor.publish('linkedListCards', async function (listId) {
|
|
check(listId, String);
|
|
if (!this.userId) return this.ready();
|
|
const list = await Lists.findOneAsync(listId);
|
|
if (!isLinkedList(list)) return this.ready();
|
|
const source = await visibleBoard(this.userId, list.linkedBoardId);
|
|
if (!(await visibleBoard(this.userId, list.boardId)) || !source) return this.ready();
|
|
// Only the cards the subscriber sees on the SOURCE board: an assigned-only
|
|
// member there gets their own cards (AssignedBleed, GHSA-3cgr-47wm-9cc9).
|
|
// Viewing a linked list is ordinary use, so nothing is logged.
|
|
return [
|
|
Cards.find({ boardId: list.linkedBoardId, listId: list.linkedListId, archived: false,
|
|
...(assignedOnlyCardScope(source, this.userId) || {}) }, { limit: 1000 }),
|
|
Boards.find({ _id: list.linkedBoardId }, { fields: { title: 1, slug: 1, labels: 1, permission: 1, members: 1, color: 1 } }),
|
|
];
|
|
});
|
|
|
|
Meteor.methods({
|
|
// The lists of a board the caller sees, for the "link a list" picker.
|
|
async linkableLists(boardId) {
|
|
check(boardId, String);
|
|
if (!this.userId) throw new Meteor.Error('not-authorized');
|
|
if (!(await visibleBoard(this.userId, boardId))) throw new Meteor.Error('not-authorized');
|
|
return Lists.find({ boardId, archived: { $ne: true }, linkedListId: { $exists: false } },
|
|
{ fields: { title: 1 }, sort: { sort: 1 }, limit: 500 }).fetchAsync();
|
|
},
|
|
|
|
// Make a linked list on `boardId` mirroring `sourceListId` of `sourceBoardId`.
|
|
async createLinkedList(input) {
|
|
check(input, { boardId: String, sourceBoardId: String, sourceListId: String });
|
|
if (!this.userId) throw new Meteor.Error('not-authorized');
|
|
const board = await Boards.findOneAsync(input.boardId);
|
|
if (!board || board.archived || !allowIsBoardMemberWithWriteAccess(this.userId, board)) throw new Meteor.Error('not-authorized');
|
|
if (!(await visibleBoard(this.userId, input.sourceBoardId))) throw new Meteor.Error('not-authorized');
|
|
const sourceList = await Lists.findOneAsync(input.sourceListId);
|
|
if (!validLink({ ...input, sourceList })) throw new Meteor.Error('linked-list-invalid');
|
|
const last = await Lists.findOneAsync({ boardId: board._id, archived: { $ne: true } }, { sort: { sort: -1 }, fields: { sort: 1 } });
|
|
return Lists.insertAsync({
|
|
title: sourceList.title || '',
|
|
boardId: board._id,
|
|
sort: last && Number.isFinite(last.sort) ? last.sort + 1 : 0,
|
|
type: 'linked',
|
|
linkedBoardId: input.sourceBoardId,
|
|
linkedListId: input.sourceListId,
|
|
});
|
|
},
|
|
|
|
// A card typed into a linked list goes to the source list, by the source
|
|
// board's rules.
|
|
async addCardToLinkedList(listId, title) {
|
|
check(listId, String);
|
|
check(title, String);
|
|
if (!this.userId) throw new Meteor.Error('not-authorized');
|
|
const list = await Lists.findOneAsync(listId);
|
|
if (!isLinkedList(list)) throw new Meteor.Error('not-found');
|
|
if (!(await visibleBoard(this.userId, list.boardId))) throw new Meteor.Error('not-authorized');
|
|
const source = await Boards.findOneAsync(list.linkedBoardId);
|
|
const sourceList = await Lists.findOneAsync({ _id: list.linkedListId, boardId: list.linkedBoardId, archived: { $ne: true } });
|
|
if (!source || source.archived || !sourceList) throw new Meteor.Error('not-found');
|
|
if (!(await canWriteInList(this.userId, source, sourceList._id))) throw new Meteor.Error('not-authorized');
|
|
const clean = title.replace(/\s+/g, ' ').trim().slice(0, 1000);
|
|
if (!clean) throw new Meteor.Error('linked-list-empty-title');
|
|
const swimlane = await source.getDefaultSwimlineAsync();
|
|
const last = await Cards.findOneAsync({ listId: sourceList._id, archived: false }, { sort: { sort: -1 }, fields: { sort: 1 } });
|
|
return Cards.insertAsync({ title: clean, boardId: source._id, listId: sourceList._id, swimlaneId: swimlane && swimlane._id,
|
|
sort: last && Number.isFinite(last.sort) ? last.sort + 1 : 0, type: 'cardType-card',
|
|
cardNumber: await source.getNextCardNumber(), userId: this.userId });
|
|
},
|
|
});
|
|
|
|
for (const name of ['createLinkedList', 'addCardToLinkedList', 'linkableLists']) {
|
|
DDPRateLimiter.addRule({ type: 'method', name, connectionId: () => true }, 20, 10000);
|
|
}
|