← Blog

Claude MCP skill privilege escalation — skill analytics dashboard and report management endpoints (SA-SKL-PRIVESC52)

SA-SKL-PRIVESC52 identifies four privilege escalation vulnerabilities in MCP skill registry analytics dashboard and report management endpoints. A forged JWT analyticsLevel claim grants full analytics admin access including raw event export and PII data; a missing level boundary check in the access assignment endpoint allows any analytics viewer to assign themselves the analytics_admin role; a missing ownership check on the global analytics configuration endpoint lets any authenticated user modify PII retention periods and event sampling rates; and an incomplete cache key that omits the analytics policy version ID causes access level entries to bleed across policy upgrades, granting stale elevated access to users whose permissions were downgraded.

SA-SKL-PRIVESC52 findings at a glance
CRITICALPRIVESC52-001 — Analytics viewer access level read from JWT analyticsLevel claim without server-side verification; crafted JWT with analyticsLevel:'analytics_admin' grants full raw event access, PII export, and ability to modify analytics retention policies
CRITICALPRIVESC52-002 — POST /api/analytics/viewer/access missing level boundary check; any analytics viewer assigns analytics_admin to themselves without admin approval
HIGHPRIVESC52-003 — PATCH /api/registry/analytics/config missing ownership check; any authenticated user modifies global analytics configuration including PII retention periods and event sampling rates
MEDIUMPRIVESC52-004 — Analytics access level cache key uses userId without analyticsPolicyVersionId; cache entries bleed across analytics policy upgrades; downgraded users retain stale elevated access until TTL expiry

PRIVESC52-001 — JWT analyticsLevel claim grants analytics_admin without server-side verification

The analytics dashboard authorization middleware reads the user's analytics access level from the analyticsLevel field in the decoded JWT payload. The middleware trusts the claim value directly without verifying it against the access level stored in the database for the authenticated user. Because the JWT is verified for signature validity but not for claim content against the authoritative database record, any user who can generate a valid-signature JWT (through a leaked signing key, algorithm confusion, or JWT none-algorithm bypass) and includes analyticsLevel: "analytics_admin" in the payload is granted full analytics admin access.

The analytics_admin level provides access to raw event streams including user identifiers, session tokens, and behavioral telemetry; the ability to export PII data including email addresses, IP addresses, and usage patterns; and the ability to modify global analytics retention policies that determine how long PII data is stored. In a registry that serves enterprise customers, the PII export capability is a direct GDPR liability: an attacker who escalates to analytics_admin can export the email addresses and behavioral data of all users in the registry without any additional authentication step.

Vulnerable
// PRIVESC52-001 — VULNERABLE
function requireAnalyticsLevel(requiredLevel) {
  const LEVEL_ORDER = ['analytics_viewer', 'analytics_editor', 'analytics_admin'];
  return (req, res, next) => {
    const { analyticsLevel } = req.user; // VULNERABLE: read from JWT claim
    const userIdx = LEVEL_ORDER.indexOf(analyticsLevel);
    const reqIdx  = LEVEL_ORDER.indexOf(requiredLevel);
    if (userIdx < reqIdx) return res.status(403).json({ error: 'Insufficient analytics level' });
    next();
  };
}

router.get('/analytics/raw-events',
  requireSession,
  requireAnalyticsLevel('analytics_admin'), // trusts JWT claim
  async (req, res) => {
    const events = await db.analyticsEvents.findAll({ where: { skillId: req.query.skillId } });
    res.json(events);
  }
);

Attack PoC — PRIVESC52-001: Attacker crafts a JWT with analyticsLevel: "analytics_admin". If the signing key is weak or the algorithm confusion attack applies, the registry grants full analytics admin access and returns raw event data including PII.

// PRIVESC52-001 — ATTACK PoC (algorithm confusion / weak key scenario)
// Craft a JWT with analyticsLevel:'analytics_admin' using discovered HMAC key
const jwt = require('jsonwebtoken');
const weakKey = 'secret'; // discovered via brute force or exposure
const maliciousToken = jwt.sign(
  {
    sub: 'attacker-user-id',
    email: 'attacker@example.com',
    analyticsLevel: 'analytics_admin', // escalated claim
    iat: Math.floor(Date.now() / 1000),
    exp: Math.floor(Date.now() / 1000) + 3600,
  },
  weakKey
);
// Use maliciousToken to access /api/analytics/raw-events?skillId=target
Fixed
// PRIVESC52-001 — FIXED
function requireAnalyticsLevel(requiredLevel) {
  const LEVEL_ORDER = ['analytics_viewer', 'analytics_editor', 'analytics_admin'];
  return async (req, res, next) => {
    // FIXED: read access level from database — never from JWT claim
    const userAccess = await db.analyticsAccess.findOne({
      where: { userId: req.user.sub },
      attributes: ['analyticsLevel'],
    });
    if (!userAccess) return res.status(403).json({ error: 'No analytics access' });
    const userIdx = LEVEL_ORDER.indexOf(userAccess.analyticsLevel);
    const reqIdx  = LEVEL_ORDER.indexOf(requiredLevel);
    if (userIdx < reqIdx) return res.status(403).json({ error: 'Insufficient analytics level' });
    req.analyticsLevel = userAccess.analyticsLevel;
    next();
  };
}

