mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
sanitize-html 2.18.0 re-sanitized the fallback of a discarded <iframe>
with no recursion limit (GHSA-c9rx-x947-fp3h, CWE-674). WeKan's server
sanitizer discards every tag, so a few kilobytes of nested <iframe> threw
RangeError in secureTransfer, on every import and export - and
secureTransfer records a throw as a high blocked event naming the user,
which disables that account. A card planted with the payload locked out
the next member who exported the board. 96ed9ad202 moved to 2.18.1.
tests/sanitizeHtmlNestedIframe.test.cjs runs WeKan's own sanitizeInput
options on three nested-iframe payloads, checks the installed and locked
versions, and fails if anything else imports sanitize-html; with 2.18.0
it fails with RangeError. The Playwright spec exports and imports a board
holding the payload and checks that nobody is locked out.
Thanks to xet7 !
31 lines
1.6 KiB
JavaScript
31 lines
1.6 KiB
JavaScript
'use strict';
|
|
// GHSA-c9rx-x947-fp3h: sanitize-html 2.18.0 overflowed the stack on nested
|
|
// <iframe>. secureTransfer sanitizes every import and export, and a throw there
|
|
// is recorded as a high "blocked" event that disables the user's account, so a
|
|
// card planted with the payload locked out whoever exported the board next.
|
|
const { test, expect } = require('../fixtures');
|
|
const db = require('../helpers/db');
|
|
|
|
const PAYLOAD = '<iframe>'.repeat(20000);
|
|
const auth = (token, json) => ({ Authorization: `Bearer ${token}`, ...(json ? { 'Content-Type': 'application/json' } : {}) });
|
|
|
|
test('a board whose card holds nested iframes exports and imports, and nobody is locked out', async ({ request, user, board }) => {
|
|
const card = db.findOne('cards', { boardId: board.boardId });
|
|
db.updateOne('cards', { _id: card._id }, { $set: { description: PAYLOAD } });
|
|
|
|
const exported = await request.get(`/api/boards/${board.boardId}/export`, { headers: auth(user.token) });
|
|
expect(exported.status()).toBe(200);
|
|
const json = await exported.json();
|
|
const exportedCard = json.cards.find(c => c._id === card._id);
|
|
expect(exportedCard.description).not.toMatch(/<iframe/i);
|
|
|
|
json.title = PAYLOAD;
|
|
const imported = await request.post('/api/boards/import', { headers: auth(user.token, true), data: { board: json } });
|
|
expect(imported.status()).toBe(200);
|
|
const { _id: newBoardId } = await imported.json();
|
|
|
|
expect(db.findOne('users', { _id: user.id })?.loginDisabled).not.toBe(true);
|
|
expect(db.find('eventlog', { stream: 'security', bleed: 'ImportExportValidation', userId: user.id })).toHaveLength(0);
|
|
db.cleanup({ boardIds: [newBoardId] });
|
|
});
|