Claude MCP skill privilege escalation — skill moderation and content policy enforcement endpoints (SA-SKL-PRIVESC64)
SA-SKL-PRIVESC64 identifies four privilege escalation vulnerabilities in MCP skill registry skill moderation and content policy enforcement endpoints. The moderation role check trusts a moderationScope claim embedded directly in the JWT without verifying it against the database, allowing any attacker who can forge or tamper with a JWT to claim global_moderator scope and immediately gain the ability to override content policy decisions, suspend any skill in the registry, and remove content from any publisher without any database-side authorization check; the moderation role assignment endpoint lacks a boundary check that prevents a user from assigning a role equal to or higher than their own current role, so any verified publisher can POST to assign themselves global_moderator status, bypassing the manual vetting process that the registry uses to background-check moderators before granting them cross-publisher content removal authority; the content policy configuration endpoint lacks an ownership check that restricts modification to registry administrators, allowing any authenticated user to PATCH global content policy parameters including the abuse report threshold that triggers automatic skill takedown, the minimum suspension duration, and the criteria for escalating a content dispute to the registry's trust and safety team; and the moderation role authorization cache uses only userId as the cache key without incorporating the current moderationPolicyVersionId, causing cached role grants from before a policy upgrade to remain valid until their TTL expires — meaning a user whose global_moderator role was revoked as part of a policy update continues to have that role honored by the cache for up to the cache TTL duration after revocation.
moderationScope claim — craft JWT with moderationScope:'global_moderator' grants content policy override, skill suspension authority, and cross-publisher content removal rights without database-side checkPOST /api/registry/moderation/assign missing role boundary check — any publisher assigns global_moderator role to themselves bypassing moderation vetting processPATCH /api/registry/moderation/policy missing ownership check — any authenticated user modifies global content policies including takedown thresholds and suspension criteriauserId without moderationPolicyVersionId — cache entries bleed across moderation policy upgrades; revoked global_moderator roles retained until TTL expiryPRIVESC64-001 — JWT moderationScope claim grants global_moderator without database verification
The moderation middleware reads the user's moderation scope from the moderationScope claim in the decoded JWT and uses it directly for authorization decisions without querying the database to verify that the user actually holds this scope. Because JWTs are signed by the registry's auth server, an attacker cannot modify a legitimately issued JWT — but the attack surface includes JWT forgery via a compromised signing key (from PRIVESC64-003 policy config access or SSRF to Vault), algorithm confusion attacks against the JWT verification library, and any JWT issuance endpoint that passes untrusted user input into the claims payload. Any of these paths allows the attacker to obtain a JWT with moderationScope:'global_moderator', immediately granting content policy override authority, the ability to suspend any skill, and the right to remove content from any publisher in the registry.
// PRIVESC64-001 — VULNERABLE: moderationScope read directly from JWT claim
function requireModerationScope(requiredScope) {
return (req, res, next) => {
// JWT claim trusted without DB verification — attacker forges moderationScope
const userScope = req.jwt.moderationScope;
const MODERATION_SCOPE_ORDER = ['none', 'skill_reporter', 'skill_moderator', 'global_moderator'];
if (MODERATION_SCOPE_ORDER.indexOf(userScope) >= MODERATION_SCOPE_ORDER.indexOf(requiredScope)) {
return next();
}
res.status(403).json({ error: 'Insufficient moderation scope' });
};
}
router.post('/skills/:id/suspend', requireModerationScope('skill_moderator'), suspendSkill);
router.delete('/skills/:id/content/:contentId', requireModerationScope('global_moderator'), removeContent);
// PRIVESC64-001 — FIXED: DB-backed moderation scope lookup; JWT carries only sub
function requireModerationScope(requiredScope) {
return async (req, res, next) => {
try {
// DB lookup — attacker cannot forge this even with a modified JWT
const userId = req.jwt.sub; // JWT carries only sub — no scope claim trusted
const userScope = await moderationScopeCache.getOrFetch(
`scope:${userId}`,
() => db.getModerationScope(userId)
);
const MODERATION_SCOPE_ORDER = ['none', 'skill_reporter', 'skill_moderator', 'global_moderator'];
if (MODERATION_SCOPE_ORDER.indexOf(userScope) >= MODERATION_SCOPE_ORDER.indexOf(requiredScope)) {
return next();
}
res.status(403).json({ error: 'Insufficient moderation scope' });
} catch (err) {
res.status(500).json({ error: 'Authorization check failed' });
}
};
}
PRIVESC64-002 — Missing role boundary check enables self-assignment of global_moderator
The moderation role assignment endpoint allows any user with a valid session to assign a moderation scope to any user ID, including themselves. The endpoint validates that the target scope is a recognized scope string but does not check that the assigning user holds a scope strictly higher than the scope being assigned. This means any verified publisher — who holds skill_reporter scope by default — can POST to assign themselves global_moderator scope without going through the registry's manual vetting process, which involves a background check and a review by the trust and safety team. Once self-elevated to global_moderator, the publisher can remove any skill from the registry, override any content policy decision, and approve or reject other users' moderation scope assignments.
// PRIVESC64-002 — VULNERABLE: no boundary check — any user assigns any scope to themselves
router.post('/moderation/assign',
requireSession,
async (req, res) => {
const { targetUserId, moderationScope } = req.body;
const VALID_SCOPES = ['none', 'skill_reporter', 'skill_moderator', 'global_moderator'];
if (!VALID_SCOPES.includes(moderationScope)) {
return res.status(400).json({ error: 'Invalid scope' });
}
// No check that req.session.userId's scope > moderationScope
// Any user can assign global_moderator to themselves
await db.setModerationScope(targetUserId, moderationScope);
res.json({ assigned: true });
}
);
// PRIVESC64-002 — FIXED: MODERATION_SCOPE_ORDER boundary; global_moderator requires admin queue
const MODERATION_SCOPE_ORDER = ['none', 'skill_reporter', 'skill_moderator', 'global_moderator'];
router.post('/moderation/assign',
requireSession,
async (req, res) => {
const { targetUserId, moderationScope } = req.body;
if (!MODERATION_SCOPE_ORDER.includes(moderationScope)) {
return res.status(400).json({ error: 'Invalid scope' });
}
const actorScope = await db.getModerationScope(req.session.userId);
const actorLevel = MODERATION_SCOPE_ORDER.indexOf(actorScope);
const targetLevel = MODERATION_SCOPE_ORDER.indexOf(moderationScope);
// Assigner must hold strictly higher scope than the scope being assigned
if (actorLevel <= targetLevel) {
return res.status(403).json({ error: 'Cannot assign scope equal to or higher than own scope' });
}
// global_moderator always requires admin queue — cannot be granted directly
if (moderationScope === 'global_moderator') {
await moderationQueue.enqueueForAdminReview({ targetUserId, moderationScope, requestedBy: req.session.userId });
return res.json({ queued: true, pendingAdminReview: true });
}
await db.setModerationScope(targetUserId, moderationScope);
await auditLog.write({ action: 'moderation.scope.assign', targetUserId, moderationScope, actorId: req.session.userId, at: new Date() });
res.json({ assigned: true });
}
);
PRIVESC64-003 — Missing ownership check allows unrestricted content policy modification
The content policy configuration endpoint accepts a PATCH request to update global moderation policy parameters including the abuse report count threshold that triggers automatic skill takedown, the minimum and maximum suspension durations, and the criteria for escalating a content dispute to the registry's trust and safety team. The endpoint validates that the requesting user is authenticated but does not verify that they hold registry_admin or higher moderation scope. Any authenticated user — including newly registered publishers with zero reputation — can lower the abuse report threshold to 1 (causing any skill to be auto-taken-down on a single report from any user) or raise the minimum suspension duration to the maximum value (preventing moderators from issuing temporary suspensions and forcing every suspension to be permanent).
// PRIVESC64-003 — VULNERABLE: missing ownership check — any authenticated user modifies global policy
router.patch('/moderation/policy',
requireSession,
async (req, res) => {
// No role check — any authenticated user can modify global content policy
const updated = await db.updateModerationPolicy({
abuseReportThreshold: req.body.abuseReportThreshold,
minSuspensionDays: req.body.minSuspensionDays,
maxSuspensionDays: req.body.maxSuspensionDays,
escalationCriteria: req.body.escalationCriteria
});
res.json({ updated: true, policy: updated });
}
);
// PRIVESC64-003 — FIXED: require registry_admin; Zod schema with bounds; bump policy version; audit log
const { z } = require('zod');
const ModerationPolicyUpdateSchema = z.object({
abuseReportThreshold: z.number().int().min(3).max(50),
minSuspensionDays: z.number().int().min(1).max(30),
maxSuspensionDays: z.number().int().min(7).max(365),
escalationCriteria: z.enum(['any_critical', 'repeat_offender', 'manual_only'])
}).partial().refine(
data => !data.minSuspensionDays || !data.maxSuspensionDays || data.minSuspensionDays <= data.maxSuspensionDays,
{ message: 'minSuspensionDays must be <= maxSuspensionDays' }
);
router.patch('/moderation/policy',
requireSession,
requireModerationScope('registry_admin'),
reAuthRequired,
async (req, res) => {
const updates = ModerationPolicyUpdateSchema.parse(req.body);
const previous = await db.getModerationPolicy();
const updated = await db.updateModerationPolicy({ ...updates, policyVersion: previous.policyVersion + 1 });
await auditLog.write({ action: 'moderation.policy.update', before: previous, after: updated, actorId: req.session.userId, at: new Date() });
res.json({ updated: true, policyVersion: updated.policyVersion });
}
);
PRIVESC64-004 — Moderation role cache bleeds across policy version upgrades
The moderation role authorization cache stores per-user scope grants keyed only by userId. When a moderation policy upgrade revokes a user's global_moderator scope — for example, as part of a periodic re-vetting cycle or in response to a trust and safety incident — the existing cache entry for that user's userId key is not invalidated. Any moderation API request made by the revoked user within the cache TTL window uses the stale cached global_moderator scope, granting them continued access to cross-publisher content removal and skill suspension capabilities even after their scope was explicitly revoked in the database.
// PRIVESC64-004 — VULNERABLE: cache key is userId only — bleeds across policy version upgrades
const moderationScopeCache = new LRUCache({ ttl: 15 * 60 * 1000 }); // 15 min TTL
async function getUserModerationScope(userId) {
const cacheKey = `modscope:${userId}`; // no policy version — revoked roles stay cached
const cached = moderationScopeCache.get(cacheKey);
if (cached) return cached;
const scope = await db.getModerationScope(userId);
moderationScopeCache.set(cacheKey, scope);
return scope;
}
// When revoking a user's scope, cache is not invalidated — stale grant persists for 15 min
async function revokeModerationScope(userId) {
await db.setModerationScope(userId, 'none');
// BUG: moderationScopeCache entry for userId not invalidated
}
// PRIVESC64-004 — FIXED: cache key = policyVersionId:userId; revoke bumps policyVersion
const moderationScopeCache = new LRUCache({ ttl: 15 * 60 * 1000 });
async function getUserModerationScope(userId) {
const policy = await db.getCurrentModerationPolicy();
// policyVersionId in cache key — upgrade invalidates all entries atomically
const cacheKey = `modscope:${policy.policyVersionId}:${userId}`;
const cached = moderationScopeCache.get(cacheKey);
if (cached) return cached;
const scope = await db.getModerationScope(userId);
moderationScopeCache.set(cacheKey, scope);
return scope;
}
async function revokeModerationScope(userId) {
await db.setModerationScope(userId, 'none');
// Bump policyVersionId — invalidates ALL cached scope entries across all users
await db.incrementModerationPolicyVersion();
await auditLog.write({ action: 'moderation.scope.revoke', userId, actorId: 'system', at: new Date() });
}
SkillAudit scans for all SA-SKL-PRIVESC64 patterns — JWT claim-based authorization without database verification, missing role boundary checks on scope assignment endpoints, missing ownership checks on content policy configuration endpoints, and authorization caches without policy version invalidation. Get a free audit to see the full privilege escalation analysis for your skill.