mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
GHSA-qcfm-2g4w-wqcc. Admin Panel / Settings / Visibility / "Only admins can create boards" (#4475) was checked only inside createBoardWithInitialSwimlanes, the Add Board form. A non-admin still created working boards by a client Boards.insert (Boards.allow.insert approves any signed-in user), POST /api/boards and both board import routes, as reported, and also by importBoard, cloneBoard, copyBoard, POST /api/boards/:boardId/copy and createBoardFromCard. One decision (models/lib/boardCreationPolicy.js) and one guard (server/lib/boardCreationGuard.js) are asked by every one of those paths before they write, and by a new Boards.deny insert rule. A board template stays every member's own; boards WeKan makes itself (a Templates container, a board's subtasks board) are not created by the user. A REST refusal is 403. A refusal is recorded in Admin Panel / Problems as CreateBleed (authz.board-creation, low, CWE-863, blocks no account), and Duplicate and "Create board from card" are hidden like Add Board, so only a client bypassing the interface reaches it. tests/createBleed.test.cjs drives the decision, the guard and the real deny rule against the reporter's console insert, and fails if any path that creates a board for a user does not ask the guard, or if anything else reads the setting. tests/playwright/specs/createbleed-board-creation-admin-only.e2e.js replays the report against a running server. The guards that pinned the old inline check now pin the shared one. Thanks to tsurutanmen and xet7 !
36 lines
1.6 KiB
JavaScript
36 lines
1.6 KiB
JavaScript
// CreateBleed (GHSA-qcfm-2g4w-wqcc), #4475: who may create a board while
|
|
// Admin Panel -> Settings -> Visibility -> "Only admins can create boards"
|
|
// (tableVisibilityMode-boardCreationAdminOnly) is on.
|
|
//
|
|
// The decision, as arithmetic: no server, no database. Every path that makes a
|
|
// new WORKING board asks it through server/lib/boardCreationGuard.js -
|
|
// createBoardWithInitialSwimlanes, a client Boards.insert, POST /api/boards,
|
|
// importBoard (the UI's and both REST import routes), cloneBoard, copyBoard
|
|
// and createBoardFromCard. Only the first of them used to read the setting.
|
|
//
|
|
// A board TEMPLATE (type 'template-board') is not a working board: a member
|
|
// keeps their Templates board, and making a working board from a template is
|
|
// copyBoard with type 'board', which this refuses. Boards WeKan makes itself -
|
|
// a user's Templates container, a board's default subtasks board - are not
|
|
// "created by the user" and never ask.
|
|
|
|
const TEMPLATE_TYPES = new Set(['template-board']);
|
|
|
|
// The type a new board will have; none means a working board, as the schema
|
|
// defaults it.
|
|
function boardTypeOf(type) {
|
|
return typeof type === 'string' && type ? type : 'board';
|
|
}
|
|
|
|
// May this user create a board of this type?
|
|
// adminOnly: the setting's booleanValue
|
|
// isAdmin: the user's isAdmin (only `true` counts)
|
|
// type: the new board's type
|
|
function boardCreationAllowed({ adminOnly, isAdmin, type } = {}) {
|
|
if (adminOnly !== true) return true;
|
|
if (isAdmin === true) return true;
|
|
return TEMPLATE_TYPES.has(boardTypeOf(type));
|
|
}
|
|
|
|
module.exports = { boardCreationAllowed, boardTypeOf, TEMPLATE_TYPES };
|