Files
wekan/server/lib/adminCollectionPermission.js
Lauri Ojansivu 216146edc9 Restrict Organization and Team DDP writes.
Thanks to Char0n1507 and xet7 !

Fixes GHSA-p4cq-83j9-7g73.
2026-08-21 23:41:09 +03:00

22 lines
854 B
JavaScript

import { Meteor } from 'meteor/meteor';
import { tripCanary } from '/server/lib/canary';
// Organization and Team configuration is instance/tenant administration data.
// Client-side collection mutations are therefore site-admin only; scoped writes
// run through server methods that enforce their own tenant/admin contract.
//
// TenantBleed (GHSA-p4cq-83j9-7g73): Org and Team previously also allowed any
// authenticated user to mutate a document whose _id equalled their user id.
// A document id is not an authorization relationship.
export async function allowSiteAdminCollectionMutation(userId) {
if (!userId) return false;
const user = await Meteor.users.findOneAsync(userId, {
fields: { isAdmin: 1 },
});
if (user?.isAdmin) return true;
if (user) {
tripCanary('tenant.mutate-without-admin', { userId });
}
return false;
}