Claude MCP skill privilege escalation — skill publisher and maintainer role assignment endpoints — SA-SKL-PRIVESC39
SA-SKL-PRIVESC39 documents four privilege escalation vulnerabilities in MCP skill registry skill publisher and maintainer role assignment endpoints. These endpoints control who can approve skill submissions, modify skill listings, and access organizational skill data. Each finding provides a path from limited maintainer access to registry-wide administrative control — either by forging JWT claims, exploiting missing role boundary checks, bypassing ownership verification, or exploiting cache key collisions that bleed elevated roles to newly created skills.
maintainerRole claim — craft JWT with maintainerRole:'registry_admin' grants power to approve any skill submission, modify any skill listing, and access all organizations' private skill data; fix: DB-backed 60s Map cache keyed on userId+skillId; JWT carries only sub; invalidate on role change eventPOST /api/skills/:id/maintainers missing role boundary check — any maintainer assigns registry_admin role to themselves or others exceeding their own role level; fix: requireSession; validate assigned role does not exceed assigning user's own role level; Zod MaintainerRoleSchema; audit logPATCH /api/skills/:id/maintainers/:userId/role missing ownership check — any authenticated user modifies any other maintainer's role for any skill, escalating low-privilege accounts to registry_admin; fix: require skill.ownerId === req.session.userId OR registry_admin role; requireSession; audit logskillId without orgId — cache entries bleed across skill deletion and recreation; previously assigned elevated roles served to new skills with same sequential integer ID; fix: cache key = orgId:skillId; invalidate on skill deletion; strict 60s TTLPRIVESC39-001 — JWT maintainerRole claim forgery grants registry_admin access
Severity: CRITICAL
The maintainer role authorization system reads the caller's role level from the maintainerRole claim embedded in the JWT access token. JWT claims are signed but not encrypted — an attacker who knows the signing algorithm can craft a token with maintainerRole: 'registry_admin' if the signing secret is weak, reused across environments, or obtainable via a separate vulnerability. Even without the signing secret, the design is architecturally flawed: role data stored in a JWT cannot be revoked in real time. If a maintainer's role is downgraded after their token was issued, the JWT still carries the old elevated role until the token expires. The registry_admin role grants power to approve any skill submission for publication, modify any skill listing across all organizations, and read all organizations' private skill data.
Never read authorization data from JWT claims in a multi-tenant system. JWTs are suitable for identity claims (subject, issuer) but not for authorization state that must be revocable. Use a database-backed role cache with short TTL (60s) keyed on the user+resource pair. The JWT carries only the user ID; the authorization decision is made by looking up the current role from the authoritative store on each request.
// Maintainer role read from JWT claim — forgeable and not revocable
router.use('/:id/maintainers', requireSession, (req, res, next) => {
req.maintainerRole = req.jwt.claims.maintainerRole; // from JWT
next();
});
router.get('/:id/admin/submissions', (req, res) => {
if (req.maintainerRole !== 'registry_admin') return res.status(403).end();
// attacker crafts JWT with maintainerRole:'registry_admin'
return SkillSubmission.find({});
});
// Maintainer role from DB-backed cache — revocable, non-forgeable
const roleCache = new Map(); // userId:skillId => { role, expiresAt }
async function getMaintainerRole(userId, skillId) {
const key = `${userId}:${skillId}`;
const cached = roleCache.get(key);
if (cached && cached.expiresAt > Date.now()) return cached.role;
const assignment = await MaintainerRole.findOne({ userId, skillId });
const role = assignment?.role ?? 'none';
roleCache.set(key, { role, expiresAt: Date.now() + 60_000 });
return role;
}
// Invalidate on role change
MaintainerRole.events.on('change', ({ userId, skillId }) => {
roleCache.delete(`${userId}:${skillId}`);
});
router.get('/:id/admin/submissions', requireSession, async (req, res) => {
const role = await getMaintainerRole(req.session.userId, req.params.id);
if (role !== 'registry_admin') return res.status(403).end();
return res.json(await SkillSubmission.find({}));
});
PRIVESC39-002 — POST /maintainers missing role boundary check enables self-escalation
Severity: HIGH
The maintainer assignment endpoint allows any authenticated maintainer to assign roles without verifying that the assigned role does not exceed the assigning user's own role level. A maintainer with contributor role can call POST /api/skills/:id/maintainers with a body specifying their own user ID and role: 'registry_admin'. The endpoint creates the assignment without checking whether the caller has the authority to grant registry_admin — which requires holding registry_admin themselves. This enables any maintainer, regardless of their current role level, to self-escalate to registry_admin and then perform all PRIVESC39-001 impacts without needing to forge a JWT.
// POST /api/skills/:id/maintainers — no role boundary check
router.post('/:id/maintainers', requireSession, async (req, res) => {
const { userId, role } = req.body;
// No check: req.session.userId's own role >= assigned role
await MaintainerRole.create({ skillId: req.params.id, userId, role });
return res.status(201).json({ assigned: true });
});
// POST /api/skills/:id/maintainers — role boundary check + Zod + audit log
const ROLE_LEVELS = { contributor: 1, maintainer: 2, admin: 3, registry_admin: 4 };
const MaintainerRoleSchema = z.object({
userId: z.string().uuid(),
role: z.enum(['contributor', 'maintainer', 'admin', 'registry_admin']),
});
router.post('/:id/maintainers', requireSession, async (req, res) => {
const parsed = MaintainerRoleSchema.safeParse(req.body);
if (!parsed.success) return res.status(400).json({ error: 'Invalid role assignment' });
const callerRole = await getMaintainerRole(req.session.userId, req.params.id);
const callerLevel = ROLE_LEVELS[callerRole] ?? 0;
const assignedLevel = ROLE_LEVELS[parsed.data.role];
if (assignedLevel > callerLevel) {
return res.status(403).json({ error: 'Cannot assign role exceeding your own level' });
}
await MaintainerRole.create({
skillId: req.params.id,
userId: parsed.data.userId,
role: parsed.data.role,
assignedBy: req.session.userId,
at: new Date(),
});
await AuditLog.create({
action: 'maintainer.assigned',
actorId: req.session.userId,
targetUserId: parsed.data.userId,
skillId: req.params.id,
role: parsed.data.role,
at: new Date(),
});
roleCache.delete(`${parsed.data.userId}:${req.params.id}`);
return res.status(201).json({ assigned: true });
});
PRIVESC39-003 — PATCH /maintainers/:userId/role missing ownership check
Severity: HIGH
The role modification endpoint allows any authenticated user to change any maintainer's role for any skill without verifying that the caller owns the skill or holds a sufficiently elevated role. An attacker calls PATCH /api/skills/VICTIM_SKILL_ID/maintainers/ATTACKER_USER_ID/role with a body of {"role": "registry_admin"}. Without an ownership check, the endpoint modifies the attacker's own role assignment on a skill they do not own to registry_admin — granting them the same permissions as PRIVESC39-001 without any JWT manipulation. The lack of an audit log means the modification leaves no trace.
// PATCH /api/skills/:id/maintainers/:userId/role — no ownership check
router.patch('/:id/maintainers/:userId/role', requireSession, async (req, res) => {
const { role } = req.body;
await MaintainerRole.findOneAndUpdate(
{ skillId: req.params.id, userId: req.params.userId },
{ role },
{ upsert: true }
);
return res.json({ updated: true });
});
// PATCH /api/skills/:id/maintainers/:userId/role — ownership check + role boundary + audit
router.patch('/:id/maintainers/:userId/role', requireSession, async (req, res) => {
const parsed = z.object({ role: z.enum(['contributor', 'maintainer', 'admin', 'registry_admin']) })
.safeParse(req.body);
if (!parsed.success) return res.status(400).json({ error: 'Invalid role' });
// Caller must be skill owner OR registry_admin
const skill = await Skill.findById(req.params.id);
const callerRole = await getMaintainerRole(req.session.userId, req.params.id);
const isOwner = String(skill?.ownerId) === req.session.userId;
const isAdmin = callerRole === 'registry_admin';
if (!isOwner && !isAdmin) return res.status(403).json({ error: 'Forbidden' });
// Role boundary: caller cannot grant role exceeding their own
const callerLevel = ROLE_LEVELS[callerRole] ?? 0;
if (ROLE_LEVELS[parsed.data.role] > callerLevel) {
return res.status(403).json({ error: 'Cannot assign role exceeding your own level' });
}
await MaintainerRole.findOneAndUpdate(
{ skillId: req.params.id, userId: req.params.userId },
{ role: parsed.data.role, updatedBy: req.session.userId, at: new Date() },
{ upsert: true }
);
await AuditLog.create({
action: 'maintainer.role_changed',
actorId: req.session.userId,
targetUserId: req.params.userId,
skillId: req.params.id,
newRole: parsed.data.role,
at: new Date(),
});
roleCache.delete(`${req.params.userId}:${req.params.id}`);
return res.json({ updated: true });
});
PRIVESC39-004 — Cache key collision bleeds elevated roles to recreated skills
Severity: HIGH
The maintainer role cache uses skillId as the second component of the cache key without including orgId. Registry skills use sequential integer IDs. When a skill is deleted and a new skill is created by a different organization, it may receive the same integer ID. If the previously elevated role assignment for the old skill is still in the cache (within the 60-second TTL window), and the cache key does not distinguish organization, the new skill's role lookup returns the old skill's elevated assignment. An attacker who knows the deletion/creation timing can arrange for a skill deletion to occur just before they create a new skill, receiving registry_admin role for the new skill based on the previous organization's cache entry — without any explicit role assignment.
// Cache key: userId:skillId — no orgId — bleeds across recreation
const key = `${userId}:${skillId}`; // skillId 42 from org A = skillId 42 from org B
// Cache key: userId:orgId:skillId — orgId prevents cross-org bleed
async function getMaintainerRole(userId, skillId) {
const skill = await Skill.findById(skillId).select('orgId');
const key = `${userId}:${skill.orgId}:${skillId}`; // org-scoped key
const cached = roleCache.get(key);
if (cached && cached.expiresAt > Date.now()) return cached.role;
const assignment = await MaintainerRole.findOne({ userId, skillId });
const role = assignment?.role ?? 'none';
roleCache.set(key, { role, expiresAt: Date.now() + 60_000 });
return role;
}
// Invalidate entire org's cache on skill deletion
Skill.events.on('delete', ({ skillId, orgId }) => {
for (const key of roleCache.keys()) {
if (key.includes(`:${orgId}:${skillId}`)) roleCache.delete(key);
}
});
Related advisories: SA-SKL-PRIVESC38 (audit report export) | SA-SKL-PRIVESC37 (marketplace monetization)