← Security advisories

Claude MCP skill privilege escalation — skill team workspace and project management endpoints — SA-SKL-PRIVESC34

SA-SKL-PRIVESC34 documents four privilege escalation vulnerabilities in MCP skill registry team workspace and project management endpoints. Team workspaces are multi-tenant trust boundaries: they group users, skills, and projects under a shared authorization model where roles — viewer, member, maintainer, admin, owner — control what each member can read, write, and administer. All four PRIVESC34 findings allow an attacker to exceed the access level their legitimate workspace role permits, either by forging JWT claims, bypassing role boundary validation on project creation, modifying other users' membership roles without ownership authorization, or exploiting cache key collisions that bleed invite tokens across workspaces.

SA-SKL-PRIVESC34 findings at a glance
CRITICALPRIVESC34-001 — team workspace role read from JWT teamWorkspaceRole claim — craft JWT with teamWorkspaceRole:'owner' grants owner-level privileges including billing control and member management for victim workspaces; fix: DB-backed 60s Map cache keyed on userId+workspaceId; JWT carries only sub; invalidate on role change event
CRITICALPRIVESC34-002 — POST /api/workspaces/:id/projects missing role boundary check — any workspace member creates projects with roles exceeding their own workspace membership level; fix: requireSession; validate project role does not exceed requesting user's workspace role; Zod ProjectRoleSchema; audit log
CRITICALPRIVESC34-003 — PATCH /api/workspaces/:id/members/:userId missing ownership check — any authenticated user modifies any other account's workspace membership role, escalating viewer to admin; fix: require workspace.ownerId === req.session.userId OR req.session.userId === targetMemberId; requireSession; audit log
HIGHPRIVESC34-004 — workspace invite token cache key uses inviteCode without workspaceId — invite token cache entries bleed across workspace deletion and recreation: expired invite from deleted workspace served to new workspace with same sequential integer ID; fix: cache key = workspaceId:inviteCode; invalidate on workspace deletion; strict 60s TTL

PRIVESC34-001 — JWT teamWorkspaceRole claim forgery grants billing control and member management

Severity: CRITICAL

The workspace authorization middleware reads the caller's workspace role from the teamWorkspaceRole claim in the JWT access token. The JWT is signed by the registry's authentication service, but the claim value is set at token issuance time and is not re-validated against the database on subsequent requests. An attacker who can generate a JWT with an arbitrary teamWorkspaceRole claim — either by exploiting a JWT signing weakness, by using a token obtained during a period when they held a higher role before demotion, or by using a JWT from one workspace that is accepted by another workspace's authorization middleware — can present a JWT with teamWorkspaceRole: 'owner' and gain owner-level access to any workspace their user ID has any membership in.

Owner-level access in a team workspace includes the ability to manage billing (change subscription plan, cancel subscriptions), remove members including other admins, delete the workspace itself, and modify workspace-wide security policies. For attacker users who are legitimate members at viewer or member level, escalating to owner via a forged JWT claim represents a complete takeover of the workspace's skills, billing, and member roster. The fix replaces JWT-claim-based role resolution with a DB-backed in-process cache keyed on userId+workspaceId with a 60-second TTL, invalidated on any role change event. The JWT carries only the sub (user ID); the workspace role is always read from the authoritative database.

Vulnerable
// Workspace auth middleware — role from JWT claim, never re-validated
function requireWorkspaceRole(minRole) {
  return (req, res, next) => {
    // teamWorkspaceRole comes from JWT — attacker can forge this claim
    const role = req.user.teamWorkspaceRole;
    if (!hasMinRole(role, minRole)) {
      return res.status(403).json({ error: 'Insufficient workspace role' });
    }
    req.workspaceRole = role;
    next();
  };
}
Fixed
// Workspace auth middleware — role from DB cache, never from JWT
const workspaceRoleCache = new Map(); // key: `${userId}:${workspaceId}`, value: { role, expiresAt }

async function requireWorkspaceRole(minRole) {
  return async (req, res, next) => {
    const workspaceId = req.params.id;
    const userId = req.user.sub; // JWT carries only sub — no role claims trusted
    const cacheKey = `${userId}:${workspaceId}`;
    const cached = workspaceRoleCache.get(cacheKey);

    let role;
    if (cached && cached.expiresAt > Date.now()) {
      role = cached.role;
    } else {
      const membership = await WorkspaceMember.findOne({ workspaceId, userId, status: 'active' });
      if (!membership) return res.status(403).json({ error: 'Not a workspace member' });
      role = membership.role;
      workspaceRoleCache.set(cacheKey, { role, expiresAt: Date.now() + 60_000 });
    }

    if (!hasMinRole(role, minRole)) {
      return res.status(403).json({ error: 'Insufficient workspace role' });
    }
    req.workspaceRole = role;
    next();
  };
}

PRIVESC34-002 — Project creation missing role boundary check allows role escalation via project membership

Severity: CRITICAL

The POST /api/workspaces/:id/projects endpoint creates a new project within a workspace and assigns roles to project members. The endpoint validates that the caller is a workspace member but does not validate that the project roles assigned to other members are within the bounds of their current workspace membership level. An attacker who is a workspace member with the member role can create a project and assign themselves or another user the owner project role, which carries permissions that exceed the workspace member level — including the ability to delete the project, manage project billing, and add project members with arbitrary roles.

Project roles cascade: a project owner can perform actions within that project that a workspace member cannot perform at the workspace level. This creates a privilege escalation path: an attacker with low workspace membership obtains project-owner-level access through project creation, then uses that access to modify skills and configurations within the project that affect the workspace. The fix requires session authentication, validates that the requested project role for each assigned member does not exceed that member's current workspace role using a strict role hierarchy comparison, enforces Zod ProjectRoleSchema validation, and logs every project creation with the assigning user's workspace role for audit purposes.

