← Blog

Claude MCP skill privilege escalation — skill search index and discovery feature management endpoints (SA-SKL-PRIVESC49)

SA-SKL-PRIVESC49 identifies four privilege escalation vulnerabilities in MCP skill registry search index and discovery feature management endpoints. JWT-based indexing level claims enable index_admin escalation; missing level boundary checks allow self-promotion; a missing ownership check on global search configuration enables any authenticated user to manipulate all skills' search rankings; and a cache key design flaw bleeds elevated privileges across search policy version upgrades.

SA-SKL-PRIVESC49 findings at a glance
CRITICALPRIVESC49-001 — Search indexing level read from JWT indexingLevel claim; craft JWT with indexingLevel:'index_admin' grants ability to modify search index weights, suppress skills from search, and boost attacker-controlled skills in search rankings; fix: DB-backed level cache; JWT carries only sub
HIGHPRIVESC49-002 — POST /api/search/index/access missing level boundary check; any indexing user assigns index_admin to themselves exceeding their own indexing scope; fix: INDEX_LEVEL_ORDER ordinal comparison; Zod IndexLevelSchema; audit log
HIGHPRIVESC49-003 — PATCH /api/registry/search/config missing ownership check; any authenticated user modifies global search configuration including index weights, featured skill slots, and search result boosting rules; fix: require index_admin level; Zod SearchConfigSchema; audit log with before/after diff
HIGHPRIVESC49-004 — Search indexing level cache key uses userId without searchPolicyVersionId; cache entries bleed across search policy version upgrades; fix: cache key = searchPolicyVersionId:userId; invalidate entire cache on policy upgrade event; strict 60s TTL

PRIVESC49-001 — JWT indexingLevel claim grants index_admin

The search index management API uses a JWT claim indexingLevel to determine whether the caller can modify search index weights, feature slots, and suppression rules. The registry reads this claim directly from the JWT payload without validating it against the database. An attacker who can craft or obtain a JWT with indexingLevel: "index_admin" gains full search administration privileges: they can suppress competitors' skills from all search results, boost their own skills to the top of every result page, and modify the global index weight configuration to favour attacker-controlled skill categories.

Vulnerable
// PRIVESC49-001 — VULNERABLE
router.use('/search/index', (req, res, next) => {
  const token = req.headers.authorization?.split(' ')[1];
  const payload = jwt.verify(token, process.env.JWT_SECRET);
  // VULNERABLE: indexingLevel read from JWT payload — not from database
  req.indexingLevel = payload.indexingLevel;
  next();
});

router.patch('/search/index/weights', (req, res, next) => {
  if (req.indexingLevel !== 'index_admin') {
    return res.status(403).json({ error: 'index_admin required' });
  }
  // Attacker with crafted JWT indexingLevel:'index_admin' reaches here
  updateIndexWeights(req.body);
  res.json({ ok: true });
});
Fixed
// PRIVESC49-001 — FIXED
// DB-backed level cache — JWT carries only sub (user ID)
const indexingLevelCache = new Map(); // { userId → { level, expiresAt } }

async function requireIndexingLevel(minLevel) {
  return async (req, res, next) => {
    const token = req.headers.authorization?.split(' ')[1];
    const { sub: userId } = jwt.verify(token, process.env.JWT_SECRET);
    // FIXED: level comes from DB, not JWT claim
    const cached = indexingLevelCache.get(userId);
    let level;
    if (cached && cached.expiresAt > Date.now()) {
      level = cached.level;
    } else {
      const user = await db.users.findOne({ where: { id: userId }, attributes: ['indexingLevel'] });
      level = user?.indexingLevel ?? 'none';
      indexingLevelCache.set(userId, { level, expiresAt: Date.now() + 60_000 }); // 60s TTL
    }
    if (INDEX_LEVEL_ORDER.indexOf(level) < INDEX_LEVEL_ORDER.indexOf(minLevel)) {
      return res.status(403).json({ error: `${minLevel} level required` });
    }
    req.indexingLevel = level;
    next();
  };
}

const INDEX_LEVEL_ORDER = ['none', 'indexer', 'index_admin'];
router.patch('/search/index/weights', requireIndexingLevel('index_admin'), updateIndexWeightsHandler);

Search ranking manipulation impact: An attacker with index_admin privileges can suppress any competitor skill from search results (effectively removing it from registry discovery), boost their own malicious skills to top positions, and modify the featured skill slots that appear on the registry homepage. In a registry with thousands of skills, search ranking is the primary discovery mechanism — manipulation at this level is equivalent to editorial control over the entire marketplace.

PRIVESC49-002 — Missing level boundary check allows self-escalation to index_admin

The POST /api/search/index/access endpoint allows indexing users to grant indexing access to other users. The endpoint validates that the caller has at least indexer level, but it does not check that the target level being assigned is within the caller's own scope. An indexer-level user can call this endpoint to assign index_admin to themselves, escalating beyond their authorised level.

Vulnerable
// PRIVESC49-002 — VULNERABLE
router.post('/search/index/access',
  requireIndexingLevel('indexer'), // only checks caller has indexer level
  async (req, res) => {
    const { targetUserId, newLevel } = req.body;
    // VULNERABLE: no check that newLevel <= caller's own level
    // attacker calls: { targetUserId: attackerOwnId, newLevel: 'index_admin' }
    await db.users.update({ indexingLevel: newLevel }, { where: { id: targetUserId } });
    res.json({ ok: true });
  }
);
Fixed
// PRIVESC49-002 — FIXED
const { z } = require('zod');
const IndexLevelSchema = z.enum(['none', 'indexer', 'index_admin']);

