mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 04:49:41 -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 !
111 lines
6.8 KiB
JavaScript
111 lines
6.8 KiB
JavaScript
'use strict';
|
|
const { test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const vm = require('node:vm');
|
|
function fixture({ load = async () => {}, translate = (key, params, language) => `${language}:${params.card}`, member = true, user = true } = {}) {
|
|
let language = 'fi', method, stored = null;
|
|
const requests = [], writes = [], translations = [];
|
|
const context = { structuredClone, process: { env: {} },
|
|
Meteor: { methods: methods => { method = methods.outgoingWebhooks; },
|
|
setTimeout: () => { throw new Error('preparation must not set echo locks'); } },
|
|
check() {}, Integrations: { Const: { TWOWAY: 'two-way' } },
|
|
CardComments: { direct: { updateAsync: async (...args) => writes.push(args) } },
|
|
ReactiveCache: { getUser: async () => user ? { getLanguage: () => language } : null,
|
|
// HookBleed: delivery builds the request from the STORED integration.
|
|
getIntegration: async () => stored, getBoard: async () => ({ hasMember: () => member }),
|
|
getCurrentSetting: async () => ({}),
|
|
getCard: async id => (id === 'card' ? { _id: 'card', boardId: 'board', listId: 'list' } : null) },
|
|
TAPi18n: { ensureLanguageLoaded: load, __: (...args) => { translations.push(args); return translate(...args); } },
|
|
// The senders call webhookFetch: fetchSafe off Sandstorm (server/sandstormEgress.js).
|
|
webhookFetch: async (url, request) => { requests.push({ url, ...request }); return { status: 200 }; },
|
|
// #3695: the payload builder outgoing.js imports (stripped below).
|
|
...require('../models/lib/webhookPayload'), ...require('../models/lib/notificationDelivery'),
|
|
// GHSA-r4gm-mjj9-g3x8: the card-opened notification asks the card rule.
|
|
...require('../models/lib/boardCardScope'),
|
|
};
|
|
const source = fs.readFileSync(require.resolve('../server/notifications/outgoing.js'), 'utf8')
|
|
.replace(/^import .*;\n/gm, '').replace(/^export /gm, '');
|
|
vm.runInNewContext(source, context);
|
|
return { prepare: context.prepareOutgoingWebhook,
|
|
// Ordinary use: the stored integration is the one the caller names.
|
|
send: (input, { storedIntegration = structuredClone(input.integration), connection = null } = {}) => {
|
|
stored = storedIntegration;
|
|
return method.call({ userId: 'actor', connection, unblock() {} }, input.integration, input.description, input.params);
|
|
}, requests, writes, translations,
|
|
language: value => { language = value; } };
|
|
}
|
|
const input = type => ({ actorId: 'actor', description: 'act-test',
|
|
integration: { boardId: 'board', url: 'https://example.test/hook', token: 'old-token', type },
|
|
params: { user: 'Person', card: 'Original', url: 'https://example.test/card', customFieldValue: { nested: [0, false, null] }, commentId: 'comment', comment: 'Before' } });
|
|
test('preparation freezes nested parameters, endpoint, token and language across asynchronous loading', async () => {
|
|
let entered, release;
|
|
const waiting = new Promise(resolve => { entered = resolve; });
|
|
const gate = new Promise(resolve => { release = resolve; });
|
|
const loaded = [];
|
|
const f = fixture({ load: async language => { loaded.push(language); entered(); await gate; } });
|
|
const original = input('outgoing');
|
|
const pending = f.prepare(original);
|
|
await waiting;
|
|
original.params.card = 'Changed'; original.params.customFieldValue.nested[0] = 42;
|
|
original.integration.url = 'https://changed.test'; original.integration.token = 'new-token';
|
|
f.language('de'); release();
|
|
const prepared = await pending;
|
|
assert.equal(prepared.url, 'https://example.test/hook');
|
|
assert.equal(prepared.headers['X-Wekan-Token'], 'old-token');
|
|
assert.equal(prepared.language, 'fi'); assert.deepEqual(loaded, ['fi']);
|
|
const body = JSON.parse(prepared.body);
|
|
assert.equal(body.text, 'Person fi:"Original"\nhttps://example.test/card');
|
|
assert.deepEqual(body.customFieldValue, { nested: [0, false, null] });
|
|
assert.equal(f.requests.length, 0); assert.equal(f.writes.length, 0);
|
|
});
|
|
test('ordinary delivery sends precisely the prepared wire payload; two-way preparation has no lock or writes', async () => {
|
|
for (const type of ['outgoing', 'two-way']) {
|
|
const f = fixture(), data = input(type);
|
|
if (type === 'two-way') delete data.params.commentId;
|
|
const prepared = await f.prepare(data);
|
|
assert.equal(f.requests.length, 0); assert.equal(f.writes.length, 0);
|
|
await f.send(data);
|
|
assert.equal(f.requests.length, 1);
|
|
assert.equal(f.requests[0].body, prepared.body);
|
|
assert.equal(f.requests[0].url, prepared.url);
|
|
assert.deepEqual(structuredClone(f.requests[0].headers), structuredClone(prepared.headers));
|
|
}
|
|
const f = fixture();
|
|
const prepared = await f.prepare(input('two-way'));
|
|
assert.equal(JSON.parse(prepared.body).commentId, 'comment');
|
|
assert.equal(f.requests.length, 0); assert.equal(f.writes.length, 0);
|
|
});
|
|
test('suppression, missing user, denied membership and preparation failure never send', async () => {
|
|
for (const options of [{ translate: () => '-' }, { user: false }]) {
|
|
const f = fixture(options);
|
|
assert.equal(await f.prepare(input('outgoing')), null);
|
|
await f.send(input('outgoing')); assert.equal(f.requests.length, 0);
|
|
}
|
|
const denied = fixture({ member: false });
|
|
await denied.send(input('outgoing')); assert.equal(denied.requests.length, 0);
|
|
const broken = fixture({ load: async () => { throw new Error('load failed'); } });
|
|
await assert.rejects(broken.prepare(input('outgoing')), /load failed/);
|
|
await assert.rejects(broken.send(input('outgoing')), /load failed/);
|
|
assert.equal(broken.requests.length, 0);
|
|
});
|
|
|
|
// HookBleed (2026-10-02): the request came from the CALLER's integration
|
|
// object, description and params, so any member could post arbitrary text to
|
|
// the board's chat webhook as WeKan, or turn a one-way hook two-way.
|
|
test('a client cannot forge what a board webhook sends', async () => {
|
|
const f = fixture();
|
|
const forged = input('two-way');
|
|
forged.description = 'act-anything';
|
|
// A stored ONE-way hook; the caller claims two-way and a message of its own.
|
|
await f.send(forged, { storedIntegration: { boardId: 'board', url: 'https://example.test/hook', token: 'stored', type: 'outgoing' }, connection: {} });
|
|
assert.equal(f.requests.length, 0, 'only the card-opened notification may come from a client');
|
|
// The card-opened notification is sent - built from the stored hook and the
|
|
// card, not from what the client sent.
|
|
const opened = { ...input('two-way'), description: 'CardSelected', params: { cardId: 'card', user: 'Somebody else', text: 'forged text' } };
|
|
await f.send(opened, { storedIntegration: { boardId: 'board', url: 'https://example.test/hook', token: 'stored', type: 'outgoing' }, connection: {} });
|
|
assert.equal(f.requests.length, 1);
|
|
assert.equal(f.requests[0].headers['X-Wekan-Token'], 'stored');
|
|
assert.doesNotMatch(f.requests[0].body, /forged text|Somebody else/);
|
|
});
|