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 !
39 lines
2.6 KiB
JavaScript
39 lines
2.6 KiB
JavaScript
'use strict';
|
|
// Hall of Fame regression coverage: RuleButtonBleed.
|
|
const { test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const { buttonRuleAllowed, requireButtonRuleContext } = require('../models/lib/buttonRulePermission');
|
|
const { BOARD_ROLES, ROLE_FLAGS, roleCan } = require('../models/lib/boardRoleCapabilities');
|
|
const read = file => fs.readFileSync(path.join(__dirname, '..', file), 'utf8');
|
|
test('button rule requires write access and binds a supplied card to its board', () => {
|
|
for (const role of BOARD_ROLES) {
|
|
const member = { userId: 'u', isActive: true, [ROLE_FLAGS[role] || 'normal']: true };
|
|
const board = { _id: 'A', members: [member] };
|
|
// GHSA-r4gm-mjj9-g3x8: on a card, an assigned-only role decides by the
|
|
// card too - an unassigned card is refused, their own card is not.
|
|
const assignedOnly = /assigned-only/.test(role);
|
|
assert.equal(buttonRuleAllowed('u', board, 'c', { _id: 'c', boardId: 'A' }), roleCan(role, 'write') && !assignedOnly, role);
|
|
assert.equal(buttonRuleAllowed('u', board, 'c', { _id: 'c', boardId: 'A', assignees: ['u'] }), roleCan(role, 'write'), role);
|
|
assert.equal(buttonRuleAllowed('u', board, undefined, undefined), roleCan(role, 'write'), 'board button remains supported');
|
|
assert.equal(buttonRuleAllowed('u', board, 'c', { _id: 'c', boardId: 'B' }), false);
|
|
assert.equal(buttonRuleAllowed('u', board, 'missing', null), false);
|
|
assert.equal(buttonRuleAllowed(null, board, undefined, undefined), false);
|
|
}
|
|
assert.throws(() => requireButtonRuleContext('u', null, 'c', null, { Error: class extends Error {} }), 'logger failure cannot bypass refusal');
|
|
});
|
|
test('negative: method and shared action dispatcher both enforce the manual context', () => {
|
|
const method = read('server/rulesButton.js');
|
|
const at = method.indexOf(" async 'rules.runButton'");
|
|
const body = method.slice(at, method.indexOf(' // Create a rule', at));
|
|
assert.doesNotMatch(body, /\.hasMember\(/);
|
|
assert.match(body, /requireButtonRuleContext\(this.userId, board, cardId, card, Meteor\)/);
|
|
assert.ok(body.indexOf('requireButtonRuleContext') < body.indexOf('RulesHelper.performAction'));
|
|
const helper = read('server/rulesHelper.js');
|
|
const actionAt = helper.indexOf(' async performAction(');
|
|
const guardAt = helper.indexOf('requireButtonRuleContext(activity.userId', actionAt);
|
|
assert.ok(guardAt > actionAt && guardAt < helper.indexOf('const boardLevelActions', actionAt));
|
|
assert.match(helper.slice(actionAt, guardAt), /activity.activityType === 'button'/);
|
|
});
|