mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 04:49:41 -05:00
"Are the security tests enough to prevent what is in the Hall of Fame" was unanswerable. WeKan publishes 58 named vulnerabilities at https://wekan.fi/hall-of-fame/ ; some suites name the one they belong to, most did not, and the Hall of Fame lives in a different repository that CI never checks out. Answering it meant reading 58 pages against 300 suites by hand, which means it was never answered - and a regression test that quietly stops existing is worth nothing, the failure mode tests/testsAreRegistered.test.cjs already caught once when two *bleed suites drifted out of the mocha index. So the list lives in the repository that has the tests, and tests/securityRegressionCoverage.test.cjs keeps the two in step. Every published vulnerability is either GUARDED - named by a suite that still exists - or RECORDED, a gap with a written reason, which is the CHANGELOG's "TODO Later" pattern applied to tests. The gap count is pinned, so a vulnerability cannot be published with neither a test nor a note; a gap that turns out to be guarded after all fails too, so coverage is never understated; and a file that merely REGISTERS suites is not accepted as coverage, or the guard would pass itself. Getting there meant naming vulnerabilities in the suites that already guarded them, which is most of what this commit is: - tests/securityMeifukun.test.cjs guards eight reports and named one. Its sections are RedirectBleed, SourceBleed, LiveBleed, CasBleed, OidcBleed, MetricsBleed, ImpersonateBleed and InviteBleed - seven vulnerabilities that looked untested and were not. - tests/noIdentityReplacement.test.cjs guards IdentityBleed and PatternBleed, the same CodeQL finding twice. - ExportBleed, CrashBleed, MimeBleed and the four LockoutBleed suites now say so. - tests/crossBoardParentCardLeak.test.cjs also guards BoardBleed's cross-board move deny, and now checks it on Lists and Swimlanes too, not only Cards. The count that comes out of it: 29 of 58 published vulnerabilities have a named regression test, and 29 are recorded gaps - mostly older fixes from before WeKan tested its security fixes at all. They are not known to be unprotected; they are known to be unchecked, which is a different and more honest statement, and each one now says what it would take to close it. Thanks to xet7 !
57 lines
2.5 KiB
JavaScript
57 lines
2.5 KiB
JavaScript
/* eslint-env mocha */
|
|
// MimeBleed - https://wekan.fi/hall-of-fame/mimebleed/
|
|
// Named for tests/securityRegressionCoverage.test.cjs, which checks the published
|
|
// Hall of Fame list against the tests that guard it - a test that does not say
|
|
// which vulnerability it belongs to cannot be checked against that list.
|
|
|
|
import { expect } from 'chai';
|
|
import { looksLikeDangerousMarkup } from '/models/fileValidation';
|
|
|
|
// Regression test for GHSA-jhph-whx8-wq6p: when the `file` binary is unavailable,
|
|
// isFileValid() must not trust the client-supplied MIME type. It falls back to
|
|
// looksLikeDangerousMarkup() to sniff the real bytes, so a spoofed "image/png"
|
|
// upload that actually contains HTML/JS is still forced through the dangerous
|
|
// content scan (and rejected). These tests pin the sniffer that gates that path.
|
|
describe('fileValidation — dangerous-markup content sniff (GHSA-jhph-whx8-wq6p)', function() {
|
|
describe('flags dangerous markup regardless of the claimed MIME type', function() {
|
|
const dangerous = [
|
|
"<html><body><script>alert('XSS')</script></body></html>",
|
|
'<script>document.cookie</script>',
|
|
'<svg xmlns="http://www.w3.org/2000/svg"><script>alert(1)</script></svg>',
|
|
' \n <html></html>', // leading whitespace
|
|
'<!DOCTYPE html><html></html>',
|
|
"<?xml version='1.0'?><root/>",
|
|
'<iframe src="evil"></iframe>',
|
|
'<object data="x"></object>',
|
|
'<embed src="x">',
|
|
'<!ENTITY xxe SYSTEM "file:///etc/passwd">',
|
|
'<META HTTP-EQUIV="refresh" content="0">', // case-insensitive
|
|
];
|
|
dangerous.forEach((sample, i) => {
|
|
it(`detects dangerous sample #${i + 1}`, function() {
|
|
expect(looksLikeDangerousMarkup(sample)).to.equal(true);
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('does NOT misfire on genuine non-markup content (negative)', function() {
|
|
const safe = [
|
|
'',
|
|
null,
|
|
undefined,
|
|
'hello world, this is a plain text note.',
|
|
'a,b,c\n1,2,3\n', // CSV
|
|
'{"key": "value", "n": 1}', // JSON
|
|
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR', // PNG magic bytes
|
|
'\xff\xd8\xff\xe0\x00\x10JFIF', // JPEG magic bytes
|
|
'%PDF-1.7\n1 0 obj', // PDF header
|
|
'Some text mentioning a script for a play, no angle brackets.',
|
|
];
|
|
safe.forEach((sample, i) => {
|
|
it(`treats safe sample #${i + 1} as not dangerous`, function() {
|
|
expect(looksLikeDangerousMarkup(sample)).to.equal(false);
|
|
});
|
|
});
|
|
});
|
|
});
|