PRIVESC52-002 — Missing level boundary check enables analytics_admin self-assignment

The analytics viewer access assignment endpoint allows an analytics user to request a change to their own access level. The endpoint is intended only to allow analytics editors and admins to assign access levels to other users, but a missing authorization check allows any analytics viewer to call the endpoint and assign themselves any level, including analytics_admin, without requiring approval from an existing admin. The endpoint validates that the requesting user has at least the analytics_viewer role but does not check that the requested level is not higher than the requesting user's current level.

The self-assignment vulnerability is distinct from PRIVESC52-001 in that it creates a persistent escalation: once an attacker calls the endpoint and assigns themselves analytics_admin, the new level is recorded in the database. All subsequent requests that use the fixed PRIVESC52-001 database check will correctly read the now-elevated level, making the escalation durable across sessions and JWT refreshes. The attacker no longer needs to maintain a crafted token; the database record makes the escalation permanent until an admin notices and manually revokes it.

Vulnerable
// PRIVESC52-002 — VULNERABLE
router.post('/analytics/viewer/access',
  requireSession,
  requireAnalyticsLevelAtLeast('analytics_viewer'), // only checks caller is a viewer
  async (req, res) => {
    const { targetUserId, newLevel } = req.body;
    // VULNERABLE: no check that newLevel <= caller's current level
    await db.analyticsAccess.upsert({ userId: targetUserId, analyticsLevel: newLevel });
    res.json({ ok: true });
  }
);

Attack PoC — PRIVESC52-002: Any analytics viewer calls the endpoint, sets their own userId as targetUserId, and assigns themselves analytics_admin. The escalation persists in the database.

// PRIVESC52-002 — ATTACK PoC
await fetch('https://registry.example.com/api/analytics/viewer/access', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json', Authorization: 'Bearer ' + viewerToken },
  body: JSON.stringify({
    targetUserId: 'attacker-user-id', // own userId
    newLevel: 'analytics_admin',
  }),
});
// attacker now has persistent analytics_admin in the database
Fixed
// PRIVESC52-002 — FIXED
const LEVEL_ORDER = ['analytics_viewer', 'analytics_editor', 'analytics_admin'];

router.post('/analytics/viewer/access',
  requireSession,
  requireAnalyticsLevelAtLeast('analytics_admin'), // FIXED: only admins may assign access
  async (req, res) => {
    const parsed = AnalyticsAccessAssignSchema.safeParse(req.body);
    if (!parsed.success) return res.status(422).json({ error: parsed.error.issues });
    const { targetUserId, newLevel } = parsed.data;

    // FIXED: prevent self-assignment (require a second admin for own access changes)
    if (targetUserId === req.user.sub) {
      return res.status(403).json({ error: 'Cannot modify own analytics access level' });
    }

    // FIXED: validate newLevel is a valid enum value
    if (!LEVEL_ORDER.includes(newLevel)) {
      return res.status(422).json({ error: 'Invalid analytics level' });
    }

    await db.analyticsAccess.upsert({ userId: targetUserId, analyticsLevel: newLevel });
    await db.auditLog.create({
      type: 'analyticsAccess.changed',
      actorId: req.user.sub,
      targetUserId,
      newLevel,
    });
    res.json({ ok: true });
  }
);

PRIVESC52-003 — Missing ownership check on global analytics config endpoint

The global analytics configuration endpoint allows updating registry-wide analytics settings including PII retention periods, event sampling rates, and the list of event types that are captured and stored. The endpoint is intended to be accessible only to registry administrators, but the authorization middleware only checks that the requester has an active session — it does not verify that the user has the analytics_admin level or the registry_admin role. Any authenticated user, including skill publishers with no analytics access, can call PATCH /api/registry/analytics/config and modify global analytics settings.

The most damaging modification an attacker can make through PRIVESC52-003 is shortening the PII retention period to zero, which may trigger the registry's automated PII deletion job and permanently destroy user event data. Alternatively, an attacker can set the event sampling rate to zero, disabling all analytics event capture and blinding the registry's operators to usage anomalies and security events that would normally be detected through analytics monitoring. Neither modification requires elevated privileges, and both are destructive in ways that are difficult to reverse if the events have already been purged.

Vulnerable
// PRIVESC52-003 — VULNERABLE
router.patch('/registry/analytics/config',
  requireSession, // VULNERABLE: only checks session — no role check
  async (req, res) => {
    const { piiRetentionDays, samplingRate, capturedEventTypes } = req.body;
    await db.analyticsConfig.update(
      { piiRetentionDays, samplingRate, capturedEventTypes },
      { where: { registryId: 'global' } }
    );
    res.json({ ok: true });
  }
);

