Claude MCP skill privilege escalation — moderation and content policy enforcement endpoints (SA-SKL-PRIVESC62)
SA-SKL-PRIVESC62 identifies four privilege escalation vulnerabilities in MCP skill registry skill moderation and content policy enforcement endpoints. The registry's moderation middleware reads the user's moderator role from the moderatorScope claim inside the JWT rather than verifying it against the database; an attacker crafts a JWT with moderatorScope: 'global_moderator' and uses it to invoke skill removal, publisher suspension, and content policy override endpoints that are supposed to be gated to vetted human moderators. The moderator scope assignment endpoint accepts a targetScope value from the request body without checking whether the requesting user's current role permits elevating to that scope; any verified publisher can assign themselves global_moderator scope by submitting a direct API request, bypassing the moderator vetting and approval process entirely. The global content moderation policy update endpoint requires authentication but not a minimum moderator role; any authenticated user can submit a PATCH request that overwrites content policy thresholds, automated takedown trigger conditions, and appeal queue priority weights, silently changing the rules under which all skills are evaluated for removal. The moderator scope authorization cache uses only the user ID as the cache key, omitting the content policy version identifier; when the registry admin publishes a new content policy that revokes a subset of global_moderator scopes, the cached entries for affected users continue to report the revoked scope as active until the TTL expires, allowing formerly-authorized moderators to continue taking moderation actions after their revocation.
moderatorScope claim — craft JWT with moderatorScope:'global_moderator' grants skill removal, publisher suspension, and content policy override without database-side authorization checkPOST /api/registry/moderation/assign missing scope boundary check — any verified publisher assigns global_moderator scope to themselves bypassing moderator vetting processPATCH /api/registry/moderation/policy missing ownership check — any authenticated user modifies global content moderation policy thresholds, automated takedown triggers, and appeal queue priority weightsuserId without contentPolicyVersionId — cache entries bleed across content policy upgrades; revoked global_moderator scopes retained until TTL expiryPRIVESC62-001 — JWT moderatorScope claim forgery grants global moderator access
The moderation middleware extracts the user's moderator scope from the moderatorScope field of the decoded JWT payload without performing a database lookup to verify that the claimed scope matches the user's actual stored authorization. JWT signatures prevent tampering when the token is issued by the registry, but an attacker who finds a signing key (via PRIVESC62-003 policy inspection, a leaked config, or a previous injection vulnerability) can mint a valid JWT with an arbitrary moderatorScope claim. Even without the signing key, if the JWT verification is misconfigured to accept alg:none, the attacker can forge an unsigned token. With moderatorScope: 'global_moderator', the attacker can invoke endpoints that remove any skill from the registry, suspend any publisher's account, and override the content moderation policy for the entire platform.
// PRIVESC62-001 — VULNERABLE
function requireModeratorScope(minScope) {
return async (req, res, next) => {
const { moderatorScope } = req.jwtPayload; // trusts JWT claim directly
const scopeRank = { viewer: 0, skill_moderator: 1, global_moderator: 2 };
if ((scopeRank[moderatorScope] ?? -1) >= scopeRank[minScope]) {
return next();
}
res.status(403).json({ error: 'insufficient_moderator_scope' });
};
}
router.delete('/registry/skills/:id',
requireSession,
requireModeratorScope('global_moderator'), // scope from JWT — forgeable
async (req, res) => { /* removes skill */ }
);
// PRIVESC62-001 — FIXED: DB-verify moderator scope; cache with userId+policyVersionId
async function getVerifiedModeratorScope(userId, policyVersionId) {
const cacheKey = `mod:scope:${userId}:${policyVersionId}`;
const cached = await redis.get(cacheKey);
if (cached) return cached;
const row = await db.queryOne(
'SELECT scope FROM moderator_authorizations WHERE user_id=$1 AND policy_version_id=$2 AND revoked_at IS NULL',
[userId, policyVersionId]
);
const scope = row?.scope ?? 'none';
await redis.set(cacheKey, scope, 'EX', 300); // 5-min TTL
return scope;
}
function requireModeratorScope(minScope) {
return async (req, res, next) => {
const policyVersionId = await getCurrentPolicyVersionId();
const scope = await getVerifiedModeratorScope(req.session.userId, policyVersionId);
const scopeRank = { none: -1, viewer: 0, skill_moderator: 1, global_moderator: 2 };
if ((scopeRank[scope] ?? -1) >= scopeRank[minScope]) return next();
res.status(403).json({ error: 'insufficient_moderator_scope' });
};
}
PRIVESC62-002 — Missing scope boundary check allows self-assignment of global_moderator
The moderator scope assignment endpoint accepts the targetScope and targetUserId from the request body. The endpoint checks that the requesting user is authenticated and has a verified_publisher account flag, but does not check whether targetUserId matches req.session.userId (preventing self-assignment) or whether the targetScope value falls within a set of scopes that require admin approval versus scopes that publishers may request for themselves. Any verified publisher can POST to this endpoint with targetUserId: req.session.userId and targetScope: 'global_moderator', immediately granting themselves full moderation authority without going through the moderator vetting queue, background check, or approval by existing administrators.
// PRIVESC62-002 — VULNERABLE: no self-assignment check, no scope boundary
router.post('/api/registry/moderation/assign', requireSession, async (req, res) => {
const { targetUserId, targetScope } = req.body;
const requester = await db.getUser(req.session.userId);
if (!requester.verifiedPublisher) {
return res.status(403).json({ error: 'verified_publisher_required' });
}
// No check that targetUserId !== req.session.userId
// No check that targetScope is in self-requestable set
await db.setModeratorScope(targetUserId, targetScope);
res.json({ assigned: true });
});
// PRIVESC62-002 — FIXED: self-assignment blocked; scope boundary enforced; admin-only for elevated scopes
const SELF_REQUESTABLE_SCOPES = new Set(['viewer']); // only viewer self-requestable
const ADMIN_REQUIRED_SCOPES = new Set(['skill_moderator', 'global_moderator']);
router.post('/api/registry/moderation/assign', requireSession, async (req, res) => {
const { targetUserId, targetScope } = req.body;
if (targetUserId === req.session.userId) {
return res.status(403).json({ error: 'self_assignment_forbidden' });
}
if (ADMIN_REQUIRED_SCOPES.has(targetScope)) {
const requester = await db.getUser(req.session.userId);
if (requester.role !== 'registry_admin') {
return res.status(403).json({ error: 'admin_required_for_scope', scope: targetScope });
}
}
await db.createModeratorScopeRequest(targetUserId, targetScope, req.session.userId, 'pending_review');
res.json({ created: true, status: 'pending_review' });
});
PRIVESC62-003 — Missing ownership check allows any user to modify global content policy
The global content moderation policy update endpoint is protected by requireSession middleware that verifies the user is authenticated, but no additional role check verifies that the authenticated user holds the global_moderator or registry_admin scope required to modify platform-wide moderation rules. Any user with a valid session token can submit a PATCH request to /api/registry/moderation/policy and overwrite the content policy thresholds (e.g., lowering the spam score threshold to cause mass false-positive takedowns of legitimate skills), automated takedown trigger conditions (e.g., disabling all automated enforcement), and appeal queue priority weights (e.g., elevating appeals for specific publisher IDs to skip the queue). These changes affect every skill in the registry and every pending moderation action.
// PRIVESC62-003 — VULNERABLE: requireSession without role check
router.patch('/api/registry/moderation/policy', requireSession, async (req, res) => {
const { spamThreshold, takedownTriggers, appealQueueWeights } = req.body;
// Any authenticated user can overwrite global moderation policy
await db.updateContentModerationPolicy({
spamThreshold,
takedownTriggers,
appealQueueWeights,
updatedBy: req.session.userId
});
res.json({ updated: true });
});
// PRIVESC62-003 — FIXED: global_moderator scope required; CSRF token; policy version bump; audit log
router.patch('/api/registry/moderation/policy',
requireSession,
requireModeratorScope('global_moderator'),
validateCsrfToken,
async (req, res) => {
const ContentPolicySchema = z.object({
spamThreshold: z.number().min(0).max(1),
takedownTriggers: z.array(z.enum(['spam', 'malware', 'policy_violation'])).max(10),
appealQueueWeights: z.record(z.enum(['normal', 'elevated', 'urgent']), z.number().min(0).max(1))
});
const policy = ContentPolicySchema.parse(req.body);
const newVersionId = await db.createContentPolicyVersion(policy, req.session.userId);
await auditLog.record({
action: 'content_policy_update', actorId: req.session.userId,
newVersionId, policySnapshot: policy
});
res.json({ updated: true, versionId: newVersionId });
}
);
PRIVESC62-004 — Moderator scope cache bleed retains revoked scopes across policy upgrades
The moderator scope authorization cache stores entries keyed solely by userId, without incorporating the current content policy version identifier. When the registry admin publishes a new content policy version that revokes moderator scopes for a subset of users (for example, as part of a periodic re-vetting cycle or in response to a moderation abuse incident), the cached entries for affected users continue to reflect the old, now-revoked scope until their individual TTLs expire. During this window, revoked moderators can continue to remove skills, suspend publishers, and override content policy decisions. The TTL is configured at 15 minutes, meaning a revoked global_moderator retains full moderation authority for up to 15 minutes after the admin explicitly revokes their access.
// PRIVESC62-004 — VULNERABLE: cache key omits contentPolicyVersionId
async function getModeratorScope(userId) {
const cacheKey = `mod:scope:${userId}`; // no policy version — bleeds across upgrades
const cached = await redis.get(cacheKey);
if (cached) return cached; // revoked scope served from cache for up to 15 minutes
const row = await db.queryOne(
'SELECT scope FROM moderator_authorizations WHERE user_id=$1 AND revoked_at IS NULL',
[userId]
);
const scope = row?.scope ?? 'none';
await redis.set(cacheKey, scope, 'EX', 900);
return scope;
}
// PRIVESC62-004 — FIXED: include contentPolicyVersionId in cache key; bust cache on revocation
async function getCurrentPolicyVersionId() {
const cached = await redis.get('content:policy:current_version');
if (cached) return cached;
const row = await db.queryOne(
'SELECT id FROM content_policy_versions ORDER BY created_at DESC LIMIT 1'
);
await redis.set('content:policy:current_version', row.id, 'EX', 60);
return row.id;
}
async function getModeratorScope(userId) {
const policyVersionId = await getCurrentPolicyVersionId();
const cacheKey = `mod:scope:${userId}:${policyVersionId}`; // version-scoped key
const cached = await redis.get(cacheKey);
if (cached) return cached;
const row = await db.queryOne(
`SELECT scope FROM moderator_authorizations
WHERE user_id=$1 AND policy_version_id=$2 AND revoked_at IS NULL`,
[userId, policyVersionId]
);
const scope = row?.scope ?? 'none';
await redis.set(cacheKey, scope, 'EX', 300); // 5-min TTL
return scope;
}
// Call this when revoking a moderator to bust their specific cache entry immediately
async function revokeModeratorScope(userId) {
const policyVersionId = await getCurrentPolicyVersionId();
await db.query(
'UPDATE moderator_authorizations SET revoked_at=NOW() WHERE user_id=$1 AND policy_version_id=$2',
[userId, policyVersionId]
);
await redis.del(`mod:scope:${userId}:${policyVersionId}`);
}
SkillAudit detects all SA-SKL-PRIVESC62 patterns via static AST analysis. Run a free audit on your MCP skill or Claude plugin and get a graded report with fix guidance in under 60 seconds.