mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -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 !
98 lines
3.5 KiB
JavaScript
98 lines
3.5 KiB
JavaScript
var limits = require("./request-limits.js");
|
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
|
|
// Buffer and TextEncoder are not available on all supported browser targets.
|
|
function byteLength(text) {
|
|
var bytes = 0;
|
|
for (var i = 0; i < text.length; i += 1) {
|
|
var code = text.charCodeAt(i);
|
|
if (code < 0x80) bytes += 1;
|
|
else if (code < 0x800) bytes += 2;
|
|
else if (code >= 0xd800 && code <= 0xdbff &&
|
|
i + 1 < text.length && text.charCodeAt(i + 1) >= 0xdc00 &&
|
|
text.charCodeAt(i + 1) <= 0xdfff) {
|
|
bytes += 4;
|
|
i += 1;
|
|
} else bytes += 3;
|
|
}
|
|
return bytes;
|
|
}
|
|
|
|
function newNode(value) {
|
|
return { value: value, children: Object.create(null), count: 0 };
|
|
}
|
|
|
|
// Pack complete leaves, not arbitrary subtrees: a single wide directory or
|
|
// transitive graph can exceed the server caps even when its paths are valid.
|
|
// Accounting is incremental; do not serialize the whole graph for every leaf.
|
|
exports.makeRequestBodies = function (tree) {
|
|
var bodies = [];
|
|
var batch;
|
|
function reset() {
|
|
batch = { root: newNode(Object.create(null)), nodes: 1, bytes: 2 };
|
|
}
|
|
reset();
|
|
|
|
function add(parts) {
|
|
var node = batch.root;
|
|
var index = 0;
|
|
while (index < parts.length && hasOwn.call(node.children, parts[index])) {
|
|
node = node.children[parts[index]];
|
|
index += 1;
|
|
}
|
|
var extraNodes = parts.length - index;
|
|
var extraBytes = index < parts.length && node.count > 0 ? 1 : 0;
|
|
for (var i = index; i < parts.length; i += 1) {
|
|
extraBytes += byteLength(JSON.stringify(parts[i])) +
|
|
(i < parts.length - 1 ? 3 : 2); // colon + {} or 1
|
|
}
|
|
if ((extraNodes > 0 && node.count >= limits.MAX_KEYS_PER_OBJECT) ||
|
|
batch.nodes + extraNodes > limits.MAX_TREE_NODES ||
|
|
batch.bytes + extraBytes > limits.MAX_REQUEST_BYTES) return false;
|
|
|
|
for (; index < parts.length; index += 1) {
|
|
var name = parts[index];
|
|
var value = index < parts.length - 1 ? Object.create(null) : 1;
|
|
var child = newNode(value);
|
|
node.value[name] = value;
|
|
node.children[name] = child;
|
|
node.count += 1;
|
|
node = child;
|
|
}
|
|
batch.nodes += extraNodes;
|
|
batch.bytes += extraBytes;
|
|
return true;
|
|
}
|
|
|
|
var stack = [{ node: tree, parts: [], pathBytes: 0 }];
|
|
while (stack.length > 0) {
|
|
var frame = stack.pop();
|
|
if (frame.node === 1 && frame.parts.length > 0) {
|
|
if (!add(frame.parts)) {
|
|
bodies.push(JSON.stringify(batch.root.value));
|
|
reset();
|
|
if (!add(frame.parts)) throw new Error("dynamic import path cannot fit in a request");
|
|
}
|
|
continue;
|
|
}
|
|
if (!frame.node || typeof frame.node !== "object" || Array.isArray(frame.node)) {
|
|
throw new Error("dynamic import tree leaves must equal 1");
|
|
}
|
|
var keys = Object.keys(frame.node);
|
|
for (var k = keys.length - 1; k >= 0; k -= 1) {
|
|
var key = keys[k];
|
|
var keyBytes = byteLength(key);
|
|
var pathBytes = frame.pathBytes + (frame.parts.length > 0 ? 1 : 0) + keyBytes;
|
|
if (!key || key === "." || key === ".." || key.indexOf("\0") >= 0 ||
|
|
key.indexOf("/") >= 0 || key.indexOf("\\") >= 0 ||
|
|
keyBytes > limits.MAX_KEY_BYTES || pathBytes > limits.MAX_PATH_BYTES ||
|
|
frame.parts.length + 1 > limits.MAX_TREE_DEPTH) {
|
|
throw new Error("invalid dynamic import path");
|
|
}
|
|
stack.push({ node: frame.node[key], parts: frame.parts.concat(key), pathBytes: pathBytes });
|
|
}
|
|
}
|
|
if (batch.nodes > 1 || bodies.length === 0) bodies.push(JSON.stringify(batch.root.value));
|
|
return bodies;
|
|
};
|