mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
A low-privilege (comment-only / read-only) board member could escalate to
board admin and take over a private board via the board 'sort' collection
allow rule. To support drag-to-reorder, a second Boards.allow({ update })
rule returned true for any board member whenever the update touched the
'sort' field. Meteor applies the WHOLE modifier once any allow rule approves
and no deny rule rejects, and does not scope the approving rule to the field
that satisfied it. Because canUpdateBoardSort only checked that 'sort' was
AMONG the modified fields, a restricted member could smuggle arbitrary board
mutations (members, permission, title) into the same $set as 'sort' in one
DDP Boards.update call, making themselves admin, flipping the private board
to public, and evicting the legitimate owner. The last-admin deny rule only
inspected $pull, so a wholesale $set of the members array bypassed it.
Fix: restrict canUpdateBoardSort so the sort-reorder rule approves an update
only when 'sort' is the sole modified field. Defense in depth: the last-admin
deny rule now also rejects a $set rewrite of the members array that would
drop the last active admin. Regression test covers the multi-field smuggling
case. The legitimate All Boards drag-reorder is unaffected: it persists order
per-user in profile.boardSortIndex, not in the board document.
CVSS:3.1 8.8 High (AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H), CWE-863, CWE-269.
Thanks to 5ud0 / Tarmo Technologies and xet7.
80 lines
2.4 KiB
JavaScript
80 lines
2.4 KiB
JavaScript
/* eslint-env mocha */
|
|
import { expect } from 'chai';
|
|
import { Random } from 'meteor/random';
|
|
import { canUpdateBoardSort } from '../utils';
|
|
|
|
// Unit tests for canUpdateBoardSort policy
|
|
|
|
describe('boards security', function() {
|
|
describe(canUpdateBoardSort.name, function() {
|
|
it('denies anonymous updates even if fieldNames include sort', function() {
|
|
const userId = null;
|
|
const board = {
|
|
hasMember: () => true,
|
|
};
|
|
const fieldNames = ['sort'];
|
|
|
|
expect(canUpdateBoardSort(userId, board, fieldNames)).to.equal(false);
|
|
});
|
|
|
|
it('denies updates by non-members', function() {
|
|
const userId = Random.id();
|
|
const board = {
|
|
hasMember: (id) => id === 'someone-else',
|
|
};
|
|
const fieldNames = ['sort'];
|
|
|
|
expect(canUpdateBoardSort(userId, board, fieldNames)).to.equal(false);
|
|
});
|
|
|
|
it('allows updates when user is a member and updating sort', function() {
|
|
const userId = Random.id();
|
|
const board = {
|
|
hasMember: (id) => id === userId,
|
|
};
|
|
const fieldNames = ['sort'];
|
|
|
|
expect(canUpdateBoardSort(userId, board, fieldNames)).to.equal(true);
|
|
});
|
|
|
|
it('denies updates when not updating sort', function() {
|
|
const userId = Random.id();
|
|
const board = {
|
|
hasMember: (id) => id === userId,
|
|
};
|
|
const fieldNames = ['title'];
|
|
|
|
expect(canUpdateBoardSort(userId, board, fieldNames)).to.equal(false);
|
|
});
|
|
|
|
// SortBleed (GHSA-xm8x-c8wg-jhmf): a member must not be able to smuggle
|
|
// other fields (members, permission, title, ...) into the same modifier as
|
|
// sort. The sort rule may only approve an update that touches sort ALONE.
|
|
it('denies multi-field updates that smuggle other fields alongside sort', function() {
|
|
const userId = Random.id();
|
|
const board = {
|
|
hasMember: (id) => id === userId,
|
|
};
|
|
|
|
expect(
|
|
canUpdateBoardSort(userId, board, ['sort', 'members']),
|
|
).to.equal(false);
|
|
expect(
|
|
canUpdateBoardSort(userId, board, ['sort', 'permission', 'title']),
|
|
).to.equal(false);
|
|
expect(
|
|
canUpdateBoardSort(userId, board, ['members', 'sort']),
|
|
).to.equal(false);
|
|
});
|
|
|
|
it('denies an empty fieldNames array', function() {
|
|
const userId = Random.id();
|
|
const board = {
|
|
hasMember: (id) => id === userId,
|
|
};
|
|
|
|
expect(canUpdateBoardSort(userId, board, [])).to.equal(false);
|
|
});
|
|
});
|
|
});
|