Claude MCP skill privilege escalation — skill content moderation and policy enforcement endpoints — SA-SKL-PRIVESC42
SA-SKL-PRIVESC42 documents four privilege escalation vulnerabilities in MCP skill registry content moderation and policy enforcement endpoints. Content moderation infrastructure governs the ability to suppress skills, modify global moderation policies, access sensitive user report data, and control the automated takedown rules that determine which skills remain publicly available. PRIVESC42 identifies four distinct escalation paths to policy_admin level: JWT claim forgery exploiting trust in a user-controlled payload field, missing level boundary enforcement on moderation action assignment allowing self-escalation beyond moderator scope, missing ownership check on global policy modification allowing any authenticated user to change registry-wide moderation rules, and cache key design that propagates previously assigned elevated levels across moderation policy version upgrades.
contentModeratorLevel claim — craft JWT with contentModeratorLevel:'policy_admin' grants ability to suppress any skill, modify moderation policies, and access all user report data; fix: DB-backed 60s Map cache keyed on userId; JWT carries only sub; invalidate on level change eventPOST /api/skills/:id/moderation/actions missing level boundary check — any content moderator assigns policy_admin level actions exceeding their own moderator scope; fix: requireSession; validate action level does not exceed assigning user's own moderator scope; Zod ContentModerationActionSchema; audit logPATCH /api/registry/moderation/policy missing ownership check — any authenticated user modifies global content moderation policies including prohibited content categories, automated takedown triggers, and appeal window durations; fix: require policy_admin level; requireSession; audit logpolicy_admin level served under new policy version with different permission boundaries; fix: cache key = policyVersionId:userId; invalidate on policy version change; strict 60s TTLPRIVESC42-001 — JWT contentModeratorLevel claim forgery grants policy_admin
Severity: CRITICAL
The content moderation authorization check reads the contentModeratorLevel field from the decoded JWT payload. JWTs are signed but their payload is not encrypted — the payload is base64url-encoded and readable without the signing key. Any user can craft a JWT containing arbitrary claims if they possess the signing key, or if the server is vulnerable to algorithm confusion (substituting RS256's public key as the HS256 HMAC secret to forge tokens without the private key). An attacker crafts a JWT with contentModeratorLevel: 'policy_admin'. The middleware reads this claim and trusts it without a database lookup, granting the attacker the ability to suppress any skill from the registry, modify the global moderation policies that govern all future takedown decisions, and access all user report data including unreleased report details and reporter identity information.
Authorization roles must never be read from JWT claims. JWTs are user-controlled inputs. Even properly signed JWTs should not carry authorization levels — the user who holds the JWT may have had their role revoked since it was issued, or may have crafted it via algorithm confusion. The JWT should carry only the subject identifier (sub); all role lookups must hit a database or a short-TTL cache keyed on that identifier.
// Content moderation middleware — reads level from JWT claim
function requireContentModerator(minLevel) {
return (req, res, next) => {
const token = req.headers.authorization?.split(' ')[1];
const payload = jwt.verify(token, process.env.JWT_SECRET);
// attacker controls contentModeratorLevel in JWT payload
if (!hasLevel(payload.contentModeratorLevel, minLevel)) {
return res.status(403).json({ error: 'Insufficient moderator level' });
}
req.moderatorLevel = payload.contentModeratorLevel;
next();
};
}
// Content moderation middleware — DB-backed cache keyed on sub only
const moderatorCache = new Map(); // key: userId, value: { level, expiresAt }
function requireContentModerator(minLevel) {
return async (req, res, next) => {
const token = req.headers.authorization?.split(' ')[1];
const payload = jwt.verify(token, process.env.JWT_SECRET);
const userId = payload.sub; // only sub from JWT
let entry = moderatorCache.get(userId);
if (!entry || Date.now() > entry.expiresAt) {
const mod = await ContentModerator.findOne({ userId }).select('level');
entry = { level: mod?.level ?? null, expiresAt: Date.now() + 60_000 };
moderatorCache.set(userId, entry);
}
if (!entry.level || !hasLevel(entry.level, minLevel)) {
return res.status(403).json({ error: 'Insufficient moderator level' });
}
req.moderatorLevel = entry.level;
next();
};
}
PRIVESC42-002 — Self-escalation via missing level boundary on moderation action assignment
Severity: HIGH
The moderation action endpoint creates moderation actions against skills — including suppression, demotion, and policy-override actions. It verifies that the caller has a content moderator role but does not check that the action level is within the caller's own authority. A moderator at reviewer level can call this endpoint to create a policy_admin level action — such as a global suppression that bypasses normal review workflow or a policy-override that exempts a specific skill from future moderation. Because the action is created in the database before the cache TTL expires, the new action takes effect immediately. The action is attributed to the caller's legitimate moderator session in the audit log, making it appear as a routine moderation decision within the reviewer's normal scope.
// POST /api/skills/:id/moderation/actions — no level boundary check
router.post('/moderation/actions', requireContentModerator('reviewer'), async (req, res) => {
const { actionType, actionLevel, reason } = req.body;
// attacker submits actionLevel:'policy_admin' — no boundary check
await ModerationAction.create({
skillId: req.params.id, actionType, actionLevel,
reason, createdBy: req.session.userId,
});
return res.status(201).json({ created: true });
});
// POST /api/skills/:id/moderation/actions — level boundary + Zod + audit log
import { z } from 'zod';
const MODERATOR_LEVELS = ['reporter', 'reviewer', 'senior_moderator', 'policy_admin'];
const ContentModerationActionSchema = z.object({
actionType: z.enum(['flag', 'warn', 'suppress', 'restore', 'policy_override']),
actionLevel: z.enum(MODERATOR_LEVELS),
reason: z.string().min(10).max(2000),
});
router.post(
'/moderation/actions',
requireSession,
requireContentModerator('reviewer'),
async (req, res) => {
const parsed = ContentModerationActionSchema.safeParse(req.body);
if (!parsed.success) return res.status(400).json({ error: 'Invalid payload' });
const callerIdx = MODERATOR_LEVELS.indexOf(req.moderatorLevel);
const actionIdx = MODERATOR_LEVELS.indexOf(parsed.data.actionLevel);
if (actionIdx > callerIdx) {
return res.status(403).json({ error: 'Cannot create action at level exceeding your own' });
}
const action = await ModerationAction.create({
skillId: req.params.id,
actionType: parsed.data.actionType,
actionLevel: parsed.data.actionLevel,
reason: parsed.data.reason,
createdBy: req.session.userId,
createdAt: new Date(),
});
await AuditLog.create({
action: 'moderation.action_created', actorId: req.session.userId,
skillId: req.params.id, actionId: action._id,
actionLevel: parsed.data.actionLevel, at: new Date(),
});
return res.status(201).json({ actionId: action._id });
}
);
PRIVESC42-003 — Any authenticated user modifies global content moderation policies
Severity: HIGH
The global content moderation policy endpoint accepts PATCH requests that update the registry-wide moderation rules — including prohibited content categories, automated takedown triggers, minimum review thresholds, and appeal window durations. The endpoint requires requireSession but not requireContentModerator. Any authenticated registry user — including skill publishers, reviewers, and read-only API consumers — can modify global moderation settings. Changes take effect immediately and affect all future moderation decisions. Attackers can expand prohibited content categories to target competing skills for automatic takedown, shorten appeal windows to prevent legitimate users from contesting erroneous takedowns, or disable automated takedown triggers to allow prohibited content to remain published without moderator review.
// PATCH /api/registry/moderation/policy — requireSession only, no moderator level check
router.patch('/moderation/policy', requireSession, async (req, res) => {
const { prohibitedCategories, takedownTriggers, appealWindowHours } = req.body;
await ModerationPolicy.findOneAndUpdate({}, {
prohibitedCategories, // any user can add competing skills' categories
takedownTriggers, // any user can disable automated moderation
appealWindowHours, // any user can shrink appeal windows to 0
});
return res.json({ updated: true });
});
// PATCH /api/registry/moderation/policy — policy_admin level + Zod + audit log
const ModerationPolicySchema = z.object({
prohibitedCategories: z.array(z.string().max(100)).max(200).optional(),
takedownTriggers: z.object({
autoTakedownEnabled: z.boolean(),
reportThreshold: z.number().int().min(1).max(1000),
}).optional(),
appealWindowHours: z.number().int().min(24).max(720).optional(),
}).refine(d => Object.keys(d).length > 0, 'At least one field required');
router.patch(
'/moderation/policy',
requireSession,
requireContentModerator('policy_admin'),
async (req, res) => {
const parsed = ModerationPolicySchema.safeParse(req.body);
if (!parsed.success) return res.status(400).json({ error: 'Invalid policy payload' });
const prev = await ModerationPolicy.findOne({}).lean();
const updated = await ModerationPolicy.findOneAndUpdate({}, parsed.data, { new: true });
await AuditLog.create({
action: 'moderation.policy_updated', actorId: req.session.userId,
previousPolicy: prev, newPolicy: updated, at: new Date(),
});
return res.json({ updated: true });
}
);
PRIVESC42-004 — Moderator level cache bleed across policy version upgrades
Severity: HIGH
The content moderation level cache is keyed only on userId. When the registry deploys a new moderation policy version — which redefines the permission boundaries associated with each moderator level — the cache is not invalidated. A moderator who held policy_admin level under policy version 1 retains that cached level under policy version 2, even if the new policy version redefines policy_admin to include permissions that the original policy_admin was not intended to have. For example, if policy version 2 adds the ability to export all user report data to policy_admin, moderators whose cached level was set under version 1 immediately gain this new permission without any explicit grant during the 60-second TTL window. The bleed is automatic and requires no action from the affected moderator.
Cache keys must include the policy version that defines the permission boundaries. Any cache that stores authorization levels must be scoped to the specific policy version that was in effect when the level was assigned. When the policy version changes, all cached levels must be invalidated — even if the level names are unchanged — because the same level name may carry different permission boundaries under the new policy version.
// Moderator level cache — keyed on userId only
const moderatorCache = new Map(); // key: userId
// policy version 1: policy_admin can suppress skills and view reports
// policy version 2: policy_admin ALSO gets export-all-reports permission
// moderator cached under v1 automatically gains v2 export permission on next API call
moderatorCache.set('user-123', { level: 'policy_admin', expiresAt: Date.now() + 60_000 });
// new policy deployed — cache NOT invalidated — user-123 gains v2 permissions
// Moderator level cache — keyed on policyVersionId:userId
const moderatorCache = new Map(); // key: `${policyVersionId}:${userId}`
async function getCurrentPolicyVersion() {
const policy = await ModerationPolicy.findOne({}).select('versionId').lean();
return policy?.versionId ?? 'default';
}
function cacheKey(policyVersionId, userId) {
return `${policyVersionId}:${userId}`;
}
async function getModeratorLevel(userId) {
const policyVersionId = await getCurrentPolicyVersion();
const key = cacheKey(policyVersionId, userId);
let entry = moderatorCache.get(key);
if (!entry || Date.now() > entry.expiresAt) {
const mod = await ContentModerator.findOne({ userId }).select('level');
entry = { level: mod?.level ?? null, expiresAt: Date.now() + 60_000 };
moderatorCache.set(key, entry);
}
return entry.level;
}
// on policy version change, purge all entries for prior version
eventBus.on('moderation.policy_version_changed', ({ oldVersionId }) => {
for (const key of moderatorCache.keys()) {
if (key.startsWith(oldVersionId + ':')) moderatorCache.delete(key);
}
});
All four SA-SKL-PRIVESC42 vulnerabilities reflect a consistent pattern of trusting user-controlled or insufficiently-scoped authorization signals for content moderation level checks. SkillAudit detects PRIVESC42-001 by flagging JWT payload field reads used in authorization comparisons without a cache-or-database lookup in the same handler; PRIVESC42-002 by detecting moderation action endpoints without caller-level comparison against action level; PRIVESC42-003 by flagging moderation policy write endpoints without moderator-level middleware; and PRIVESC42-004 by detecting cache key expressions that include userId without a policy version identifier. See also SA-SKL-PRIVESC41 on registry operator and platform administration endpoints for the companion chain targeting platform-level escalation paths.