Files
wekan/models/lib/transferFailure.cjs
T
Lauri Ojansivu 567f99227b A failed import or export disables an account only when it was an attempt.
secureTransfer recorded every throw as a high "blocked" event naming the
user, and that disables the account. sanitize-html 2.18.0 threw
RangeError on nested <iframe>, so a card planted with the payload locked
out the next member who exported the board; any library fault would do
the same. The transfer boundary now marks its own refusals
(TransferBoundaryError: a cycle, a non-plain object, a size limit), and
models/lib/transferFailure.cjs records only those as blocked - high, and
medium for a size limit as before. Anything else is ImportExportFailure:
detected, still naming whose import or export it was, and never blocking
an account.

tests/transferFailure.test.cjs drives real boundary refusals and a
sanitizer that throws through blockOnSecurityEvent's own decision; with
the old secureTransfer it fails. It also fails if the boundary throws a
plain Error or anything but secureTransfer calls it.

Thanks to xet7 !
2026-10-22 04:56:40 +03:00

49 lines
1.7 KiB
JavaScript

'use strict';
// What server/lib/secureTransfer.js records when an import or export throws.
//
// Only the transfer boundary's own refusals (models/lib/importExportBoundary.js
// marks them name 'TransferBoundaryError') are an ATTEMPT, and are recorded as
// blocked: a cycle or a non-plain object is not something an export produces,
// so it is high, and a size limit - which a large real board reaches too - is
// medium. Anything else is the code failing, not the user trying something:
// sanitize-html 2.18.0 threw RangeError on nested <iframe>, and recording that
// as a high "blocked" event disabled the account of whoever exported a board
// someone else had planted the payload in. It is recorded as detected, so an
// administrator still sees it, and never blocks an account.
function isTransferBoundaryError(error) {
return Boolean(error) && error.name === 'TransferBoundaryError';
}
function transferFailureEvent(error, context = {}) {
const base = {
category: 'Import/export validation',
source: context.source || `${context.direction || 'import'}:unknown`,
userId: context.userId,
username: context.username,
ip: context.ip,
};
if (isTransferBoundaryError(error)) {
return {
...base,
bleed: 'ImportExportValidation',
severity: error.kind === 'limit' ? 'medium' : 'high',
action: 'blocked',
detail: error.message,
};
}
const name = (error && error.name) || 'Error';
const message = (error && error.message) || String(error);
return {
...base,
bleed: 'ImportExportFailure',
severity: 'medium',
action: 'detected',
blocksAccount: false,
detail: `${name}: ${message}`.slice(0, 200),
};
}
module.exports = { isTransferBoundaryError, transferFailureEvent };