← Security advisories

Claude MCP skill privilege escalation — skill team member and organization management endpoints — SA-SKL-PRIVESC29

SA-SKL-PRIVESC29 documents four privilege escalation vulnerabilities in MCP skill registry team member and organization management endpoints. These endpoints control the full scope of organizational authority within the registry: team role assignment, member invitation with role specification, organization settings including SSO configuration and security policy gates, and invitation token management. JWT-embedded team role claims allow any JWT holder to forge owner-level privileges without compromising the database. Missing role boundary checks on member invitation let any org member invite external attackers with admin or owner roles. Missing ownership checks on settings mutation allow any authenticated user to modify any organization's SSO and audit policy. And invite token cache key collisions bleed expired invites across organizational boundaries.

SA-SKL-PRIVESC29 findings at a glance
CRITICALPRIVESC29-001 — team role read from JWT teamRole claim; craft JWT with teamRole:'owner' grants owner-level privileges including billing control, member deletion, and org-wide API key revocation
CRITICALPRIVESC29-002 — POST /api/orgs/:id/members missing role boundary check; any org member adds new members with roles exceeding their own role level (e.g., member grants admin to external attacker)
CRITICALPRIVESC29-003 — PATCH /api/orgs/:id/settings missing ownership check; any authenticated user modifies any org's settings including SSO configuration, audit log retention, and security policy gates
HIGHPRIVESC29-004 — org invite token cache key uses inviteCode without orgId; invite token cache entries bleed across orgs: expired invite from one org served to new org that generates same token prefix

PRIVESC29-001 — JWT teamRole claim forgery grants owner-level privileges

Team role authorization reads the user's current role from the teamRole claim embedded in the JWT at login time. The JWT is signed with the registry's key, so the attacker cannot modify it in transit without invalidating the signature. However, the attacker can craft a new JWT using any JWT creation tool and submit it to any endpoint that trusts the teamRole claim as an authoritative role indicator. If the JWT signing secret is weak or has been exposed through a credential leak elsewhere, the attacker signs the JWT themselves. If the signing is robust, the attacker waits until they hold a legitimate JWT as an org member, then uses that session to call any endpoint that promotes their role before the JWT expires — but the structural vulnerability is that the JWT claim is trusted without a database verification step.

The JWT teamRole claim should be treated as a hint for display purposes only, never as an authorization gate. Owner-level actions — billing mutations, member deletion, org-wide API key revocation, SSO configuration changes — have irreversible or long-lasting consequences. Reading the authorization level from an immutable token rather than a database record means that a role demotion applied in the database (e.g., after detecting suspicious activity) has no effect until the user's JWT expires. An owner who is demoted to member retains full owner-level API access for the remaining JWT lifetime.

PRIVESC29-001 fix: Read team role from a DB-backed in-process cache (new Map()) keyed on userId:orgId with a 60-second TTL. The JWT carries only the sub (user ID) and orgId — never the role. On every request, hydrate the role from the cache if the entry is fresh, or query the database and update the cache. Invalidate the cache entry on any role change event (via an event bus or a direct cache delete call in the role-assignment handler). This ensures that role demotions take effect within 60 seconds of the database update rather than waiting for JWT expiry.

WRONG
// Role from JWT claim — no DB verification
function requireRole(minRole) {
  return (req, res, next) => {
    const { teamRole } = req.jwt;  // attacker controls this via JWT forgery
    if (ROLE_RANK[teamRole] >= ROLE_RANK[minRole]) return next();
    res.status(403).json({ error: 'forbidden' });
  };
}
RIGHT
// DB-backed cache: role from database, not JWT
const roleCache = new Map();  // key: userId:orgId, value: { role, expiresAt }

async function getRole(userId, orgId) {
  const key = `${userId}:${orgId}`;
  const cached = roleCache.get(key);
  if (cached && cached.expiresAt > Date.now()) return cached.role;
  const { role } = await db.getMembership(userId, orgId);
  roleCache.set(key, { role, expiresAt: Date.now() + 60_000 });
  return role;
}

function requireRole(minRole) {
  return async (req, res, next) => {
    const role = await getRole(req.session.userId, req.session.orgId);
    if (ROLE_RANK[role] >= ROLE_RANK[minRole]) return next();
    res.status(403).json({ error: 'forbidden' });
  };
}

PRIVESC29-002 — Member invitation missing role boundary check enables external attacker escalation

