Claude MCP skill privilege escalation via IDOR in organization management — SA-SKL-PRIVESC5
Multi-tenant MCP skill registries that support team organizations must enforce object-level authorization on every mutating endpoint — not just resource existence, but whether the authenticated user has the right to perform that specific action on that specific object. Insecure direct object references (IDOR) in organization management endpoints enable regular users to accept invites meant for others, promote themselves to admin, transfer skills to organizations that never consented, and leave active API keys behind after deleting their organization. SA-SKL-PRIVESC5 covers four such patterns.
PRIVESC5-001 — Invite acceptance without recipient validation
When a team admin invites alice@example.com to join with the admin role, the system creates an invite record with a random ID. The invite acceptance URL (/api/orgs/:orgId/invites/:inviteId/accept) is typically sent by email to the recipient. But if the endpoint only checks that the invite exists (not that the authenticated user is alice@example.com), any registered user who knows the invite ID can accept it and join the org as alice's role. Invite IDs are often predictable ULIDs or UUIDs that may be guessable or leaked via shared links.
// VULNERABLE — PRIVESC5-001
// Invite acceptance checks invite exists and belongs to org, but not whether
// the authenticated user is the designated recipient.
// Attacker who discovers or guesses inviteId accepts the invite and joins as admin.
app.post('/api/orgs/:orgId/invites/:inviteId/accept', requireAuth, async (req, res) => {
const { orgId, inviteId } = req.params;
const invite = await db.invites.findOne({
id: inviteId,
orgId,
status: 'pending',
});
if (!invite) return res.status(404).json({ error: 'Invite not found' });
// VULNERABLE: does not check invite.recipientEmail === req.user.email
// Any authenticated user can accept any pending invite
await db.orgMembers.insert({
orgId,
userId: req.user.id,
role: invite.role, // attacker gets whatever role was intended for the real recipient
});
await db.invites.update({ id: inviteId }, { status: 'accepted', acceptedBy: req.user.id });
res.json({ message: 'Joined organization', role: invite.role });
});
// FIXED — PRIVESC5-001
// Fix: Verify that the authenticated user's email matches the invite recipient email.
// Also mark the invite single-use so it cannot be accepted again.
app.post('/api/orgs/:orgId/invites/:inviteId/accept', requireAuth, async (req, res) => {
const { orgId, inviteId } = req.params;
const invite = await db.invites.findOne({
id: inviteId,
orgId,
status: 'pending',
});
if (!invite) return res.status(404).json({ error: 'Invite not found' });
// FIX: Verify the authenticated user is the designated recipient
if (invite.recipientEmail.toLowerCase() !== req.user.email.toLowerCase()) {
return res.status(403).json({ error: 'This invite was not sent to your account' });
}
// FIX: Check invite has not expired
if (invite.expiresAt < Date.now()) {
return res.status(410).json({ error: 'Invite has expired' });
}
await db.orgMembers.insert({ orgId, userId: req.user.id, role: invite.role });
await db.invites.update({ id: inviteId }, { status: 'accepted', acceptedAt: new Date() });
res.json({ message: 'Joined organization', role: invite.role });
});
PRIVESC5-002 — Role self-promotion without admin role check
Organization role management endpoints often perform two checks: does the requesting user belong to the org, and does the target member belong to the org. The critical third check — does the requester hold the admin role within the org — is frequently forgotten. A regular member who discovers the role update endpoint can send a PATCH request setting their own memberId and role: "admin". Since they're a valid org member, the first check passes. Since they're targeting their own membership ID, the second check passes. Without the admin-role check, they successfully promote themselves.
// VULNERABLE — PRIVESC5-002
// Role update checks org membership for both requester and target, but not
// whether the requester is an admin.
// Regular member sends: PATCH /api/orgs/abc/members/my-member-id { role: "admin" }
app.patch('/api/orgs/:orgId/members/:memberId/role', requireAuth, async (req, res) => {
const { orgId, memberId } = req.params;
const { role } = req.body;
if (!['member', 'admin', 'owner'].includes(role)) {
return res.status(400).json({ error: 'Invalid role' });
}
// Check requester is in org
const requesterMembership = await db.orgMembers.findOne({
orgId, userId: req.user.id,
});
if (!requesterMembership) return res.status(403).json({ error: 'Not an org member' });
// Check target membership exists
const targetMembership = await db.orgMembers.findOne({ id: memberId, orgId });
if (!targetMembership) return res.status(404).json({ error: 'Member not found' });
// VULNERABLE: requesterMembership.role never checked — any member can change any role
await db.orgMembers.update({ id: memberId }, { role });
res.json({ message: 'Role updated' });
});
// FIXED — PRIVESC5-002
// Fix: Require the requester to hold the admin role before processing role changes.
// Also prevent non-owners from promoting others to owner.
app.patch('/api/orgs/:orgId/members/:memberId/role', requireAuth, async (req, res) => {
const { orgId, memberId } = req.params;
const { role } = req.body;
if (!['member', 'admin'].includes(role)) {
return res.status(400).json({ error: 'Invalid role' });
}
const requesterMembership = await db.orgMembers.findOne({
orgId, userId: req.user.id,
});
// FIX: Require admin role to change other members' roles
if (!requesterMembership || requesterMembership.role !== 'admin') {
return res.status(403).json({ error: 'Admin role required' });
}
const targetMembership = await db.orgMembers.findOne({ id: memberId, orgId });
if (!targetMembership) return res.status(404).json({ error: 'Member not found' });
// FIX: Prevent demoting the last admin (would orphan the org)
if (role !== 'admin') {
const adminCount = await db.orgMembers.count({ orgId, role: 'admin' });
if (adminCount <= 1 && targetMembership.role === 'admin') {
return res.status(409).json({ error: 'Cannot demote the last admin' });
}
}
await db.orgMembers.update({ id: memberId }, { role });
res.json({ message: 'Role updated' });
});
PRIVESC5-003 — Skill transfer without target organization consent
MCP skill transfer endpoints allow an author to move their skill to an organization. The endpoint typically verifies that the authenticated user owns the skill — but not that the target organization has accepted the transfer. An attacker who owns a skill can transfer it to any organization (by guessing or enumerating org IDs), attributing the skill's audit events, security findings, and billing charges to the target organization without its knowledge. If the target org has a minimum-grade policy gate, transferring a vulnerable skill there could also cause CI pipeline failures at the target.
// VULNERABLE — PRIVESC5-003
// Skill transfer checks ownership but not target org acceptance.
// Attacker transfers skill to competitor's org, poisoning their audit profile.
app.post('/api/skills/:skillId/transfer', requireAuth, async (req, res) => {
const { skillId } = req.params;
const { targetOrgId } = req.body;
const skill = await db.skills.findOne({ id: skillId, authorId: req.user.id });
if (!skill) return res.status(403).json({ error: 'Not skill owner' });
const targetOrg = await db.orgs.findOne({ id: targetOrgId });
if (!targetOrg) return res.status(404).json({ error: 'Organization not found' });
// VULNERABLE: does not check that targetOrg has an accepted pending transfer for this skill
await db.skills.update({ id: skillId }, { orgId: targetOrgId, authorId: null });
res.json({ message: 'Skill transferred' });
});
// FIXED — PRIVESC5-003
// Fix: Require a pending transfer acceptance from a target org admin before completing transfer.
// Two-phase: (1) author initiates transfer → org admin receives email → (2) org admin accepts.
// Phase 1: Author initiates transfer (creates pending transfer record)
app.post('/api/skills/:skillId/transfer/initiate', requireAuth, async (req, res) => {
const { skillId } = req.params;
const { targetOrgId } = req.body;
const skill = await db.skills.findOne({ id: skillId, authorId: req.user.id });
if (!skill) return res.status(403).json({ error: 'Not skill owner' });
// FIX: Create pending transfer — target org admin must accept
const transfer = await db.skillTransfers.insert({
skillId,
fromUserId: req.user.id,
toOrgId: targetOrgId,
status: 'pending',
expiresAt: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000), // 7 days
});
await notifyOrgAdmins(targetOrgId, 'skill_transfer_request', { transfer, skill });
res.json({ message: 'Transfer request sent', transferId: transfer.id });
});
// Phase 2: Target org admin accepts transfer
app.post('/api/orgs/:orgId/skill-transfers/:transferId/accept', requireAuth, async (req, res) => {
const { orgId, transferId } = req.params;
// FIX: Verify requester is an admin of the target org
const membership = await db.orgMembers.findOne({ orgId, userId: req.user.id, role: 'admin' });
if (!membership) return res.status(403).json({ error: 'Org admin required' });
const transfer = await db.skillTransfers.findOne({
id: transferId, toOrgId: orgId, status: 'pending',
});
if (!transfer || transfer.expiresAt < Date.now()) {
return res.status(404).json({ error: 'Transfer not found or expired' });
}
await db.skills.update({ id: transfer.skillId }, { orgId });
await db.skillTransfers.update({ id: transferId }, { status: 'accepted' });
res.json({ message: 'Transfer accepted' });
});
PRIVESC5-004 — Organization deletion without skill and API key revocation
When an organization is deleted, all associated resources — published skills, issued API keys, active webhooks — must be revoked or transferred. If the deletion handler only marks the org record as deleted: true without cascading to skills and API keys, an attacker can abuse this to get free hosting: create an org, publish skills under it, issue API keys, then delete the org. The skills remain publicly published and the API keys remain valid, but the billing attribution is now to a deleted entity. Depending on the registry's billing model, this means continued usage with no active payment method.
// VULNERABLE — PRIVESC5-004
// Org deletion only marks the org deleted — associated resources remain active.
app.delete('/api/orgs/:orgId', requireAuth, async (req, res) => {
const { orgId } = req.params;
const membership = await db.orgMembers.findOne({
orgId, userId: req.user.id, role: 'admin',
});
if (!membership) return res.status(403).json({ error: 'Admin required' });
// VULNERABLE: soft-delete the org record only
// org.skills remain published, org.apiKeys remain valid, org.webhooks still receive callbacks
await db.orgs.update({ id: orgId }, { deletedAt: new Date(), status: 'deleted' });
res.json({ message: 'Organization deleted' });
});
// FIXED — PRIVESC5-004
// Fix: Cascade deletion to all associated resources.
// Skills: unpublish. API keys: revoke. Webhooks: deactivate.
// Use a database transaction to ensure atomicity.
app.delete('/api/orgs/:orgId', requireAuth, async (req, res) => {
const { orgId } = req.params;
const membership = await db.orgMembers.findOne({
orgId, userId: req.user.id, role: 'admin',
});
if (!membership) return res.status(403).json({ error: 'Admin required' });
// FIX: Cascade deletion in a single transaction
await db.transaction(async (trx) => {
// FIX: Unpublish all org skills (removes them from public registry)
await trx.skills.update(
{ orgId, status: 'published' },
{ status: 'unpublished', unpublishedReason: 'org_deleted', unpublishedAt: new Date() }
);
// FIX: Revoke all API keys issued under this org
await trx.apiKeys.update(
{ orgId, revokedAt: null },
{ revokedAt: new Date(), revokeReason: 'org_deleted' }
);
// FIX: Deactivate all webhooks
await trx.webhooks.update({ orgId }, { active: false });
// FIX: Remove all org members
await trx.orgMembers.delete({ orgId });
// FIX: Mark org deleted
await trx.orgs.update({ id: orgId }, { deletedAt: new Date(), status: 'deleted' });
});
res.json({ message: 'Organization and all associated resources deleted' });
});
Soft delete vs hard delete for skills: Never hard-delete published skill records — other users may have installed the skill and need to see that it has been removed (rather than getting a 404 that looks like a server error). The status: 'unpublished' approach lets the registry show a "this skill has been removed" page instead, which is better UX and helps with audit trails for security incident responses.
Summary — SA-SKL-PRIVESC5 at a glance
| Pattern | Root cause | Fix | Severity |
|---|---|---|---|
| PRIVESC5-001 | Invite acceptance without recipient email check | WHERE recipientEmail = req.user.email in invite lookup | CRITICAL |
| PRIVESC5-002 | Role update without admin role check on requester | Require requesterMembership.role === 'admin' | CRITICAL |
| PRIVESC5-003 | Skill transfer without target org acceptance | Two-phase transfer: initiate + org admin accept | HIGH |
| PRIVESC5-004 | Org deletion without cascading to skills and API keys | Transactional cascade: unpublish, revoke, deactivate | HIGH |
SkillAudit's privilege escalation scanner tests all organization management endpoints with crafted requests that probe for missing object-level authorization checks. See also SA-SKL-PRIVESC4 (JWT algorithm confusion) and SA-SKL-AUTH11 (OAuth PKCE bypass).