Files
wekan/models/lib/importPlacement.js
T
Lauri Ojansivu 0d6d481fcb ImportPlacementBleed: an import into a board is placed only beside that board's own list, swimlane or card.
The scoped importer, reached by POST /api/import/zip and the importScoped
method, authorized the import on boardId alone. The listId and swimlaneId
beside it were written onto the new cards as given, and a cardId was looked
up with no board filter, so a writer of board A could create cards on A
whose list and swimlane were board B's, and could probe whether a card id
existed on a board they cannot see.

Before anything is written, the list, swimlane and card are now looked up
together with the board's id; an id of another board is refused (400 over
REST, error-import-placement from the method), with the same answer for a
foreign card and a missing one. Cards are placed only by what was found on
the board. A refusal is recorded in Admin Panel / Problems as
ImportPlacementBleed (authz.import-placement), without blocking the account.

Tests: the decision with the reporter's ids, the check before every write,
a negative scan for a target id written or looked up without the board, and
a browser test of the reporter's attack by both routes, which fails on the
previous code.

Thanks to Zachariah Mithani (AploSec) and xet7 !
2026-10-29 20:27:14 +02:00

38 lines
1.6 KiB
JavaScript

'use strict';
// ImportPlacementBleed: an import INTO a board (the scoped importer, reached by
// POST /api/import/zip and the importScoped method) was authorized on its
// boardId alone. The listId, swimlaneId and cardId beside it - where the
// imported cards land - were taken as they were, so a writer of board A could
// create cards on A whose list and swimlane were board B's, and could ask
// whether a card id existed on a board they cannot see. The REST card create
// refuses the same thing (restPlacementError, #6572).
//
// Pure: the caller looks each id up WITH the board's id in the query and hands
// over what it found, so the decision is testable without a database.
// target: { boardId, listId?, swimlaneId?, cardId? } as the request gave it
// found: { list, swimlane, card } - each the document found on THAT board,
// or null/undefined when there is none there
// Returns null when every id given belongs to the board, else which one does
// not: 'listId', 'swimlaneId' or 'cardId'.
const PLACEMENT_KEYS = ['listId', 'swimlaneId', 'cardId'];
const FOUND_KEY = { listId: 'list', swimlaneId: 'swimlane', cardId: 'card' };
function given(value) {
return value !== undefined && value !== null && value !== '';
}
function importPlacementError(target, found) {
const t = target || {};
const f = found || {};
for (const key of PLACEMENT_KEYS) {
if (!given(t[key])) continue;
const doc = f[FOUND_KEY[key]];
if (typeof t[key] !== 'string' || !doc || doc._id !== t[key] || doc.boardId !== t.boardId) return key;
}
return null;
}
module.exports = { PLACEMENT_KEYS, importPlacementError };