Files
wekan/server/permissions/users.js
T
Lauri Ojansivu 040d853c8e RedirectBleed hardening: a direct client write of an avatar URL follows setAvatarUrl's rule.
setAvatarUrl refuses javascript:, file:, data:text/html and every scheme but
http(s), data:image and local paths, but the Users allow rule permits every
profile.* field, so Users.update({$set: {'profile.avatarUrl': ...}}) from the
browser console stored what the method refuses. Not exploitable as reported:
the URL is rendered only as an <img src>, and the server fetches it only
through fetchSafe (http/https). The rule is now models/lib/avatarUrlScheme.js,
used by both avatar methods and by a Users deny rule, which logs the refused
write to Admin Panel / Problems as file.avatar-url. No WeKan client code
writes the field directly, which the test checks.

Verified while checking meifukun's GHSA-g98f-44gc-hqcc, GHSA-x6fh-wrr5-3426,
GHSA-28hr-j65r-grj2, GHSA-mrhx-8xm7-chrq and GHSA-83qj-w8mp-w4qf against the
current code: all five were already fixed (tests/securityMeifukun.test.cjs).

Thanks to meifukun and xet7 !
2026-11-16 13:54:08 +02:00

68 lines
2.7 KiB
JavaScript

import Users, { isUserUpdateAllowed, hasForbiddenUserUpdateField, writesNotificationList } from '/models/users';
const { writesUnsafeAvatarUrl } = require('/models/lib/avatarUrlScheme');
Users.allow({
update(userId, doc, fields, modifier) {
// Only the owner can update, and only for allowed fields
if (!userId || doc._id !== userId) {
return false;
}
if (!Array.isArray(fields) || fields.length === 0) {
return false;
}
// Disallow if any forbidden field present
if (hasForbiddenUserUpdateField(fields, modifier)) {
return false;
}
// Allow only username and profile.*
const allowed = isUserUpdateAllowed(fields);
return allowed;
},
remove(userId, doc) {
// Disable direct client-side user removal for security
// All user removal should go through the secure server method 'removeUser'
// This prevents IDOR vulnerabilities and ensures proper authorization checks
return false;
},
fetch: [],
});
// Deny any attempts to touch forbidden fields from client updates
Users.deny({
update(userId, doc, fields, modifier) {
const denied = hasForbiddenUserUpdateField(fields, modifier);
if (denied && fields.some(field => field === 'profile' ||
field === 'profile.invitedBoards' || field.startsWith('profile.invitedBoards.'))) {
try {
require('/server/lib/securityLog').record({
key: 'authz.invitation-profile', action: 'blocked', source: 'ddp:user-profile',
detail: 'Client modification of server-issued board invitations denied.',
});
} catch (e) { /* logging must never break the guard */ }
}
if (writesNotificationList(modifier)) {
// No client code adds to or rewrites the tray; only an attempt reaches here.
try {
require('/server/lib/securityLog').record({
key: 'authz.notification-tray', action: 'blocked', source: 'ddp:user-notifications', userId,
detail: 'Client write of server-issued notification entries denied.',
});
} catch (e) { /* logging must never break the guard */ }
}
// The allow rule above permits every profile.* field, and WeKan's client
// sets an avatar only through the setAvatarUrl method. A direct write of an
// avatar URL that method refuses is an attempt, never ordinary use.
if (writesUnsafeAvatarUrl(modifier)) {
try {
require('/server/lib/securityLog').record({
key: 'file.avatar-url', action: 'blocked', source: 'ddp:user-profile-avatar', userId,
detail: 'Client write of a profile.avatarUrl that setAvatarUrl refuses denied.',
});
} catch (e) { /* logging must never break the guard */ }
return true;
}
return denied;
},
fetch: [],
});