PRIVESC34-003 — Workspace member PATCH missing ownership check enables cross-account role escalation

Severity: CRITICAL

The PATCH /api/workspaces/:id/members/:userId endpoint modifies a workspace member's role. The endpoint validates that the caller is authenticated but does not validate that the caller owns the workspace or has sufficient administrative authority over the workspace to modify another member's role. Any authenticated user who knows the workspace ID and target user ID can send a PATCH request modifying the target's workspace role to any value, including escalating a viewer to admin.

The practical impact has two dimensions. First, an attacker with any workspace membership can escalate their own role to admin or owner, gaining full workspace control. Second, an attacker can demote legitimate admins and owners to viewer level as part of a lockout attack — combined with adding their own account to the workspace at owner level, this constitutes a complete workspace takeover. The endpoint also does not emit an audit log entry, so the role change is not recorded and may not be discovered until an impacted user notices that their access has changed. The fix requires that the caller is the workspace owner, an admin whose role is higher than the target's current role, or the target user themselves (allowing self-demotion only), enforces these checks before the update, and writes an audit log entry on every role change.

Membership modification endpoints are the most dangerous IDOR surface in multi-tenant applications. An attacker who can modify any user's role in any workspace can silently escalate their own access, lock out legitimate administrators, and take complete control of the workspace and all its contained resources. Always enforce that membership modification requires the caller to be the workspace owner, an admin with higher authority than the target, or the target themselves — and always write an audit log entry before returning a success response.

PRIVESC34-004 — Invite token cache key collision bleeds expired tokens across workspaces

Severity: HIGH

The workspace invite system caches invite token validations using inviteCode as the sole cache key. When a workspace is deleted and subsequently recreated — a common pattern in development and testing environments where workspace IDs are assigned as sequential integers — the new workspace may receive the same sequential integer ID as a deleted workspace. If an invite token from the deleted workspace is still in the cache (within its TTL), the cache entry is served for the new workspace with the same ID, granting access to the new workspace to holders of the expired invite from the deleted workspace.

The practical exploit scenario: an attacker who was a member of a now-deleted workspace retains their invite token from that workspace. They wait for the workspace ID to be reused by a new workspace (sequential integer allocation makes this predictable in environments where workspace creation and deletion is frequent). When the new workspace is created with the matching ID, the attacker's cached invite token is accepted without re-validation, granting them membership in the new workspace. The fix changes the cache key to workspaceId:inviteCode, adds an explicit cache invalidation on workspace deletion, reduces the cache TTL to 60 seconds, and always verifies that the workspace ID on the cached invite record matches the workspace ID in the request before serving the cached entry.

Vulnerable
// Invite token validation — cache key uses only inviteCode
const inviteCache = new Map();

async function validateInviteToken(workspaceId, inviteCode) {
  // Cache key: inviteCode only — bleeds across workspaces with same sequential ID
  if (inviteCache.has(inviteCode)) {
    return inviteCache.get(inviteCode); // serves deleted workspace's invite to new workspace
  }
  const invite = await WorkspaceInvite.findOne({ inviteCode });
  if (invite) inviteCache.set(inviteCode, invite);
  return invite;
}
Fixed
// Invite token validation — cache key includes workspaceId
const inviteCache = new Map();

async function validateInviteToken(workspaceId, inviteCode) {
  // Cache key: workspaceId:inviteCode — no bleed across workspace ID reuse
  const cacheKey = `${workspaceId}:${inviteCode}`;
  const cached = inviteCache.get(cacheKey);

  if (cached && cached.expiresAt > Date.now()) {
    // Always verify workspaceId matches — defense-in-depth against future cache bugs
    if (cached.invite.workspaceId !== workspaceId) {
      inviteCache.delete(cacheKey);
      return null;
    }
    return cached.invite;
  }

  const invite = await WorkspaceInvite.findOne({
    inviteCode,
    workspaceId, // ownership enforced in query
    expiresAt: { $gt: new Date() },
  });

  if (invite) {
    inviteCache.set(cacheKey, {
      invite,
      expiresAt: Date.now() + 60_000, // 60s TTL
    });
  }
  return invite;
}

// Called on workspace deletion — clears all invite cache entries for deleted workspace
function invalidateWorkspaceInviteCache(workspaceId) {
  for (const key of inviteCache.keys()) {
    if (key.startsWith(`${workspaceId}:`)) inviteCache.delete(key);
  }
}

Remediation summary

FindingSeverityPrimary remediationSecondary hardening
PRIVESC34-001CriticalDB-backed role cache keyed on userId+workspaceId; JWT carries only subCache invalidation on role change event; 60s TTL
PRIVESC34-002CriticalValidate project role ≤ requesting user's workspace role; Zod ProjectRoleSchemaAudit log on every project creation
PRIVESC34-003CriticalRequire caller = workspace owner OR admin with higher role than targetAudit log on every membership role change
PRIVESC34-004HighCache key = workspaceId:inviteCode; invalidate on workspace deletionStrict 60s TTL; workspaceId verification before serving cached entry

Find privilege escalation vulnerabilities like these before attackers do. SkillAudit scans your MCP skill registry workspace endpoints for all four SA-SKL-PRIVESC34 patterns plus the broader privilege escalation advisory series. See the SA-SKL-PRIVESC33 audit history advisory and the SA-SKL-PRIVESC32 collaboration management advisory for related findings. Connect your repository at skillaudit.dev.