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 !
103 lines
4.7 KiB
JavaScript
103 lines
4.7 KiB
JavaScript
import { Meteor } from 'meteor/meteor';
|
|
import { check, Match } from 'meteor/check';
|
|
import { ReactiveCache } from '/imports/reactiveCache';
|
|
import { getFeatureFlags } from '/models/lib/featureFlags';
|
|
import Boards from '/models/boards';
|
|
const { boardVisibilitySelectors } = require('/models/lib/boardVisibilitySelectors');
|
|
const { readableWithoutMembership } = require('/models/lib/boardPermission');
|
|
|
|
// True when this user may see this board: public, a member, or an ACTIVE
|
|
// organisation / team / email-domain share. Built from the same selectors the
|
|
// board publication uses, so the two cannot drift apart.
|
|
async function canSeeBoard(userId, board) {
|
|
if (!board) return false;
|
|
// #3249: public for anybody, 'instance' for a signed-in user.
|
|
if (readableWithoutMembership(board.permission, !!userId)) return true;
|
|
if (!userId) return false;
|
|
if (typeof board.hasMember === 'function' && board.hasMember(userId)) return true;
|
|
|
|
const user = await ReactiveCache.getUser(userId);
|
|
if (!user) return false;
|
|
const listOf = value => (typeof value === 'string' && value.length ? value.split(',') : []);
|
|
const orgIds = typeof user.orgIdsUserBelongs === 'function' ? listOf(user.orgIdsUserBelongs()) : [];
|
|
const teamIds = typeof user.teamIdsUserBelongs === 'function' ? listOf(user.teamIdsUserBelongs()) : [];
|
|
const emailDomains = typeof user.emailDomains === 'function' ? user.emailDomains() : [];
|
|
|
|
const visible = await Boards.findOneAsync({
|
|
_id: board._id,
|
|
$or: boardVisibilitySelectors({ userId, orgIds, teamIds, emailDomains, includePublic: true }),
|
|
}, { fields: { _id: 1 } });
|
|
return Boolean(visible);
|
|
}
|
|
|
|
Meteor.methods({
|
|
async watch(watchableType, id, level) {
|
|
check(watchableType, String);
|
|
check(id, String);
|
|
check(level, Match.OneOf(String, null));
|
|
|
|
// Admin Panel / Features / Notifications (#5820): the watch feature is
|
|
// disabled, so ignore any request to change a watch level.
|
|
if (getFeatureFlags().disableWatch) {
|
|
throw new Meteor.Error('error-watch-disabled');
|
|
}
|
|
|
|
const userId = this.userId;
|
|
|
|
let watchableObj = null;
|
|
let board = null;
|
|
if (watchableType === 'board') {
|
|
watchableObj = await ReactiveCache.getBoard(id);
|
|
if (!watchableObj) throw new Meteor.Error('error-board-doesNotExist');
|
|
board = watchableObj;
|
|
} else if (watchableType === 'list') {
|
|
watchableObj = await ReactiveCache.getList(id);
|
|
if (!watchableObj) throw new Meteor.Error('error-list-doesNotExist');
|
|
board = await watchableObj.board();
|
|
} else if (watchableType === 'card') {
|
|
watchableObj = await ReactiveCache.getCard(id);
|
|
if (!watchableObj) throw new Meteor.Error('error-card-doesNotExist');
|
|
board = await watchableObj.board();
|
|
} else {
|
|
throw new Meteor.Error('error-json-schema');
|
|
}
|
|
|
|
// MAY THIS USER SEE THE BOARD - which is not the same question as "is this
|
|
// user in board.members", and answering the second one is the bug behind
|
|
// "Silent does not respond. If we try to change it does not change. Nothing
|
|
// happens."
|
|
//
|
|
// A board is shared with people four ways: membership, an organisation, a
|
|
// team, and (since #5850) an email domain. Only the first puts anybody in
|
|
// `members`. Everyone reaching a board through one of the other three could
|
|
// open it, see the watch button, choose a level - and have this line throw
|
|
// error-board-notAMember, which the popup swallowed (see
|
|
// client/components/boards/boardHeader.js). Nothing changed and nothing was
|
|
// said, which is exactly how it was reported.
|
|
//
|
|
// The publications answer the same question with one shared builder
|
|
// (models/lib/boardVisibilitySelectors), and so does this: ask the database
|
|
// whether this board is among the ones this user may see. It is the same
|
|
// rule, so a watch can never be granted where the board itself is not.
|
|
if (!(await canSeeBoard(userId, board))) {
|
|
throw new Meteor.Error('error-board-notAMember');
|
|
}
|
|
// ...and on it, the card by the user's board role: an assigned-only member
|
|
// watches only their own cards (GHSA-r4gm-mjj9-g3x8). No view shows them
|
|
// another card's watch button, so this is an attempt.
|
|
if (watchableType === 'card' &&
|
|
!require('/models/lib/boardCardScope').assignedOnlyAllowsCard(board, userId, watchableObj)) {
|
|
try {
|
|
require('/server/lib/securityLog').record({
|
|
key: 'authz.assigned', action: 'blocked', source: 'watch:card', userId,
|
|
detail: 'Assigned-only member tried to watch a card not assigned to them.',
|
|
});
|
|
} catch (e) { /* logging must never break the guard */ }
|
|
throw new Meteor.Error('error-card-doesNotExist');
|
|
}
|
|
|
|
await watchableObj.setWatcher(userId, level);
|
|
return true;
|
|
},
|
|
});
|