router.post('/search/index/access',
  requireIndexingLevel('indexer'),
  async (req, res) => {
    const { targetUserId, newLevel } = z.object({
      targetUserId: z.string().uuid(),
      newLevel: IndexLevelSchema,
    }).parse(req.body);

    // FIXED: level boundary check — cannot grant higher level than caller's own
    const callerOrdinal = INDEX_LEVEL_ORDER.indexOf(req.indexingLevel);
    const targetOrdinal = INDEX_LEVEL_ORDER.indexOf(newLevel);
    if (targetOrdinal > callerOrdinal) {
      return res.status(403).json({ error: 'Cannot grant level higher than your own' });
    }

    await db.users.update({ indexingLevel: newLevel }, { where: { id: targetUserId } });
    // Invalidate level cache for target user
    indexingLevelCache.delete(targetUserId);

    await db.auditLog.create({
      type: 'search_index_access.changed',
      actorId: req.session.userId,
      targetUserId,
      newLevel,
      callerLevel: req.indexingLevel,
    });
    res.json({ ok: true });
  }
);

PRIVESC49-003 — Missing ownership check on global search config

The PATCH /api/registry/search/config endpoint modifies the global search configuration: index field weights, featured skill slot assignments, search result boosting rules, and prohibited keyword filters. The endpoint is protected by requireSession (session authentication) but has no check for index_admin level. Any authenticated user can call this endpoint to modify the global search configuration, manipulating search results for all skills in the registry.

Vulnerable
// PRIVESC49-003 — VULNERABLE
router.patch('/registry/search/config',
  requireSession, // only checks authentication, not authorization level
  async (req, res) => {
    // VULNERABLE: any authenticated user can modify global search config
    await db.searchConfig.update(req.body);
    res.json({ ok: true });
  }
);
Fixed
// PRIVESC49-003 — FIXED
const SearchConfigSchema = z.object({
  fieldWeights: z.object({
    skillName:    z.number().min(0).max(10),
    description:  z.number().min(0).max(10),
    tags:         z.number().min(0).max(10),
    auditScore:   z.number().min(0).max(10),
  }).optional(),
  featuredSkillIds: z.array(z.string().uuid()).max(10).optional(),
  boostingRules:    z.array(z.object({
    field:  z.string(),
    value:  z.string(),
    weight: z.number().min(0).max(5),
  })).max(20).optional(),
});

router.patch('/registry/search/config',
  requireSession,
  requireIndexingLevel('index_admin'), // FIXED: only index_admin can modify global config
  async (req, res) => {
    const updates = SearchConfigSchema.parse(req.body);
    const before = await db.searchConfig.getCurrent();
    await db.searchConfig.update(updates);

    await db.auditLog.create({
      type: 'search_config.updated',
      actorId: req.session.userId,
      before: JSON.stringify(before),
      after: JSON.stringify(updates),
    });
    res.json({ ok: true });
  }
);

PRIVESC49-004 — Cache key without searchPolicyVersionId bleeds across upgrades

The indexing level cache keys on userId alone. When the registry administrator upgrades the search policy (changing which level is required to modify featured slots, boosting rules, etc.), the existing cache entries remain valid and serve the old level for up to 60 seconds. More critically: if a previous policy granted index_admin to a user who was later downgraded to indexer under the new policy, the user's cache entry continues to grant index_admin for the cache TTL duration — and if the cache key does not include the policy version, there is no mechanism to invalidate the stale entry without restarting the process.

Vulnerable
// PRIVESC49-004 — VULNERABLE
// Cache key = userId only — does not include searchPolicyVersionId
const cached = indexingLevelCache.get(userId); // stale on policy upgrade
if (cached) return cached.level; // serves old level after policy change
Fixed
// PRIVESC49-004 — FIXED
// Cache key = searchPolicyVersionId:userId — invalidated automatically on policy upgrade

async function getCurrentSearchPolicyVersionId() {
  // Policy version is updated whenever an admin changes role definitions
  return await redis.get('search:policy:version'); // e.g., "policy-v7"
}

async function getIndexingLevel(userId) {
  const policyVersionId = await getCurrentSearchPolicyVersionId();
  const cacheKey = `${policyVersionId}:${userId}`;
  const cached = indexingLevelCache.get(cacheKey);
  if (cached && cached.expiresAt > Date.now()) return cached.level;

  const user = await db.users.findOne({ where: { id: userId }, attributes: ['indexingLevel'] });
  const level = user?.indexingLevel ?? 'none';
  indexingLevelCache.set(cacheKey, { level, expiresAt: Date.now() + 60_000 }); // 60s TTL
  return level;
}

// On policy upgrade: bump the Redis version key
// redis.set('search:policy:version', `policy-v${newVersion}`)
// All old cache entries are now orphaned — new requests compute fresh from DB

SkillAudit detection: The scanner identifies PRIVESC49 patterns using AST queries targeting JWT payload field access for level/role fields (payload.indexingLevel, payload.role), route handlers that call db.users.update with a user-supplied level value without an ordinal boundary comparison, and PATCH route handlers that use requireSession without a requireRole or requireLevel middleware. Submit your MCP skill registry at SkillAudit.

Related: SA-SKL-CORS65: CORS in API key management endpoints • All advisories