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 !
64 lines
2.9 KiB
JavaScript
64 lines
2.9 KiB
JavaScript
'use strict';
|
|
|
|
// AuthBleed (https://wekan.fi/hall-of-fame/authbleed/): getServiceConfiguration
|
|
// ("oidc") returned the whole OIDC configuration to any caller, client secret
|
|
// included. It returns the public part now. The copy/move findings of the same
|
|
// entry are tests/authBleedCopyMethods.test.cjs.
|
|
// Run: node tests/authBleedServiceConfiguration.test.cjs
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const root = path.join(__dirname, '..');
|
|
const read = p => fs.readFileSync(path.join(root, p), 'utf8');
|
|
const pending = [];
|
|
const test = (name, fn) => pending.push([name, fn]);
|
|
|
|
// The real method, cut out of server/models/settings.js and run with a stub.
|
|
const settings = read('server/models/settings.js');
|
|
const start = settings.indexOf('async getServiceConfiguration(service) {');
|
|
const body = settings.slice(start, settings.indexOf('\n },', start) + 4);
|
|
const method = new Function('check', 'loadOidcConfig', `return ({ ${body} }).getServiceConfiguration;`)(
|
|
() => {},
|
|
async service => (service === 'oidc' ? { clientId: 'id', secret: 'TOP-SECRET', loginStyle: 'redirect', serverUrl: 'https://idp' } : null),
|
|
);
|
|
|
|
test('the OIDC configuration comes back without its client secret', async () => {
|
|
const config = await method('oidc');
|
|
assert.strictEqual(config.clientId, 'id');
|
|
assert.strictEqual(config.loginStyle, 'redirect');
|
|
assert.ok(!('secret' in config), 'no secret');
|
|
assert.ok(!JSON.stringify(config).includes('TOP-SECRET'));
|
|
assert.strictEqual(await method('nope'), null);
|
|
});
|
|
|
|
test('negative: nothing else hands a service configuration with its secret to a client', () => {
|
|
// Every server Meteor method or publication that reads a service
|
|
// configuration must leave the secret out.
|
|
const walk = dir => fs.readdirSync(path.join(root, dir), { withFileTypes: true }).flatMap(e => {
|
|
const rel = path.join(dir, e.name);
|
|
if (e.isDirectory()) return ['node_modules', 'tests', '.npm'].includes(e.name) ? [] : walk(rel);
|
|
return /\.js$/.test(e.name) ? [rel] : [];
|
|
});
|
|
for (const file of [...walk('server'), ...walk('packages')]) {
|
|
const src = read(file);
|
|
// A publication of the raw configurations collection with its secrets.
|
|
assert.ok(!/Meteor\.publish\([^)]*\)[\s\S]{0,400}ServiceConfiguration\.configurations\.find\((\{\s*\}|)\)/.test(src),
|
|
`${file}: publishes service configurations unfiltered`);
|
|
for (const m of src.matchAll(/loadOidcConfig\(/g)) {
|
|
const around = src.slice(m.index, m.index + 600);
|
|
if (/return\s+config\s*;/.test(around.split('\n },')[0])) {
|
|
assert.fail(`${file}: returns a loaded OIDC config whole`);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
(async () => {
|
|
let passed = 0;
|
|
console.log('authBleedServiceConfiguration:');
|
|
for (const [name, fn] of pending) { await fn(); passed += 1; console.log(' ok -', name); }
|
|
console.log(`authBleedServiceConfiguration: ${passed} passed`);
|
|
})().catch(e => { console.error(e); process.exit(1); });
|