Files
wekan/tests/userAuthMethodPublication.test.cjs
T
Lauri Ojansivu c15f9486d8 Name today's fixes for the Hall of Fame and give two of them their own Problems keys.
TrayBleed (notification tray writes) and CasTokenBleed (a CAS callback from
a browser that did not start the login) get catalog keys of their own; each
new fix's test names its vulnerability. ReadOnlyBleed gets the permissions
test it was recorded without, pinning the six Custom Field handlers and
requiring a write-level decision on every mutating REST route.

Thanks to xet7 !
2026-10-02 11:53:09 +03:00

30 lines
1.5 KiB
JavaScript

'use strict';
// Guard: AuthMethodBleed (2026-10-02). 'user-authenticationMethod' answered any signed-in user
// with ANY user's organizations, teams and login method, looked up by
// username. It now answers only for the caller's own account.
// Run: node tests/userAuthMethodPublication.test.cjs
const { test } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const src = fs.readFileSync(path.join(__dirname, '..', 'server/publications/users.js'), 'utf8');
const pub = src.slice(src.indexOf("Meteor.publish('user-authenticationMethod'"), src.indexOf('\n});', src.indexOf("Meteor.publish('user-authenticationMethod'")));
test('the lookup is pinned to the caller', () => {
assert.match(pub, /\{ _id: this\.userId, \$or: \[\{ _id: match \}, \{ 'emails\.address': match \}, \{ username: match \}\] \}/);
// Unauthenticated callers still get nothing and are recorded (negative).
assert.match(pub, /if \(!this\.userId\) \{[\s\S]{0,400}return this\.ready\(\);/);
});
test('negative: no publication looks users up by a client-given name with org or team fields', () => {
for (const m of src.matchAll(/Meteor\.publish\('([^']+)'[\s\S]*?\n\}\);/g)) {
const body = m[0];
if (!/\b(orgs|teams): 1/.test(body)) continue;
if (!/username: (match|searchTerm|\w+Regex)/.test(body)) continue;
assert.match(body, /_id: this\.userId/, `${m[1]} publishes other users' orgs/teams`);
}
});