← Security advisories

Claude MCP skill insecure deserialization — skill metadata indexing and tag extraction pipeline endpoints — SA-SKL-DESER41

SA-SKL-DESER41 documents four insecure deserialization vulnerabilities in MCP skill registry metadata indexing and tag extraction pipeline endpoints. These pipelines are invoked at skill publish time and during periodic re-indexing runs, processing configuration objects and model definitions stored in Redis and MongoDB. Each finding represents a path to remote code execution or process-wide authentication bypass triggered by attacker-controlled data stored in these backing stores.

SA-SKL-DESER41 findings at a glance
CRITICALDESER41-001 — metadata indexing config reads from Redis as YAML via yaml.load() DEFAULT_FULL_SCHEMA — !!js/function in metaConfig.onTagExtract achieves RCE at every metadata extraction event; fix: FAILSAFE_SCHEMA; JSON for all metadata config; Zod MetaConfigSchema; named-event dispatch table
CRITICALDESER41-002 — tag extraction model reads from MongoDB as BSON — BSON Code type at tagExtractorFn field triggers eval() during tag extraction at skill publish time; fix: reject BSON Code; promoteValues:false; Zod string-only schema; named-extractor lookup
CRITICALDESER41-003 — metadata event queue stored in Redis as MessagePack — __proto__.skipMetaAuth:true pollutes Object.prototype, disabling authentication checks for all subsequent metadata API requests in process; fix: null-prototype target; Zod strict(); JSON instead of MessagePack
CRITICALDESER41-004 — metadata aggregation reads via node-serialize — IIFE gadget achieves RCE at metadata aggregation time reachable from any authenticated consumer of the metadata pipeline API; fix: JSON.parse + Zod; detect and reject _$$ND_FUNC$$_ payloads; sealed config at deploy time

DESER41-001 — YAML RCE in Redis-cached metadata indexing config

Severity: CRITICAL

The metadata indexing pipeline reads its configuration from a Redis key using yaml.load() with the default schema (DEFAULT_FULL_SCHEMA). This schema supports YAML tags including !!js/function, which constructs a JavaScript function from the string argument. An attacker who can write to the Redis key — via a compromised CI pipeline credential, a Redis AUTH bypass, or another deserialization vulnerability in the registry — can place a payload where metaConfig.onTagExtract is a !!js/function value. When the metadata pipeline reads and executes the config, it invokes the attacker's function, achieving arbitrary code execution in the registry process at every metadata extraction event.

yaml.load() with DEFAULT_FULL_SCHEMA is never safe on untrusted input. Any configuration or data object read from an external store (Redis, MongoDB, file system) should use FAILSAFE_SCHEMA or be stored as JSON and parsed with JSON.parse(). The js/function and js/regexp YAML tags exist for developer convenience and should never be reachable from production data paths.

Vulnerable
// Metadata pipeline reads config from Redis via yaml.load() DEFAULT_FULL_SCHEMA
const raw = await redis.get('meta:indexing-config');
const metaConfig = yaml.load(raw);  // !!js/function in onTagExtract = RCE

async function extractTags(skillId, content) {
  await metaConfig.onTagExtract(skillId, content);  // attacker function executes here
}
Fixed
// Metadata pipeline reads config from Redis as JSON + Zod schema validation
const MetaConfigSchema = z.object({
  maxTagsPerSkill: z.number().int().min(1).max(100),
  onTagExtract: z.enum(['default', 'semantic', 'keyword']),  // named event only
  batchSize: z.number().int().min(1).max(1000),
});

const EXTRACTORS = {
  default:   defaultExtractor,
  semantic:  semanticExtractor,
  keyword:   keywordExtractor,
};

const raw = await redis.get('meta:indexing-config');
const parsed = MetaConfigSchema.parse(JSON.parse(raw));

async function extractTags(skillId, content) {
  const extractor = EXTRACTORS[parsed.onTagExtract] ?? EXTRACTORS.default;
  await extractor(skillId, content);  // named function, never eval()'d
}

DESER41-002 — BSON Code eval() during MongoDB tag extraction model lookup

Severity: CRITICAL

The tag extraction model is read from MongoDB as a BSON document. The document's tagExtractorFn field is expected to hold the name of a registered extractor function. However, because the MongoDB driver reads BSON Code types by default and promoteValues is not set to false, an attacker who can write a BSON document to the tag extraction model collection can store a BSON Code value at tagExtractorFn. When the pipeline reads and invokes the model, it evaluates the Code type via eval(), achieving code execution in the Node.js process at skill publish time — a high-frequency event triggered for every skill publication request.

