Files
wekan/tests/subscriptionsArePublished.test.cjs
T
Lauri Ojansivu e0189bc53b Meteor 3.5.3's six security fixes on Meteor 3.6-rc.0.
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 !
2026-10-22 04:12:13 +03:00

81 lines
3.3 KiB
JavaScript

'use strict';
// Every Meteor.subscribe('name') on the client must name a publication the
// server actually has. A misspelt name is not an error anywhere: Meteor logs
// nothing, the subscription never becomes ready and the data it should carry
// is simply absent. The notifications drawer subscribed to
// 'notificationsAttachments' while the server publishes
// 'notificationAttachments', so an attachment named in a notification was
// never sent to the drawer.
//
// The test pins that subscription, and the negative sweep checks every
// subscribe() in the tree against every publish(), so the same slip cannot
// live at another call site.
//
// Run: node tests/subscriptionsArePublished.test.cjs
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const { isMeteorPackageFork } = require('./lib/meteorPackageForks.cjs');
const ROOT = path.join(__dirname, '..');
const TOPS = ['client', 'server', 'models', 'imports', 'packages', 'config'];
const SKIP = new Set(['node_modules', '.npm', '_build']);
let passed = 0;
function test(name, fn) { fn(); passed += 1; console.log(' ok -', name); }
function walk(dir, out = []) {
if (!fs.existsSync(dir)) return out;
for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
if (SKIP.has(e.name)) continue;
const full = path.join(dir, e.name);
// Meteor's own packages subscribe in their own tests to what those tests
// publish; they are not WeKan's subscriptions.
if (isMeteorPackageFork(path.relative(ROOT, full))) continue;
if (e.isDirectory()) walk(full, out);
else if (/\.(js|jade)$/.test(e.name)) out.push(full);
}
return out;
}
const files = TOPS.flatMap(t => walk(path.join(ROOT, t)));
const published = new Set();
const subscribed = [];
for (const file of files) {
const src = fs.readFileSync(file, 'utf8');
for (const m of src.matchAll(/\b(?:Meteor\.publish|publishComposite)\(\s*['"]([\w.-]+)['"]/g)) {
published.add(m[1]);
}
// server/notifications/* register with Notifications.subscribe(), which is
// WeKan's own notifier registry, not a DDP subscription.
for (const m of src.matchAll(/(\w+)\.subscribe\(\s*['"]([\w.-]+)['"]/g)) {
if (m[1] === 'Notifications') continue;
subscribed.push({ name: m[2], file: path.relative(ROOT, file) });
}
}
console.log('subscriptionsArePublished:');
test('the notifications drawer subscribes to the attachments publication by its real name', () => {
const drawer = fs.readFileSync(
path.join(ROOT, 'client/components/notifications/notificationsDrawer.js'), 'utf8');
assert.ok(drawer.includes("Meteor.subscribe('notificationAttachments')"));
assert.ok(published.has('notificationAttachments'));
});
test('the scan sees the publications it is checking against', () => {
assert.ok(published.size >= 50, `found only ${published.size} publications`);
assert.ok(subscribed.length >= 50, `found only ${subscribed.length} subscriptions`);
});
test('no subscribe() names a publication that does not exist (negative)', () => {
const missing = subscribed.filter(s => !published.has(s.name))
.map(s => `${s.file}: '${s.name}'`);
assert.deepStrictEqual([...new Set(missing)], [],
'these subscriptions name no publication, so they never become ready');
});
console.log(`\nsubscriptionsArePublished: ${passed} tests passed`);