Claude MCP skill privilege escalation — skill analytics and reporting dashboard access endpoints (SA-SKL-PRIVESC55)
SA-SKL-PRIVESC55 identifies four privilege escalation vulnerabilities in MCP skill registry skill analytics and reporting dashboard access endpoints. Analytics access level read from a JWT analyticsLevel claim allows any user to craft a token granting analytics_admin access to cross-org analytics, revenue dashboards, and user behavior data; a missing level boundary check on the access assignment endpoint allows any skill author to self-assign analytics_admin; a missing ownership check on the global analytics configuration endpoint allows any authenticated user to modify PII retention periods, sampling rates, and cross-org data sharing settings; and an analytics access level cache key that omits the policy version ID causes cache entries to bleed across policy upgrades, leaving recently-downgraded users with stale elevated access until the TTL expires.
analyticsLevel claim — craft JWT with analyticsLevel:'analytics_admin' grants access to all org cross-skill analytics, revenue dashboards, and user behavior dataPOST /api/registry/analytics/access missing level boundary check — any skill author assigns analytics_admin to themselves granting cross-org analytics accessPATCH /api/registry/analytics/config missing ownership check — any authenticated user modifies global analytics retention, sampling rates, and cross-org data sharing settingsuserId without analyticsPolicyVersionId — cache entries bleed across analytics policy upgrades; downgraded users retain elevated access until TTL expiryPRIVESC55-001 — JWT analyticsLevel claim grants analytics_admin via token forgery
When the registry reads the user's analytics access level directly from a JWT claim (req.jwtPayload.analyticsLevel) rather than from a database-backed authorization record, any user who can craft a valid JWT with an elevated analyticsLevel value can gain analytics_admin access. In practice, the JWT is signed by the registry itself and cannot be forged without the signing key. However, this pattern fails under three common conditions: when the JWT signing key is rotated without invalidating issued tokens; when the registry has a JWT algorithm confusion vulnerability (e.g., accepting alg:none); or when a user's access level is downgraded after JWT issuance but the existing token (which may have a 24-hour or longer TTL) continues to grant the old access level. The analytics_admin level grants access to cross-org analytics aggregations, all-org revenue dashboards, and user behavior event streams that may contain PII including email addresses and geographic data.
// PRIVESC55-001 — VULNERABLE
router.get('/analytics/dashboard', requireSession, async (req, res) => {
// VULNERABLE: analyticsLevel read from JWT claim, not from DB
const { analyticsLevel } = req.jwtPayload;
if (analyticsLevel === 'analytics_admin') {
// grants access to cross-org analytics, all-org revenue, user behavior PII
const data = await db.analyticsAdmin.getCrossOrgDashboard();
return res.json(data);
}
// ... lower-level access
});
Attack scenario — PRIVESC55-001: User with any valid JWT modifies the token payload to include analyticsLevel: "analytics_admin". If the registry uses a symmetric signing algorithm (HS256) and the signing key is known or weak, the token is re-signed. If the registry has an alg:none vulnerability, the modified token is accepted without re-signing. In either case, the user gains access to all-org analytics including revenue data and user PII.
// PRIVESC55-001 — FIXED
const analyticsLevelCache = new Map(); // policyVersionId:userId → {level, expiresAt}
async function getAnalyticsLevel(userId, analyticsPolicyVersionId) {
const cacheKey = `${analyticsPolicyVersionId}:${userId}`;
const cached = analyticsLevelCache.get(cacheKey);
if (cached && cached.expiresAt > Date.now()) return cached.level;
// FIXED: DB-backed access level lookup; never read analyticsLevel from JWT
const record = await db.analyticsAccessLevels.findOne({
where: { userId, analyticsPolicyVersionId },
select: { level: true },
});
const level = record?.level ?? 'analytics_viewer';
analyticsLevelCache.set(cacheKey, { level, expiresAt: Date.now() + 60_000 });
return level;
}
router.get('/analytics/dashboard', requireSession, async (req, res) => {
// FIXED: level from DB via versioned cache, never from JWT
const policy = await db.analyticsPolicies.findFirst({ orderBy: { createdAt: 'desc' } });
const analyticsLevel = await getAnalyticsLevel(req.session.userId, policy.id);
if (analyticsLevel === 'analytics_admin') {
const data = await db.analyticsAdmin.getCrossOrgDashboard();
return res.json(data);
}
// ... lower-level access
});
PRIVESC55-002 — Missing level boundary check enables analytics_admin self-assignment
The analytics access assignment endpoint allows users to request or be granted analytics access levels. When the endpoint fails to enforce a boundary check — specifically, that a user cannot assign an access level equal to or higher than their own current level — any skill author can send a request assigning themselves analytics_admin. Because skill authors have a valid session and can call any authenticated endpoint, and because analytics_admin is simply another enum value in the analyticsLevel field, there is no technical barrier preventing the assignment beyond the missing boundary check.
// PRIVESC55-002 — VULNERABLE
router.post('/analytics/access', requireSession, async (req, res) => {
const { targetUserId, newLevel } = req.body;
// VULNERABLE: no boundary check — any user can assign analytics_admin to self
await db.analyticsAccessLevels.upsert({
where: { userId: targetUserId },
update: { level: newLevel },
create: { userId: targetUserId, level: newLevel },
});
res.json({ updated: true });
});
// PRIVESC55-002 — FIXED
const ANALYTICS_LEVEL_ORDER = {
analytics_viewer: 0,
analytics_contributor: 1,
analytics_manager: 2,
analytics_admin: 3,
};
const AnalyticsAccessAssignSchema = z.object({
targetUserId: z.string().uuid(),
newLevel: z.enum(['analytics_viewer', 'analytics_contributor', 'analytics_manager']),
// FIXED: analytics_admin is not in the assignable enum — only direct DB grants
});
router.post('/analytics/access', requireSession, async (req, res) => {
const { targetUserId, newLevel } = AnalyticsAccessAssignSchema.parse(req.body);
const policy = await db.analyticsPolicies.findFirst({ orderBy: { createdAt: 'desc' } });
const actorLevel = await getAnalyticsLevel(req.session.userId, policy.id);
const targetCurrentLevel = await getAnalyticsLevel(targetUserId, policy.id);
// FIXED: actor must be at least analytics_admin to assign any level
if (ANALYTICS_LEVEL_ORDER[actorLevel] < ANALYTICS_LEVEL_ORDER['analytics_admin']) {
return res.status(403).json({ error: 'Insufficient level to assign analytics access' });
}
// FIXED: prevent self-assignment
if (targetUserId === req.session.userId) {
return res.status(400).json({ error: 'Cannot assign analytics access to yourself' });
}
await db.analyticsAccessLevels.upsert({
where: { userId: targetUserId, analyticsPolicyVersionId: policy.id },
update: { level: newLevel },
create: { userId: targetUserId, analyticsPolicyVersionId: policy.id, level: newLevel },
});
// FIXED: invalidate cache for target user immediately
analyticsLevelCache.delete(`${policy.id}:${targetUserId}`);
await auditLog.write({
action: 'analytics_access_assign',
actorId: req.session.userId,
targetId: targetUserId,
fromLevel: targetCurrentLevel,
toLevel: newLevel,
});
res.json({ updated: true });
});
PRIVESC55-003 — Missing ownership check enables global analytics config modification
The analytics configuration endpoint allows modification of global analytics settings including PII data retention periods, event sampling rates, and cross-org data sharing enable/disable flags. Because there is no ownership or admin-level check on this endpoint, any authenticated user can modify these global settings. An attacker who reduces the PII retention period to zero causes immediate purging of historical analytics data; an attacker who enables cross-org data sharing exposes all skill analytics data to any org that requests cross-org access; and an attacker who sets the sampling rate to zero disables analytics collection entirely for all skills in the registry.
// PRIVESC55-003 — VULNERABLE
router.patch('/analytics/config', requireSession, async (req, res) => {
// VULNERABLE: no ownership or admin check — any authenticated user modifies globals
const { piiRetentionDays, samplingRate, crossOrgSharingEnabled } = req.body;
await db.analyticsConfig.update({
where: { id: 'global' },
data: { piiRetentionDays, samplingRate, crossOrgSharingEnabled },
});
res.json({ updated: true });
});
// PRIVESC55-003 — FIXED
const AnalyticsConfigSchema = z.object({
piiRetentionDays: z.number().int().min(30).max(730), // minimum 30 days enforced
samplingRate: z.number().min(0.01).max(1.0), // minimum 1% sampling enforced
crossOrgSharingEnabled: z.boolean(),
});
router.patch('/analytics/config', requireSession, async (req, res) => {
const policy = await db.analyticsPolicies.findFirst({ orderBy: { createdAt: 'desc' } });
const actorLevel = await getAnalyticsLevel(req.session.userId, policy.id);
// FIXED: require analytics_admin level for global config modification
if (actorLevel !== 'analytics_admin') {
return res.status(403).json({ error: 'analytics_admin level required' });
}
const validated = AnalyticsConfigSchema.parse(req.body);
const before = await db.analyticsConfig.findUnique({ where: { id: 'global' } });
const after = await db.analyticsConfig.update({
where: { id: 'global' },
data: validated,
});
// FIXED: audit log with before/after diff
await auditLog.write({
action: 'analytics_config_modify',
actorId: req.session.userId,
before: { piiRetentionDays: before.piiRetentionDays, samplingRate: before.samplingRate, crossOrgSharingEnabled: before.crossOrgSharingEnabled },
after: { piiRetentionDays: after.piiRetentionDays, samplingRate: after.samplingRate, crossOrgSharingEnabled: after.crossOrgSharingEnabled },
});
res.json({ updated: true });
});
PRIVESC55-004 — Analytics access level cache bleed across policy upgrades
The analytics access level cache uses only userId as the cache key, without incorporating the current analyticsPolicyVersionId. When an analytics policy is upgraded (e.g., because an org admin creates a new policy that restricts analytics_admin access to a smaller set of users), the existing cache entries for downgraded users remain valid until their TTL expires. During the TTL window — which may be 60 seconds to several minutes depending on configuration — recently-downgraded users retain their old elevated access level and can continue to access cross-org analytics, revenue dashboards, and user PII. In a targeted attack, an attacker who is granted temporary analytics_admin access and subsequently downgraded continues to hold elevated access for the full cache TTL after the downgrade.
// PRIVESC55-004 — VULNERABLE: cache key omits policy version
const badAnalyticsCache = new Map(); // userId → {level, expiresAt}
async function getAnalyticsLevelVulnerable(userId) {
const cached = badAnalyticsCache.get(userId); // VULNERABLE: no policyVersionId in key
if (cached && cached.expiresAt > Date.now()) return cached.level;
const record = await db.analyticsAccessLevels.findFirst({
where: { userId },
orderBy: { analyticsPolicyVersionId: 'desc' },
select: { level: true },
});
const level = record?.level ?? 'analytics_viewer';
badAnalyticsCache.set(userId, { level, expiresAt: Date.now() + 60_000 });
return level;
// VULNERABLE: if policy upgraded and user downgraded, old elevated level
// remains in cache for up to 60 seconds
}
// PRIVESC55-004 — FIXED: cache key includes policyVersionId
// (same getAnalyticsLevel function shown in PRIVESC55-001 fix above)
// Key pattern: `${analyticsPolicyVersionId}:${userId}`
// On policy upgrade: new policyVersionId → all old cache entries naturally
// expire because they use the old policyVersionId in their key
// FIXED: level change event explicitly invalidates old cache entry
async function onAnalyticsLevelChanged(userId, newLevel) {
const policy = await db.analyticsPolicies.findFirst({ orderBy: { createdAt: 'desc' } });
// invalidate current policy version entry for this user
analyticsLevelCache.delete(`${policy.id}:${userId}`);
// also invalidate previous policy version entries (if any)
for (const [key] of analyticsLevelCache) {
if (key.endsWith(`:${userId}`)) analyticsLevelCache.delete(key);
}
}
SkillAudit detection: Run SkillAudit on your MCP skill registry to automatically detect PRIVESC55-class patterns. The scanner flags JWT claim-based authorization reads, missing level boundary checks on access assignment endpoints, missing admin-level guards on global configuration endpoints, and cache keys missing policy version identifiers — producing a graded report with file locations and remediation guidance. See also SA-SKL-CORS71 compound attack chain analysis for related MCP skill registry security patterns.