mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 10:48:06 -05:00
Every Hall of Fame vulnerability without a test naming it (24 names, 30 advisories) was checked against the current source. No fix had been reverted. Looking for the same mistake elsewhere found siblings: - FloppyBleed: the fs-path-heal upgrade step joined an attachment's stored name into candidate paths as-is; a record a client inserted named ../../../etc/passwd made the next upgrade copy that file into storage - an arbitrary file read. Only the name's last component is used now; the bulk move limits a legacy name's extension the same way. - FilePathBleed (GHSA-g6vm-7757-pr88): the insert guard looked only inside versions; with versions left out ostrio:files falls back to a top-level path, which removing the record deletes and validation reads. A client's top-level path is refused for attachments and avatars, recorded by the existing canaries. - MoveStorageBleed: validateAttachment, which deletes a file failing the current upload rules, was open to anybody who could see the board, a public one included. Only who may change the file, or a site admin, validates now; a refusal is recorded (authz.attachment-validate). - HookUrlBleed / IntegrationBleed: the REST reads of a board's integrations gave the webhook URL - whose path is its secret - to every member reading the board; non-admins get what the publication gives them. - AttachmentMigrationBleed: four migration methods answered any logged-in user about any board, deleteDuplicateEmptyLists.getStatus with a private board's list titles; they require a visible board and record refusals (authz.migration-board). - LegacyAttachBleed (GHSA-xcxp-hx9w-q5q9) and MimeStorageBleed (GHSA-rv5g-5p4g-3v89): the legacy route judged a name dangerous only for .svg, the response policy missed x-javascript, ecmascript, xsl and +xml types, and the sniffers missed <tag/onx= handlers. OIDCBleed refusals are now recorded in Admin Panel / Problems too. New suites name the vulnerabilities they guard, existing ones name the advisories they already covered, and tests/securityRegressionCoverage counts 128 of 137 published vulnerabilities with a named test (was 125). Thanks to xet7 !
92 lines
4.2 KiB
JavaScript
92 lines
4.2 KiB
JavaScript
'use strict';
|
|
|
|
// Regression coverage for MailTitleBleed (GHSA-hp9m-vff5-7pvw): stored activity
|
|
// titles became active markup in HTML notification mail, and subjects could
|
|
// carry header-injecting newlines.
|
|
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const root = path.resolve(__dirname, '..');
|
|
const safetyModulePath = path.join(root, 'models/lib/emailNotificationSafety');
|
|
const { escapeEmailHtml, safeEmailSubject } = require(safetyModulePath);
|
|
const safetySource = fs.readFileSync(`${safetyModulePath}.js`, 'utf8');
|
|
const email = fs.readFileSync(
|
|
path.join(root, 'server/notifications/email.js'),
|
|
'utf8',
|
|
);
|
|
|
|
assert.equal(
|
|
escapeEmailHtml(`<img src=x onerror="alert('x')"> & card`),
|
|
'<img src=x onerror="alert('x')"> & card',
|
|
'HTML-active card, list and board titles must render only as text',
|
|
);
|
|
assert.equal(
|
|
escapeEmailHtml('ordinary Roadmap title'),
|
|
'ordinary Roadmap title',
|
|
'ordinary notification text must remain readable',
|
|
);
|
|
assert.equal(
|
|
safeEmailSubject('Roadmap\r\nBcc: attacker@example.test'),
|
|
'Roadmap Bcc: attacker@example.test',
|
|
'titles must not inject additional mail headers',
|
|
);
|
|
assert.match(
|
|
email,
|
|
// Not `bodyTemplate ? text : ...`: that sent the template's substituted
|
|
// member-written values as HTML (MailTitleBleed regression, 2026-10-02).
|
|
// #5171: the clearly arranged layout comes first when chosen; it is built
|
|
// by models/lib/notificationDelivery.js renderNotificationItem, which
|
|
// escapes every value (tests/notificationDelivery.test.cjs).
|
|
/const html = clear \? clear\.html : bodyTemplate\s*\?[^\n]*\$\{substituteVars\(bodyTemplate, htmlVars\)\}`\s*:\s*buildHtmlNotificationLine\(\{/,
|
|
'the HTML notification body must be built by the shared, escaping-aware helper',
|
|
);
|
|
assert.match(
|
|
safetySource,
|
|
/escapeEmailHtml\(actorName \|\| ''\)/,
|
|
'the actor name must be escaped before it is placed into the HTML message',
|
|
);
|
|
assert.match(
|
|
safetySource,
|
|
/escapeEmailHtml\(\s*descriptionText \|\| '',?\s*\)/,
|
|
'the localized description must be escaped before it is placed into the HTML message',
|
|
);
|
|
assert.match(
|
|
safetySource,
|
|
/escapeEmailHtml\(safeUrl\)/,
|
|
'#3118: the card\\/board URL must be escaped before it is placed into the <a href> link',
|
|
);
|
|
assert.match(
|
|
safetySource,
|
|
/<a href="\$\{escapeEmailHtml\(safeUrl\)\}">\$\{escapeEmailHtml\(safeUrl\)\}<\/a>/,
|
|
'#3118: an HTML-formatted notification email must wrap the card\\/board URL in a real <a href> link, not plain text',
|
|
);
|
|
assert.match(
|
|
email,
|
|
// `let`, not `const`: the admin-template override (#2022) below reassigns
|
|
// it through the same safeEmailSubject() guard, so it must stay mutable.
|
|
/let subject = safeEmailSubject\(formatActivityNotificationTitle\(/,
|
|
'notification subjects must use the shared header-safe formatter',
|
|
);
|
|
|
|
// MailTitleBleed regression (2026-10-02): with an admin-defined activity
|
|
// body template, the HTML body was the substituted template, and the values
|
|
// substituted into it - card, board and list titles, usernames, comments - are
|
|
// written by members. Markup in a card title reached other members' mail.
|
|
{
|
|
const { substituteVars } = require('../models/lib/ruleVarsSubstitute');
|
|
const { escapeEmailHtml } = require('../models/lib/emailNotificationSafety');
|
|
const vars = { card: '<img src=x onerror=alert(1)>', board: 'B&B "x"', username: 'u' };
|
|
const htmlVars = Object.fromEntries(Object.entries(vars).map(([k, v]) => [k, escapeEmailHtml(v)]));
|
|
const out = substituteVars('<p>{username} changed <b>{card}</b> on {board}</p>', htmlVars);
|
|
assert.equal(out, '<p>u changed <b><img src=x onerror=alert(1)></b> on B&B "x"</p>',
|
|
'the admin template keeps its HTML; the member-written values are escaped');
|
|
assert.doesNotMatch(email, /const html = bodyTemplate\s*\?\s*text\b/,
|
|
'the HTML body is never the raw substituted text');
|
|
assert.match(email, /const htmlVars = Object\.fromEntries\(Object\.entries\(templateVars\)\.map\(\(\[key, value\]\) => \[key, escapeEmailHtml\(value\)\]\)\);/);
|
|
assert.match(email, /\$\{substituteVars\(bodyTemplate, htmlVars\)\}/);
|
|
}
|
|
|
|
console.log('notificationEmailHtmlSafety: 12 assertions passed');
|