The member invitation endpoint at POST /api/orgs/:id/members accepts an email address and a role to assign to the invited user. When the endpoint does not validate that the invited role is at or below the inviting user's current role, any org member — regardless of their own role level — can invite an external attacker with the owner or admin role. The invited user accepts the invitation, gains the specified role, and now has full owner-level access to the organization. The compromised member account is not elevated; instead, a fresh account owned by the attacker is created with owner-level authority directly.

This vulnerability is particularly dangerous for organizations that use the member invitation workflow as part of an automated onboarding process — a CI pipeline that programmatically invites contractors with a specified role, or an HR integration that uses the API to provision access. If the system performing these invitations is ever compromised, the attacker can inject an invitation for an attacker-controlled email address with the owner role without needing to compromise any administrative credential.

PRIVESC29-002 fix: After authenticating the inviting user and reading their current role from the DB-backed cache, validate that the requested invitation role is strictly less than or equal to the inviting user's role: if (ROLE_RANK[invitedRole] > ROLE_RANK[invitingUserRole]) return res.status(403).json({ error: 'cannot_invite_higher_role' }). Apply a Zod RoleSchema that restricts invitedRole to the set of valid role strings. Write an audit log entry and emit a notification to org admins on every member invitation event.

PRIVESC29-003 — Org settings missing ownership check enables cross-org SSO and policy modification

The organization settings endpoint at PATCH /api/orgs/:id/settings accepts updates to SSO configuration, audit log retention period, minimum grade gate for skill installation policy, and other security-sensitive settings. The endpoint validates that the requesting user is an admin role but does not validate that the organization ID in the route parameter matches the requesting session's organization. Any user with admin-level access to any organization in the registry can submit a PATCH request with an arbitrary orgId in the URL and modify that organization's settings.

SSO configuration is the most sensitive target. By modifying another organization's SSO configuration to point to an attacker-controlled identity provider, the attacker can intercept all future logins to that organization, receive the SSO assertion for any user who authenticates during the attack window, and use those assertions to log in as any member of the targeted organization. The modification appears in the registry's admin interface as a settings change but does not generate a security alert unless the organization has specifically configured notifications for settings changes.

PRIVESC29-003 fix: Add an explicit check that req.params.id === req.session.orgId before processing any settings update — reject with 403 if they do not match. Add requireRole('admin') using the DB-backed role cache. Write an audit log entry for every settings change. Emit a notification to all org owners when SSO configuration, audit log retention, or security policy gates are modified.

WRONG
router.patch('/orgs/:id/settings',
  requireSession,
  requireRole('admin'),  // checks role but not org ownership
  async (req, res) => {
    // No check that req.params.id === req.session.orgId
    await db.updateOrgSettings(req.params.id, req.body);
    res.json({ updated: true });
  }
);
RIGHT
router.patch('/orgs/:id/settings',
  requireSession,
  requireRole('admin'),
  async (req, res) => {
    // Ownership check: can only modify your own org's settings
    if (req.params.id !== req.session.orgId) {
      return res.status(403).json({ error: 'forbidden' });
    }
    const settings = OrgSettingsSchema.parse(req.body);
    await db.updateOrgSettings(req.params.id, settings);
    await auditLog.write({ event: 'org_settings_updated', orgId: req.params.id,
      actor: req.session.userId, changes: Object.keys(settings) });
    if (settings.ssoConfig) {
      await notify.sendToOrgOwners(req.params.id, 'SSO configuration was modified');
    }
    res.json({ updated: true });
  }
);

PRIVESC29-004 — Invite token cache key collision bleeds expired invites across orgs

Organization invite tokens are cached in memory using only the inviteCode as the cache key — the organization ID is not included. When an invite token expires and the memory cache entry is invalidated, a new organization that subsequently generates an invite code with the same token prefix (or the same token, in systems that use short tokens with limited entropy) will cause the new cache entry to collide with the tombstone or stale entry from the previous organization. In a worst-case scenario, the previously expired invite token from Organization A is served from the cache to Organization B, allowing a user who possesses the expired token from Organization A to join Organization B — potentially with the role that Organization B's invitation specified rather than any role at Organization A.

PRIVESC29-004 fix: Include the orgId in the cache key: cache.set(`${orgId}:${inviteCode}`, entry). Validate the orgId from the cache entry against the orgId in the invite acceptance request before serving the cached invite. Set a strict 60-second TTL. Use high-entropy random tokens (at least 128 bits from crypto.randomBytes) to minimize collision probability. Invalidate cache entries on invite expiry, revocation, and acceptance events.

SkillAudit's privilege escalation scanner detects JWT claim trust patterns, missing role boundary checks, missing ownership checks, and cache key collision vulnerabilities across your registry's organization management router in a single scan. Get started free.