Vulnerable
// Tag extraction model from MongoDB — BSON Code type triggers eval()
const model = await db.collection('tag-models').findOne({ active: true });
// model.tagExtractorFn may be BSON Code — eval()'d on invocation
const result = await model.tagExtractorFn(skillContent);
Fixed
// Tag extraction model from MongoDB — promoteValues:false + Zod string schema
const TagModelSchema = z.object({
  name: z.string(),
  extractorKey: z.enum(['default', 'semantic', 'keyword', 'hybrid']),
  config: z.record(z.string(), z.unknown()),
});

const rawModel = await db.collection('tag-models')
  .findOne({ active: true }, { promoteValues: false });  // reject BSON Code

const model = TagModelSchema.parse(rawModel);
const extractor = EXTRACTORS[model.extractorKey];
if (!extractor) throw new Error('Unknown extractor key');
const result = await extractor(skillContent, model.config);

DESER41-003 — MessagePack prototype pollution disables metadata API authentication

Severity: CRITICAL

The metadata event queue is stored in Redis as MessagePack-encoded messages. When the pipeline dequeues and deserializes a message, it merges the decoded object directly into a target object using spread syntax. An attacker who can write to the Redis queue can craft a MessagePack payload where the top-level key is __proto__ and the value is {"skipMetaAuth": true}. The spread operation pollutes Object.prototype, setting skipMetaAuth to true on every subsequent object created in the process — including the request context objects used by the metadata API's authentication middleware. The authentication middleware reads req.skipMetaAuth, which now returns true for every request due to the prototype pollution, bypassing authentication checks process-wide until the Node.js process is restarted.

Vulnerable
// Metadata event queue dequeued from Redis as MessagePack
const raw = await redis.lpop('meta:event-queue');
const event = msgpack.decode(raw);
const context = { ...event };  // __proto__ spread pollutes Object.prototype

// In metadata API auth middleware:
if (req.skipMetaAuth) return next();  // true for every req after pollution
Fixed
// Metadata event queue — JSON instead of MessagePack + null-prototype target + Zod
const MetaEventSchema = z.object({
  type: z.enum(['index', 'reindex', 'delete', 'update']),
  skillId: z.string(),
  triggeredAt: z.string().datetime(),
}).strict();  // reject unknown keys including __proto__

const raw = await redis.lpop('meta:event-queue');
const decoded = JSON.parse(raw);  // no MessagePack BSON-like type tags

// Use null-prototype object to prevent prototype chain pollution
const event = Object.assign(Object.create(null), MetaEventSchema.parse(decoded));

DESER41-004 — node-serialize IIFE gadget in metadata aggregation pipeline

Severity: CRITICAL

The metadata aggregation pipeline reads aggregated configuration from a persistent store using node-serialize. The node-serialize library supports Immediately Invoked Function Expressions (IIFEs) via the _$$ND_FUNC$$_ marker prefix. Any serialized value with this prefix is deserialized by executing the enclosed function expression immediately. An attacker who can write a payload with a _$$ND_FUNC$$_-prefixed IIFE to the aggregation config store achieves arbitrary code execution at every metadata aggregation cycle. Because metadata aggregation is triggered by any authenticated consumer of the metadata pipeline API, this is effectively a low-privilege RCE: any user with a valid API key can trigger the aggregation cycle and thereby execute the attacker's payload.

Vulnerable
// Metadata aggregation config read via node-serialize
const raw = await store.get('meta:agg-config');
const aggConfig = serialize.unserialize(raw);
// _$$ND_FUNC$$_(function(){ require('child_process').exec('...') }()) executes here
Fixed
// Metadata aggregation config — JSON.parse + Zod + pre-deploy IIFE detection
const AggConfigSchema = z.object({
  aggregationInterval: z.number().int().min(60).max(86400),
  aggregationStrategy: z.enum(['full', 'incremental', 'delta']),
  maxBatchSize: z.number().int().min(1).max(10000),
});

const raw = await store.get('meta:agg-config');

// Reject any payload containing node-serialize IIFE marker
if (raw.includes('_$$ND_FUNC$$_')) {
  throw new Error('Rejected: node-serialize IIFE marker detected in aggregation config');
}

const aggConfig = AggConfigSchema.parse(JSON.parse(raw));
// Seal at deploy time to prevent runtime mutation
Object.freeze(aggConfig);

Related advisories:   SA-SKL-DESER40 (search index ranking)  |  SA-SKL-DESER39 (evaluation scoring)