Access middlewares cache the caller's org link on req.userOrg and
req.apiKeyOrg and skip their membership query when it is already set.
A value inherited from a polluted Object.prototype passed that check.
- Give every request its own undefined copy of the cached auth fields
(userOrg, apiKeyOrg, userOrgRoleIds, userOrgId, userOrgIds,
orgPolicyAllowed) before any route runs, on the API, integration,
internal and AI gateway servers.
- Add ownUserOrg/ownApiKeyOrg, which return a cached value only if it is
an own property for the signed-in user or calling key.
- Every user and API key access middleware now uses them and refuses
when the cached org does not match the org of the object being
accessed. verifyApiKeySiteAccess and verifyApiKeySiteResourceAccess
had no org comparison at all once req.apiKeyOrg was set.
Defence in depth for PAN-1814 / GHSA-5fhj.