Attack PoC — PRIVESC52-003: Any authenticated user sets the PII retention period to 1 day, triggering the automated purge job. All historical user event data older than 24 hours is permanently deleted.

// PRIVESC52-003 — ATTACK PoC
// Authenticated as any skill publisher (no analytics role required)
await fetch('https://registry.example.com/api/registry/analytics/config', {
  method: 'PATCH',
  headers: { 'Content-Type': 'application/json', Authorization: 'Bearer ' + publisherToken },
  body: JSON.stringify({
    piiRetentionDays: 1,   // triggers purge of all data older than 1 day
    samplingRate: 0,        // disables all event capture
    capturedEventTypes: [], // clears all event type tracking
  }),
});
Fixed
// PRIVESC52-003 — FIXED
router.patch('/registry/analytics/config',
  requireSession,
  requireRegistryAdmin, // FIXED: registry admin role check
  async (req, res) => {
    const parsed = AnalyticsConfigSchema.safeParse(req.body);
    if (!parsed.success) return res.status(422).json({ error: parsed.error.issues });
    const { piiRetentionDays, samplingRate, capturedEventTypes } = parsed.data;

    // FIXED: enforce minimum retention — prevent accidental/malicious purge trigger
    if (piiRetentionDays < 30) {
      return res.status(422).json({ error: 'PII retention minimum is 30 days' });
    }

    const previous = await db.analyticsConfig.findOne({ where: { registryId: 'global' } });
    await previous.update({ piiRetentionDays, samplingRate, capturedEventTypes });
    await db.auditLog.create({
      type: 'analyticsConfig.changed',
      actorId: req.user.sub,
      previous: previous.toJSON(),
      next: { piiRetentionDays, samplingRate, capturedEventTypes },
    });
    res.json({ ok: true });
  }
);

PRIVESC52-004 — Analytics access level cache bleed across policy version upgrades

The analytics authorization layer caches each user's resolved access level in Redis using a cache key of the form analyticsLevel:${userId}. When the registry administrator upgrades the analytics access policy — for example, to roll out a new GDPR-compliant configuration that restricts analytics_editor users from exporting raw event data — the new policy version is stored with a new analyticsPolicyVersionId. However, existing cache entries remain valid for their full TTL (typically 15 minutes) because the cache key does not include the policy version ID. Users whose access level was downgraded under the new policy continue to operate with the old cached level for up to 15 minutes after the policy upgrade.

The practical impact is a 15-minute window during which downgraded users retain their previous elevated access. For an attacker who is actively exploiting PRIVESC52-002, the cache bleed means that even after an admin notices the unauthorized self-assignment and revokes it, the attacker continues to have elevated analytics access for the duration of the cache TTL. An attacker who times the PRIVESC52-002 escalation to coincide with the administrator's work hours can maintain a 15-minute elevated window that is sufficient to export the full raw event archive.

Vulnerable
// PRIVESC52-004 — VULNERABLE
async function getAnalyticsLevel(userId) {
  // VULNERABLE: cache key excludes analyticsPolicyVersionId — bleeds across upgrades
  const cacheKey = `analyticsLevel:${userId}`;
  const cached = await redis.get(cacheKey);
  if (cached) return cached;

  const access = await db.analyticsAccess.findOne({ where: { userId } });
  const level = access?.analyticsLevel ?? 'analytics_viewer';
  await redis.setex(cacheKey, 900, level); // 15-minute TTL
  return level;
}
Fixed
// PRIVESC52-004 — FIXED
async function getAnalyticsLevel(userId) {
  // FIXED: include analyticsPolicyVersionId in cache key
  const policyVersion = await getCurrentAnalyticsPolicyVersion(); // e.g. "v7"
  const cacheKey = `analyticsLevel:${userId}:${policyVersion}`;
  const cached = await redis.get(cacheKey);
  if (cached) return cached;

  const access = await db.analyticsAccess.findOne({ where: { userId } });
  const level = access?.analyticsLevel ?? 'analytics_viewer';
  await redis.setex(cacheKey, 900, level);
  return level;
}

// On policy upgrade: bump policyVersion in DB — old cache keys become stale automatically
// No manual cache flush required; old keys expire naturally with zero bleed

SkillAudit detection: The scanner identifies PRIVESC52 patterns using four AST query classes: req.user.analyticsLevel reads used for authorization decisions without a subsequent database verification step; db.analyticsAccess.upsert calls without a callerLevel >= targetLevel boundary check in the same handler; PATCH route handlers matching /analytics/config without a requireRegistryAdmin or equivalent middleware call; and Redis setex cache key strings that include userId but not a policy version identifier. Submit your MCP skill registry codebase to SkillAudit for a full audit report.

Related: SA-SKL-PRIVESC51 — Privilege escalation in skill build worker and compilation job management endpoints • All advisories