← Blog

Claude MCP skill privilege escalation — skill package signing key and certificate management endpoints (SA-SKL-PRIVESC50)

SA-SKL-PRIVESC50 identifies four privilege escalation vulnerabilities in MCP skill registry package signing key and certificate management endpoints. A forged JWT signingKeyLevel claim grants full key administrator access enabling supply-chain-level attacks; a missing level boundary check allows self-escalation to key_admin; a missing ownership check on the global signing configuration endpoint lets any authenticated user modify certificate validity periods and trusted key identities; and a cache key that omits the signing policy version bleeds elevated access across policy upgrades.

SA-SKL-PRIVESC50 findings at a glance
CRITICALPRIVESC50-001 — signing key access level read from JWT signingKeyLevel claim; craft JWT with signingKeyLevel:'key_admin' grants ability to rotate all skill signing keys, revoke existing key trusts, and issue new signing certificates for attacker-controlled identities
HIGHPRIVESC50-002 — POST /api/signing/key/access missing level boundary check; any signing key user assigns key_admin to themselves; fix: requireSession; KEY_LEVEL_ORDER ordinal comparison; Zod KeyLevelSchema; audit log
HIGHPRIVESC50-003 — PATCH /api/registry/signing/config missing ownership check; any authenticated user modifies global signing configuration including trusted key identities, certificate validity periods, and key rotation policies; fix: require key_admin level; Zod SigningConfigSchema; audit log with before/after diff
HIGHPRIVESC50-004 — signing key access level cache key uses userId without signingPolicyVersionId; cache entries bleed across signing policy version upgrades; fix: cache key = signingPolicyVersionId:userId; invalidate entire cache on policy upgrade event; strict 60s TTL

PRIVESC50-001 — JWT signingKeyLevel claim forged to key_admin

The signing key management API reads the caller's access level from the signingKeyLevel claim in the JWT. Rather than loading the access level from the database on each request, the middleware trusts the JWT-encoded value directly. An attacker who obtains any valid JWT — even one issued for the lowest key_viewer role — can decode the token, modify the payload to set signingKeyLevel: "key_admin", and re-sign with a known or guessable secret. With key_admin level, the attacker can rotate all skill signing keys (invalidating every existing installation's signature verification), revoke trusted key identities from the registry, and issue new signing certificates bound to attacker-controlled email identities via the Sigstore transparency log.

Vulnerable
// PRIVESC50-001 — VULNERABLE
function requireSigningKeyLevel(requiredLevel) {
  return (req, res, next) => {
    const token = req.headers.authorization?.split(' ')[1];
    if (!token) return res.status(401).json({ error: 'Missing token' });
    const payload = jwt.verify(token, process.env.JWT_SECRET);
    // VULNERABLE: signingKeyLevel read directly from JWT claim — attacker forges this
    req.signingKeyLevel = payload.signingKeyLevel;
    if (!meetsLevel(req.signingKeyLevel, requiredLevel)) {
      return res.status(403).json({ error: 'Insufficient signing key level' });
    }
    next();
  };
}
Fixed
// PRIVESC50-001 — FIXED
// In-process cache: 60s TTL, keyed on userId
const signingKeyLevelCache = new Map();

async function getSigningKeyLevel(userId) {
  const cached = signingKeyLevelCache.get(userId);
  if (cached && Date.now() - cached.at < 60_000) return cached.level;
  // FIXED: level loaded from DB, not from JWT claim
  const record = await db.signingKeyAccess.findOne({ where: { userId } });
  const level = record?.level ?? 'key_viewer';
  signingKeyLevelCache.set(userId, { level, at: Date.now() });
  return level;
}

function requireSigningKeyLevel(requiredLevel) {
  return async (req, res, next) => {
    if (!req.session?.userId) return res.status(401).json({ error: 'Not authenticated' });
    // FIXED: JWT carries only sub; level loaded from DB
    const level = await getSigningKeyLevel(req.session.userId);
    if (!meetsLevel(level, requiredLevel)) {
      return res.status(403).json({ error: 'Insufficient signing key level' });
    }
    req.signingKeyLevel = level;
    next();
  };
}

