Claude MCP skill privilege escalation — skill content moderation and policy enforcement endpoints — SA-SKL-PRIVESC48
SA-SKL-PRIVESC48 documents four privilege escalation vulnerabilities in MCP skill registry content moderation and policy enforcement endpoints. Content moderation levels determine which users can approve flagged content, bypass the moderation queue, and modify the policies governing what content is permitted in the registry. PRIVESC48-001: JWT moderationLevel claim allows crafted tokens to bypass the moderation queue and access all flagged reports; PRIVESC48-002: missing level boundary check on the moderation access assignment endpoint allows any moderator to self-escalate to content_admin; PRIVESC48-003: missing ownership check on the global moderation config endpoint allows any authenticated user to empty prohibited content categories; PRIVESC48-004: cache key without policyVersionId causes moderation level cache entries to bleed across policy version upgrades, extending removed admin access indefinitely.
moderationLevel claim — craft JWT with moderationLevel:'content_admin' grants bypass of content moderation queue, approval of any content policy violation, and access to all flagged content reports; fix: DB-backed 60s Map cache keyed on userId; JWT carries only sub; invalidate on level change eventPOST /api/moderation/access missing level boundary check — any moderator assigns content_admin to themselves exceeding their own moderation scope; fix: requireSession; MODERATION_LEVEL_ORDER ordinal comparison; Zod ModerationLevelSchema; audit logPATCH /api/registry/moderation/config missing ownership check — any authenticated user modifies global content moderation configuration including prohibited content categories, auto-removal thresholds, and appeal periods; fix: require content_admin level; Zod ModerationConfigSchema with prohibitedCategories min(1); audit log with before/after diffuserId without policyVersionId — cache entries bleed across moderation policy version upgrades; previously assigned content_admin level served under new policy with expanded moderation scope indefinitely; fix: cache key = moderationPolicyVersionId:userId; invalidate entire cache on policy upgrade eventPRIVESC48-001 — JWT moderationLevel claim forgery grants content_admin queue bypass
Severity: CRITICAL
The content moderation middleware reads the user's moderation level from the moderationLevel claim in the user's JWT, trusting the client-supplied claim value without verifying it against the database. An attacker who crafts a JWT containing moderationLevel: 'content_admin' and signs it with a valid signature — either because they have obtained the JWT signing secret or because the registry accepts tokens signed with weak algorithms — receives full content moderation administrative capabilities.
The content_admin level in a skill registry content moderation system carries capabilities beyond ordinary moderation: bypassing the content review queue to publish skills directly without moderation review, approving flagged content policy violations that ordinary moderators cannot approve, accessing the full queue of pending flagged content reports including those submitted by other moderators, modifying the auto-removal threshold that determines at what flag count a skill is automatically removed, and accessing the appeal workflow for skills that have been removed for policy violations. An attacker with a forged content_admin JWT can silently approve policy-violating skills, observe the full moderation queue including confidential reports, and manipulate the moderation system to target specific skills for removal or protection — all while appearing in audit logs as a legitimate content_admin with no evidence of token forgery unless the registry cross-references JWT claims against database records.
// Moderation middleware — trusts JWT claim directly
function requireModerationLevel(requiredLevel) {
return (req, res, next) => {
const { moderationLevel } = req.session.jwtPayload; // from JWT claim
if (!moderationLevel || MODERATION_LEVEL_ORDER.indexOf(moderationLevel) < MODERATION_LEVEL_ORDER.indexOf(requiredLevel)) {
return res.status(403).json({ error: 'Insufficient moderation level' });
}
req.moderationLevel = moderationLevel;
next();
};
}
const moderationLevelCache = new Map(); // userId -> { level, expiresAt }
async function getModerationLevel(userId) {
const cached = moderationLevelCache.get(userId);
if (cached && cached.expiresAt > Date.now()) return cached.level;
const user = await User.findById(userId).select('+moderationLevel');
const level = user?.moderationLevel || 'none';
moderationLevelCache.set(userId, { level, expiresAt: Date.now() + 60_000 });
return level;
}
// Invalidate on level change:
eventBus.on('moderation.level.changed', ({ userId }) => moderationLevelCache.delete(userId));
function requireModerationLevel(requiredLevel) {
return async (req, res, next) => {
if (!req.session?.userId) return res.status(401).json({ error: 'Unauthenticated' });
const level = await getModerationLevel(req.session.userId); // DB-backed, not JWT
if (MODERATION_LEVEL_ORDER.indexOf(level) < MODERATION_LEVEL_ORDER.indexOf(requiredLevel)) {
return res.status(403).json({ error: 'Insufficient moderation level' });
}
req.moderationLevel = level;
next();
};
}
The fix reads the user's moderation level from a DB-backed cache keyed on userId rather than from the JWT payload. The JWT carries only the user's sub identifier — no authorization claims. The cache has a 60-second TTL ensuring that moderation level changes propagate within one minute. An event listener invalidates the cache entry immediately on moderation.level.changed events, reducing the propagation delay to near-zero for explicit level revocations. JWT claim forgery has no effect on moderation level resolution because the claim is never consulted.
PRIVESC48-002 — Missing level boundary check on moderation access assignment enables self-escalation
Severity: HIGH
The moderation access assignment endpoint accepts a targetUserId and a newLevel parameter and updates the target user's moderation level in the database. The endpoint requires an active session but does not check whether the requesting user's current moderation level is higher than the requested new level. Any user with a moderator level can assign content_admin to themselves, because the assignment endpoint does not enforce the invariant that you cannot grant a level higher than your own.
The escalation to content_admin from moderator is a single API request that takes effect immediately in the database. Because the fix for PRIVESC48-001 reads from the database via a 60-second TTL cache, the escalated level is available for use within 60 seconds of the assignment request — no JWT forgery required. A moderator-level user who performs this escalation gains full content_admin capabilities including queue bypass, violation approval, and policy modification. The escalation is logged to the assignment audit log under the attacker's user ID with the target level, but without a boundary check violation alert, the log entry looks identical to a legitimate level promotion by an admin user and may not trigger review.
router.post('/moderation/access', requireSession, async (req, res) => {
const { targetUserId, newLevel } = req.body;
// No check that req.session.userId's level >= newLevel
await User.updateOne({ _id: targetUserId }, { $set: { moderationLevel: newLevel } });
eventBus.emit('moderation.level.changed', { userId: targetUserId });
return res.json({ updated: true });
});
const MODERATION_LEVEL_ORDER = ['none', 'reviewer', 'moderator', 'content_admin'];
const ModerationLevelSchema = z.enum(['none', 'reviewer', 'moderator', 'content_admin']);
router.post('/moderation/access', requireSession, async (req, res) => {
const parsed = z.object({
targetUserId: z.string(),
newLevel: ModerationLevelSchema,
}).safeParse(req.body);
if (!parsed.success) return res.status(400).json({ error: 'Invalid payload', issues: parsed.error.issues });
const { targetUserId, newLevel } = parsed.data;
const actorLevel = await getModerationLevel(req.session.userId);
const actorOrdinal = MODERATION_LEVEL_ORDER.indexOf(actorLevel);
const newOrdinal = MODERATION_LEVEL_ORDER.indexOf(newLevel);
if (actorOrdinal <= newOrdinal) {
return res.status(403).json({ error: 'Cannot assign a level equal to or higher than your own' });
}
await User.updateOne({ _id: targetUserId }, { $set: { moderationLevel: newLevel } });
await AuditLog.create({ action: 'moderation.level.assigned', actorId: req.session.userId,
targetId: targetUserId, newLevel, actorLevel, at: new Date() });
eventBus.emit('moderation.level.changed', { userId: targetUserId });
return res.json({ updated: true });
});
The fix enforces the boundary invariant: the requesting user's moderation level ordinal must be strictly greater than the new level ordinal being assigned. A moderator-level user (ordinal 2) cannot assign content_admin (ordinal 3) because 2 <= 3. Only a content_admin can assign the moderator level and below. The Zod ModerationLevelSchema enum validates that newLevel is one of the defined levels, rejecting unknown level strings. The audit log records both the actor's current level and the assigned level, enabling detection of near-boundary assignments that may indicate escalation attempts.
PRIVESC48-003 — Missing ownership check on global moderation config allows policy emptying
Severity: HIGH
The global content moderation configuration endpoint accepts PATCH requests to update the registry-wide moderation policy, including the prohibitedCategories array that lists content types subject to automatic removal, the autoRemovalThreshold flag count at which skills are automatically removed, and the appealPeriodDays duration during which removed skills can be appealed. The endpoint requires only an authenticated session — no moderation level check is performed.
Any authenticated registry user — including skill publishers with no moderation role — can send a PATCH request to empty the prohibitedCategories array, reducing it to an empty list. When prohibitedCategories is empty, no content category is subject to automatic removal or moderation queue flagging, effectively disabling content enforcement for the entire registry. Skills containing malicious payloads, prompt injection attacks, credential harvesting code, or other policy-violating content can be published and distributed without triggering moderation review. The impact is registry-wide — every skill publication and every content flag check for the duration that the empty policy is in effect runs against a configuration that approves all content. The change takes effect immediately on the next content check cycle and persists until a content_admin user detects and reverts it.
router.patch('/registry/moderation/config', requireSession, async (req, res) => {
// No moderation level check — any authenticated user can modify global policy
const { prohibitedCategories, autoRemovalThreshold, appealPeriodDays } = req.body;
await ModerationConfig.updateOne({}, { $set: { prohibitedCategories, autoRemovalThreshold, appealPeriodDays } });
return res.json({ updated: true });
});
const ModerationConfigSchema = z.object({
prohibitedCategories: z.array(z.string().min(1).max(128)).min(1),
autoRemovalThreshold: z.number().int().min(1).max(1000),
appealPeriodDays: z.number().int().min(1).max(90),
}).partial();
router.patch('/registry/moderation/config', requireSession, requireModerationLevel('content_admin'),
async (req, res) => {
const parsed = ModerationConfigSchema.safeParse(req.body);
if (!parsed.success) return res.status(400).json({ error: 'Invalid config payload', issues: parsed.error.issues });
const before = await ModerationConfig.findOne();
await ModerationConfig.updateOne({}, { $set: parsed.data });
const after = await ModerationConfig.findOne();
await AuditLog.create({ action: 'moderation.config.updated', actorId: req.session.userId,
before: before.toObject(), after: after.toObject(), at: new Date() });
return res.json({ updated: true });
});
The fix requires the content_admin moderation level via the DB-backed requireModerationLevel middleware from PRIVESC48-001. The Zod ModerationConfigSchema enforces prohibitedCategories.min(1), making it impossible to empty the prohibited categories array through this endpoint — at least one category must remain. The autoRemovalThreshold and appealPeriodDays bounds prevent extreme values that could effectively disable enforcement. The before/after diff audit log enables rapid detection and reversal of unauthorized configuration changes by logging the full previous and new state.
PRIVESC48-004 — Moderation level cache bleed across policy version upgrades
Severity: HIGH
The moderation level cache (from PRIVESC48-001's fix pattern) uses userId as the cache key without including the current moderation policy version identifier. When the registry upgrades its moderation policy — adding new prohibited content categories, expanding the scope of content_admin responsibilities, or changing the content types that require moderation review — the existing cache entries remain valid for their full 60-second TTL. After TTL expiry, they are refreshed from the database with the user's level under the new policy. However, the level itself (e.g., content_admin) may have been granted under a previous policy scope that was more permissive than the new policy's definition of that level.
The more severe scenario occurs when an administrator removes a user's content_admin level during a policy upgrade that restricts who qualifies for the role, but the user's cache entry is not invalidated because the upgrade event does not emit per-user level change events — only a global policy version bump. The user continues operating at content_admin level for up to 60 seconds per cache refresh cycle, indefinitely if no explicit moderation.level.changed event is emitted for them. Users whose content_admin access was revoked as part of a policy tightening can continue exercising full content_admin capabilities including queue bypass and violation approval for an indeterminate period after the revocation was intended to take effect.
// Cache key: userId only — does not include policy version
const moderationLevelCache = new Map(); // userId -> { level, expiresAt }
async function getModerationLevel(userId) {
const cached = moderationLevelCache.get(userId);
if (cached && cached.expiresAt > Date.now()) return cached.level;
const user = await User.findById(userId).select('+moderationLevel');
const level = user?.moderationLevel || 'none';
moderationLevelCache.set(userId, { level, expiresAt: Date.now() + 60_000 });
return level;
}
// Policy upgrade does not invalidate existing cache entries
eventBus.on('moderation.policy.upgraded', ({ newPolicyVersionId }) => {
// only stores the new version — does not clear existing user caches
currentPolicyVersionId = newPolicyVersionId;
});
let currentModerationPolicyVersionId = null;
const moderationLevelCache = new Map(); // `${policyVersionId}:${userId}` -> { level, expiresAt }
async function getModerationLevel(userId) {
const policyVersionId = currentModerationPolicyVersionId
|| (await ModerationPolicyVersion.findOne({ active: true }).select('_id'))?.id;
const cacheKey = `${policyVersionId}:${userId}`;
const cached = moderationLevelCache.get(cacheKey);
if (cached && cached.expiresAt > Date.now()) return cached.level;
const user = await User.findById(userId).select('+moderationLevel');
const level = user?.moderationLevel || 'none';
moderationLevelCache.set(cacheKey, { level, expiresAt: Date.now() + 60_000 });
return level;
}
// Policy upgrade invalidates ALL cache entries — new policyVersionId makes all old keys stale
eventBus.on('moderation.policy.upgraded', ({ newPolicyVersionId }) => {
currentModerationPolicyVersionId = newPolicyVersionId;
moderationLevelCache.clear(); // all entries use old policyVersionId as prefix — now unreachable
});
// Per-user level change still invalidates specific entries
eventBus.on('moderation.level.changed', ({ userId }) => {
for (const key of moderationLevelCache.keys()) {
if (key.endsWith(`:${userId}`)) moderationLevelCache.delete(key);
}
});
The fix compounds the cache key with both the current policyVersionId and the userId. When the moderation policy is upgraded, the currentModerationPolicyVersionId variable is updated and the entire cache is cleared. All subsequent cache lookups use the new policy version as a key prefix, rendering all previous policy version cache entries permanently unreachable without explicit deletion. Users whose content_admin access was revoked as part of the upgrade will receive a fresh database lookup on their next request and find the revoked level immediately — no 60-second bleed window, and no indeterminate extension of removed privileges across policy version boundaries.
Run SkillAudit to detect JWT authorization claim usage in moderation middleware, missing level boundary comparisons in access assignment endpoints, unauthenticated config modification routes, and cache key patterns that omit policy version identifiers in your MCP skill registry source code. Join the waitlist for access.