mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Meteor published the same six fixes as 3.3.3, 3.4.2 and 3.5.3 on 2026-10-16. 3.6-rc.0, which WeKan runs, does not have them: its tag is behind 3.5.3 by exactly the 15 security commits, and neither it nor Meteor's devel branch has the fixed code. Going back to 3.5.3 would also mean Node.js 24 and Rspack 1, so WeKan carries the fixes in packages/, where a package overrides the release's own: 3.6-rc.0's allow-deny, ddp-server, dynamic-import, facebook-oauth, google-oauth and shell-server with Meteor's 3.5.3 patch applied unchanged, each marked with a _1 wrap number. ddp-server leaves out uWebSockets.js, as Meteor's published package does; it is only for the opt-in uws transport and came from a git URL. - DDP: a message named __proto__, toString or not a string, and an async handler that rejected, crashed the server. - allow/deny: a top-level __proto__ in an update was missing from the field list the validators saw. - dynamic import(): requests are bounded in size (413) and complexity (400). - Google and Facebook direct-token login: a token issued to another application was accepted; identity now comes from the provider, and a Facebook verification error no longer carries the app secret. - meteor shell: its history and compile cache are private. - Deploy discovery is in meteor-tool, which an app cannot replace; WeKan is never deployed with meteor deploy, and a test keeps it so. Refused attempts are in Admin Panel / Problems as Meteor DDP, Meteor allow-deny, Meteor dynamic-import and Meteor OAuth, through a hook the packages call (server/lib/meteorSecurityHook.js); none blocks an account. An oversized import() body, an unknown ordinary DDP name and a network failure are refused without a row, because ordinary use can reach them. tests/meteor353SecurityFixes.test.cjs runs each fix's code cut out of the fork and searches the tree for the shape of each fault; all of them fail on the unfixed 3.6-rc.0 packages. It also fails when .meteor/release moves on, because a fork would silently keep 3.6-rc.0's code. tests/playwright/specs/meteor-353-security.e2e.js sends each attack to a running WeKan built with the forks. The forked files are recorded in the source audit baseline, and the suites that check WeKan's own methods and subscriptions skip Meteor's package tests. Thanks to Meteor developers, Vext Labs and xet7 !
213 lines
6.1 KiB
JavaScript
213 lines
6.1 KiB
JavaScript
var Module = module.constructor;
|
|
var cache = require("./cache.js");
|
|
var meteorInstall = require("meteor/modules").meteorInstall;
|
|
var dynamicVersions = require("./dynamic-versions.js");
|
|
|
|
// Fix for Safari 14 bug (https://bugs.webkit.org/show_bug.cgi?id=226547), do not delete this unused var
|
|
var idb = global.indexedDB;
|
|
|
|
var dynamicImportSettings = Meteor.settings
|
|
&& Meteor.settings.public
|
|
&& Meteor.settings.public.packages
|
|
&& Meteor.settings.public.packages['dynamic-import'] || {};
|
|
|
|
// Call module.dynamicImport(id) to fetch a module and any/all of its
|
|
// dependencies that have not already been fetched, and evaluate them as
|
|
// soon as they arrive. This runtime API makes it very easy to implement
|
|
// ECMAScript dynamic import(...) syntax.
|
|
Module.prototype.dynamicImport = function (id) {
|
|
var module = this;
|
|
return module.prefetch(id).then(function () {
|
|
return getNamespace(module, id);
|
|
});
|
|
};
|
|
|
|
// Called by Module.prototype.prefetch if there are any missing dynamic
|
|
// modules that need to be fetched.
|
|
meteorInstall.fetch = function (ids) {
|
|
var tree = Object.create(null);
|
|
var versions = Object.create(null);
|
|
var missing;
|
|
|
|
function addSource(id, source) {
|
|
addToTree(tree, id, makeModuleFunction(id, source, ids[id].options));
|
|
}
|
|
|
|
function addMissing(id) {
|
|
addToTree(missing = missing || Object.create(null), id, 1);
|
|
}
|
|
|
|
Object.keys(ids).forEach(function (id) {
|
|
var version = dynamicVersions.get(id);
|
|
if (version) {
|
|
versions[id] = version;
|
|
} else {
|
|
addMissing(id);
|
|
}
|
|
});
|
|
|
|
return cache.checkMany(versions).then(function (sources) {
|
|
Object.keys(sources).forEach(function (id) {
|
|
var source = sources[id];
|
|
if (source) {
|
|
addSource(id, source);
|
|
} else {
|
|
addMissing(id);
|
|
}
|
|
});
|
|
|
|
return missing && fetchMissing(missing).then(function (results) {
|
|
var versionsAndSourcesById = Object.create(null);
|
|
var flatResults = flattenModuleTree(results);
|
|
|
|
Object.keys(flatResults).forEach(function (id) {
|
|
var source = flatResults[id];
|
|
addSource(id, source);
|
|
|
|
var version = dynamicVersions.get(id);
|
|
if (version) {
|
|
versionsAndSourcesById[id] = {
|
|
version: version,
|
|
source: source
|
|
};
|
|
}
|
|
});
|
|
|
|
cache.setMany(versionsAndSourcesById);
|
|
});
|
|
|
|
}).then(function () {
|
|
return tree;
|
|
});
|
|
};
|
|
|
|
function flattenModuleTree(tree) {
|
|
var parts = [""];
|
|
var result = Object.create(null);
|
|
|
|
function walk(t) {
|
|
if (t && typeof t === "object") {
|
|
Object.keys(t).forEach(function (key) {
|
|
parts.push(key);
|
|
walk(t[key]);
|
|
parts.pop();
|
|
});
|
|
} else if (typeof t === "string") {
|
|
result[parts.join("/")] = t;
|
|
}
|
|
}
|
|
|
|
walk(tree);
|
|
|
|
return result;
|
|
}
|
|
|
|
function makeModuleFunction(id, source, options) {
|
|
// By calling (options && options.eval || eval) in a wrapper function,
|
|
// we delay the cost of parsing and evaluating the module code until the
|
|
// module is first imported.
|
|
return function () {
|
|
// If an options.eval function was provided in the second argument to
|
|
// meteorInstall when this bundle was first installed, use that
|
|
// function to parse and evaluate the dynamic module code in the scope
|
|
// of the package. Otherwise fall back to indirect (global) eval.
|
|
return (options && options.eval || eval)(
|
|
// Wrap the function(require,exports,module){...} expression in
|
|
// parentheses to force it to be parsed as an expression.
|
|
"(" + source + ")\n//# sourceURL=" + id
|
|
).apply(this, arguments);
|
|
};
|
|
}
|
|
|
|
var secretKey = null;
|
|
exports.setSecretKey = function (key) {
|
|
secretKey = key;
|
|
};
|
|
|
|
var fetchURL = require("./common.js").fetchURL;
|
|
|
|
function inIframe() {
|
|
try {
|
|
return window.self !== window.top;
|
|
} catch (e) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
function fetchMissing(missingTree) {
|
|
// If the hostname of the URL returned by Meteor.absoluteUrl differs
|
|
// from location.host, then we'll be making a cross-origin request here,
|
|
// but that's fine because the dynamic-import server sets appropriate
|
|
// CORS headers to enable fetching dynamic modules from any
|
|
// origin. Browsers that check CORS do so by sending an additional
|
|
// preflight OPTIONS request, which may add latency to the first dynamic
|
|
// import() request, so it's a good idea for ROOT_URL to match
|
|
// location.host if possible, though not strictly necessary.
|
|
|
|
var url = fetchURL;
|
|
|
|
var useLocationOrigin = dynamicImportSettings.useLocationOrigin;
|
|
|
|
var disableLocationOriginIframe = dynamicImportSettings.disableLocationOriginIframe;
|
|
|
|
if (useLocationOrigin && location && !(disableLocationOriginIframe && inIframe())) {
|
|
url = location.origin.concat(__meteor_runtime_config__.ROOT_URL_PATH_PREFIX || '', url);
|
|
} else {
|
|
url = Meteor.absoluteUrl(url);
|
|
}
|
|
|
|
if (secretKey) {
|
|
url += "key=" + secretKey;
|
|
}
|
|
|
|
var bodies = require("./request-batches.js").makeRequestBodies(missingTree);
|
|
var results = Object.create(null);
|
|
// Bound concurrency as well as each request. The installer sees one merged
|
|
// response only after all batches succeed, preserving normal cache behavior.
|
|
return bodies.reduce(function (previous, body) {
|
|
return previous.then(function () {
|
|
return fetch(url, { method: "POST", body: body });
|
|
}).then(function (res) {
|
|
if (!res.ok) throw res;
|
|
return res.json();
|
|
}).then(function (tree) {
|
|
var flat = flattenModuleTree(tree);
|
|
Object.keys(flat).forEach(function (id) {
|
|
addToTree(results, id, flat[id]);
|
|
});
|
|
});
|
|
}, Promise.resolve()).then(function () {
|
|
return results;
|
|
});
|
|
}
|
|
|
|
function addToTree(tree, id, value) {
|
|
var parts = id.split("/");
|
|
var lastIndex = parts.length - 1;
|
|
parts.forEach(function (part, i) {
|
|
if (part) {
|
|
tree = tree[part] = tree[part] ||
|
|
(i < lastIndex ? Object.create(null) : value);
|
|
}
|
|
});
|
|
}
|
|
|
|
function getNamespace(module, id) {
|
|
var namespace;
|
|
|
|
module.link(id, {
|
|
"*": function (ns) {
|
|
namespace = ns;
|
|
}
|
|
});
|
|
|
|
// This helps with Babel interop, since we're not just returning the
|
|
// module.exports object.
|
|
Object.defineProperty(namespace, "__esModule", {
|
|
value: true,
|
|
enumerable: false
|
|
});
|
|
|
|
return namespace;
|
|
}
|