Supply-chain impact of key_admin escalation: A key_admin can rotate every signing key in the registry. When a signing key is rotated, all existing installations that pin the old public key fingerprint begin failing signature verification. The attacker can issue a new signing certificate under their own Sigstore identity, then sign malicious artifacts that pass the registry's attestation checks for any skill they choose to target.

PRIVESC50-002 — Missing level boundary check on key access assignment

The POST /api/signing/key/access endpoint allows an administrator to assign a signing key access level to another user. The endpoint verifies that the caller is authenticated but does not verify that the target level is lower than or equal to the caller's own level. Any user with key_user level can submit a request assigning key_admin to their own userId. Because the assignment takes effect immediately, the attacker gains full key management capabilities in the same request that performs the escalation.

Vulnerable
// PRIVESC50-002 — VULNERABLE
router.post('/key/access',
  requireSession,
  async (req, res) => {
    const { targetUserId, newLevel } = req.body;
    // VULNERABLE: no level boundary check — any user assigns key_admin to themselves
    await db.signingKeyAccess.upsert({ userId: targetUserId, level: newLevel });
    res.json({ ok: true });
  }
);
Fixed
// PRIVESC50-002 — FIXED
const KEY_LEVEL_ORDER = ['key_viewer', 'key_user', 'key_manager', 'key_admin'];
const { z } = require('zod');

const KeyLevelSchema = z.enum(['key_viewer', 'key_user', 'key_manager', 'key_admin']);

router.post('/key/access',
  requireSession,
  requireSigningKeyLevel('key_admin'),
  async (req, res) => {
    const parsed = z.object({
      targetUserId: z.string().uuid(),
      newLevel: KeyLevelSchema,
    }).safeParse(req.body);
    if (!parsed.success) return res.status(422).json({ error: parsed.error.issues });
    const { targetUserId, newLevel } = parsed.data;
    const callerLevel = req.signingKeyLevel;
    // FIXED: cannot assign a level higher than caller's own level
    if (KEY_LEVEL_ORDER.indexOf(newLevel) > KEY_LEVEL_ORDER.indexOf(callerLevel)) {
      return res.status(403).json({ error: 'Cannot assign level exceeding your own' });
    }
    await db.signingKeyAccess.upsert({ userId: targetUserId, level: newLevel });
    // Invalidate cached level for target user
    signingKeyLevelCache.delete(targetUserId);
    await db.auditLog.create({
      type: 'signing.key.access.assigned',
      actorId: req.session.userId,
      targetUserId,
      newLevel,
    });
    res.json({ ok: true });
  }
);

PRIVESC50-003 — Missing ownership check on global signing configuration

The PATCH /api/registry/signing/config endpoint modifies the global signing configuration for the registry: trusted key identities, certificate validity periods, key rotation policy, and the list of accepted Sigstore transparency log endpoints. The endpoint requires only that the caller be authenticated — it does not require key_admin level. Any authenticated user can submit a PATCH request extending certificate validity periods to 10 years (reducing rotation frequency and prolonging the window for key compromise), adding their own public key identity as a trusted signer, or modifying the key rotation policy to disable automatic rotation.

Vulnerable
// PRIVESC50-003 — VULNERABLE
router.patch('/signing/config',
  requireSession, // VULNERABLE: only checks authentication, not key_admin level
  async (req, res) => {
    const { trustedKeyIdentities, certValidityDays, rotationPolicyDays } = req.body;
    await db.signingConfig.update({
      trustedKeyIdentities,
      certValidityDays,
      rotationPolicyDays,
    }, { where: { registryId: REGISTRY_ID } });
    res.json({ ok: true });
  }
);
Fixed
// PRIVESC50-003 — FIXED
const SigningConfigSchema = z.object({
  trustedKeyIdentities: z.array(z.string().email()).min(1),
  certValidityDays: z.number().int().min(1).max(365), // cap at 1 year
  rotationPolicyDays: z.number().int().min(30).max(180),
});

