mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -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 !
93 lines
3.6 KiB
JavaScript
93 lines
3.6 KiB
JavaScript
// Pure, dependency-free guards for the `versions` metadata of a stored file
|
|
// (ostrio:files: `versions.<name>.path` / `.storage`), so both the attachment
|
|
// and the avatar permission rules can use the SAME rule and cannot drift apart.
|
|
//
|
|
// GHSA-4mxf-m8pq-xc9p: attachments blocked client-supplied `versions.*.path`,
|
|
// avatars did not - their allow rule was `update: isOwner` with no field
|
|
// restriction at all. An avatar owner could therefore point
|
|
// `versions.original.path` at any file the WeKan process can read (/etc/passwd,
|
|
// anything under WRITABLE_PATH) and then export a board they are a member of:
|
|
// the exporter reads that path from disk and embeds the bytes as base64 in
|
|
// `profile.avatarFile`. That is an arbitrary file read for any authenticated
|
|
// user, so the rule now lives in ONE place and is applied to both collections.
|
|
//
|
|
// `path` and `storage` are server-managed: they say WHERE on disk the bytes
|
|
// are. A client never has a reason to set or change them, on any collection.
|
|
|
|
const SERVER_MANAGED_VERSION_FIELDS = ['path', 'storage'];
|
|
|
|
/**
|
|
* True when a document a client is trying to INSERT carries server-managed
|
|
* version metadata (`versions.<any>.path` or `.storage`, or a top-level `path`).
|
|
* @param {object} fileObj the document as the client sent it
|
|
* @return {boolean}
|
|
*/
|
|
function hasUnsafeClientVersionFields(fileObj) {
|
|
// FilePathBleed (GHSA-g6vm-7757-pr88), top-level sibling: a document with no
|
|
// `versions` object makes ostrio:files fall back to the TOP-LEVEL `path` -
|
|
// unlinkAsync() deletes `fileRef.path` when the record is removed (for
|
|
// example by the validateAttachment method rejecting it) and isFileValid()
|
|
// reads it. The versions-only check let a client insert `{ path: '/any/file' }`
|
|
// with `versions` left out. It is the same server-managed field one level up.
|
|
if (fileObj && typeof fileObj === 'object'
|
|
&& Object.prototype.hasOwnProperty.call(fileObj, 'path')) {
|
|
return true;
|
|
}
|
|
const versions = fileObj && fileObj.versions;
|
|
if (!versions || typeof versions !== 'object') {
|
|
return false;
|
|
}
|
|
|
|
return Object.values(versions).some((version) => {
|
|
if (!version || typeof version !== 'object') {
|
|
return false;
|
|
}
|
|
return SERVER_MANAGED_VERSION_FIELDS.some((field) =>
|
|
Object.prototype.hasOwnProperty.call(version, field),
|
|
);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* True when an UPDATE touches the `versions` subtree at all. Deliberately
|
|
* broader than hasUnsafeClientVersionFields: an update arrives as a list of
|
|
* modified field names, and `versions.original` (the whole sub-object, path
|
|
* included) is as dangerous as `versions.original.path` spelled out.
|
|
* @param {string[]} fields the modified field names Meteor passes to allow()
|
|
* @return {boolean}
|
|
*/
|
|
function touchesVersionFields(fields) {
|
|
if (!Array.isArray(fields)) {
|
|
return false;
|
|
}
|
|
return fields.some(
|
|
(field) =>
|
|
typeof field === 'string' &&
|
|
(field === 'versions' || field.startsWith('versions.')),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* True when every modified field name is in `allowedFields` (comparing the
|
|
* part before the first dot, so `meta.boardId` is allowed by `meta`).
|
|
* @param {string[]} fields the modified field names
|
|
* @param {string[]} allowedFields the whitelist
|
|
* @return {boolean}
|
|
*/
|
|
function onlyTouchesAllowedFields(fields, allowedFields) {
|
|
if (!Array.isArray(fields)) {
|
|
return false;
|
|
}
|
|
return fields.every((field) => {
|
|
if (typeof field !== 'string') return false;
|
|
return allowedFields.includes(field.split('.')[0]);
|
|
});
|
|
}
|
|
|
|
module.exports = {
|
|
SERVER_MANAGED_VERSION_FIELDS,
|
|
hasUnsafeClientVersionFields,
|
|
touchesVersionFields,
|
|
onlyTouchesAllowedFields,
|
|
};
|