1 Commits
Author SHA1 Message Date
Lauri Ojansivu 875a0065ed Fix PrototypeBleed: user-chosen ids can no longer pollute Object.prototype in the server.
The per-user layout methods keep maps keyed by the ids a client sends -
collapsed lists, cards and swimlanes, list widths and heights, board sort
indexes, workspace assignments - and wrote them as
map[boardId] = map[boardId] || {}; map[boardId][listId] = value. With boardId
'__proto__', map[boardId] is Object.prototype, so any logged-in user could set
a property on every object in the server process until a restart
(Meteor.call('setListCollapsedState', '__proto__', 'isAdmin', true)).

Every function in models/users.js and server/models/users.js that writes such
a map now checks its keys with assertSafeMapKey (models/lib/safeMapKey.js):
never __proto__, constructor or prototype, nor a '.' or leading '$' MongoDB
refuses anyway. A refusal is recorded as PrototypeBleed (no client sends one).
The test runs the real method bodies in their own vm context and shows the
pollution before the guard and none after; the negative test fails on any
id-keyed map write without the check. A browser test makes the reported call.

Thanks to xet7 !
2026-10-02 10:37:08 +03:00