router.patch('/signing/config',
  requireSession,
  requireSigningKeyLevel('key_admin'), // FIXED: require key_admin level
  async (req, res) => {
    const parsed = SigningConfigSchema.safeParse(req.body);
    if (!parsed.success) return res.status(422).json({ error: parsed.error.issues });
    const before = await db.signingConfig.findOne({ where: { registryId: REGISTRY_ID } });
    await db.signingConfig.update(parsed.data, { where: { registryId: REGISTRY_ID } });
    // FIXED: audit log with before/after diff for compliance review
    await db.auditLog.create({
      type: 'signing.config.updated',
      actorId: req.session.userId,
      before: JSON.stringify(before),
      after: JSON.stringify(parsed.data),
    });
    res.json({ ok: true });
  }
);

PRIVESC50-004 — Signing key access level cache bleed across policy upgrades

The signing key access level cache uses userId as the cache key without including the signingPolicyVersionId. When a new signing policy is published — for example, reducing the maximum certificate validity period or removing a deprecated key identity from the trusted list — existing cache entries continue to serve the old access level and configuration context until they expire naturally after 60 seconds. An attacker who was granted key_admin under the previous policy, and whose access was revoked in the new policy, retains full key management capabilities for up to 60 seconds after the policy upgrade. In a worst-case scenario where the registry does not emit a cache invalidation event, the attacker retains elevated access indefinitely if the 60-second TTL is not enforced correctly.

Vulnerable
// PRIVESC50-004 — VULNERABLE
// Cache key: userId only — no signingPolicyVersionId
const signingKeyLevelCache = new Map();

async function getSigningKeyLevel(userId) {
  const cached = signingKeyLevelCache.get(userId); // VULNERABLE: stale across policy upgrades
  if (cached && Date.now() - cached.at < 60_000) return cached.level;
  const record = await db.signingKeyAccess.findOne({ where: { userId } });
  const level = record?.level ?? 'key_viewer';
  signingKeyLevelCache.set(userId, { level, at: Date.now() });
  return level;
}

// Policy upgrade does NOT invalidate cache
async function upgradeSigningPolicy(newPolicyVersionId) {
  await db.signingPolicy.create({ versionId: newPolicyVersionId });
  // VULNERABLE: cache not invalidated — revoked key_admin retains access for up to 60s
}
Fixed
// PRIVESC50-004 — FIXED
// Cache key: signingPolicyVersionId:userId
const signingKeyLevelCache = new Map();

async function getCurrentSigningPolicyVersionId() {
  const policy = await db.signingPolicy.findOne({ order: [['createdAt', 'DESC']] });
  return policy?.versionId ?? 'default';
}

async function getSigningKeyLevel(userId) {
  const policyVersionId = await getCurrentSigningPolicyVersionId();
  const cacheKey = `${policyVersionId}:${userId}`;
  const cached = signingKeyLevelCache.get(cacheKey);
  if (cached && Date.now() - cached.at < 60_000) return cached.level;
  const record = await db.signingKeyAccess.findOne({ where: { userId } });
  const level = record?.level ?? 'key_viewer';
  // FIXED: cache key includes policy version — stale entries auto-miss on upgrade
  signingKeyLevelCache.set(cacheKey, { level, at: Date.now() });
  return level;
}

async function upgradeSigningPolicy(newPolicyVersionId) {
  await db.signingPolicy.create({ versionId: newPolicyVersionId });
  // FIXED: invalidate entire cache on policy upgrade
  signingKeyLevelCache.clear();
  await emitEvent('signing.policy.upgraded', { versionId: newPolicyVersionId });
}

SkillAudit detection: The scanner identifies PRIVESC50 patterns using four AST query classes: payload.signingKeyLevel read from a JWT payload object; db.signingKeyAccess.upsert( without a preceding KEY_LEVEL_ORDER.indexOf boundary comparison; router.patch( routes containing signingConfig or signing/config without a requireSigningKeyLevel middleware call; and signingKeyLevelCache Map declarations whose key does not include a policy version identifier. Submit your MCP skill registry codebase to SkillAudit for a full audit report.

Related: SA-SKL-PRIVESC49: Privilege escalation in search index and feature management endpoints • All advisories