mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10: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 !
61 lines
2.7 KiB
JavaScript
61 lines
2.7 KiB
JavaScript
/* eslint-env mocha */
|
|
// MimeBleed and MimeStorageBleed (GHSA-jhph-whx8-wq6p, GHSA-rv5g-5p4g-3v89) -
|
|
// upload-side MIME and active-content guards.
|
|
// 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
|
|
'<img/onerror=document.body.dataset.executed="yes" src=x>',
|
|
'<img src=x onerror=alert(1)>', // unquoted handler
|
|
'<a href=javascript:alert(1)>open</a>',
|
|
];
|
|
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);
|
|
});
|
|
});
|
|
});
|
|
});
|