← Blog

Claude MCP skill insecure deserialization — rating and review aggregation pipeline endpoints (SA-SKL-DESER65)

SA-SKL-DESER65 identifies four insecure deserialization vulnerabilities in MCP skill registry skill rating and review aggregation pipeline endpoints. The rating aggregation configuration is stored in Redis as YAML and deserialized with yaml.load() using the DEFAULT_FULL_SCHEMA, enabling a !!js/function gadget in the aggregationConfig.onRatingUpdated callback field to achieve remote code execution at every user rating submission event; the review quality model is stored in MongoDB as BSON and the qualityScorerFn field is a BSON.Code type that triggers eval() during the review moderation pass at every new review submission from any user; the rating event queue is stored in Redis as MessagePack and deserializing a crafted payload with __proto__.skipRatingAuth:true pollutes Object.prototype, disabling authentication checks for all subsequent rating API requests processed by the same worker; and the review result aggregation pipeline reads cached results using node-serialize, enabling an IIFE gadget to achieve remote code execution at aggregation time reachable from any user who views a skill's review summary page.

SA-SKL-DESER65 findings at a glance
CRITICALDESER65-001 — Rating aggregation config reads from Redis as YAML via yaml.load() DEFAULT_FULL_SCHEMA — !!js/function in aggregationConfig.onRatingUpdated achieves RCE at every user rating submission event
CRITICALDESER65-002 — Review quality model reads from MongoDB as BSON — BSON.Code type at qualityScorerFn field triggers eval() during review moderation pass at every new review submission
CRITICALDESER65-003 — Rating event queue stored in Redis as MessagePack — __proto__.skipRatingAuth:true pollutes Object.prototype, disabling authentication for all subsequent rating API requests in same worker
CRITICALDESER65-004 — Review result aggregation reads via node-serialize — IIFE gadget achieves RCE at aggregation time reachable from any user viewing a skill's review summary page

DESER65-001 — yaml.load DEFAULT_FULL_SCHEMA RCE in rating aggregation config

The rating aggregation service stores its configuration document in Redis to allow hot-reloading without process restart. The document is serialized as YAML and deserialized with yaml.load(config, { schema: yaml.DEFAULT_FULL_SCHEMA }). The DEFAULT_FULL_SCHEMA permits the !!js/function YAML type tag, which reconstructs JavaScript functions from their string representation using the Function constructor. When the aggregationConfig.onRatingUpdated callback field contains a !!js/function tag, the deserialization step executes the reconstructed function. Because the aggregation service processes this config document on every rating submission, the RCE payload executes once per user rating event.

Vulnerable
// DESER65-001 — VULNERABLE: yaml.load with DEFAULT_FULL_SCHEMA
const configYaml = await redis.get('rating:aggregation:config');
const config = yaml.load(configYaml, { schema: yaml.DEFAULT_FULL_SCHEMA });
// config.onRatingUpdated is a !!js/function — called on every rating:
await config.onRatingUpdated(rating, skill);  // RCE here
Fixed
// DESER65-001 — FIXED: FAILSAFE_SCHEMA; Zod validation; named handler lookup
const configYaml = await redis.get('rating:aggregation:config');
const rawConfig = yaml.load(configYaml, { schema: yaml.FAILSAFE_SCHEMA });
const config = RatingAggregationConfigSchema.parse(rawConfig);
// onRatingUpdated must be a string enum value, not a function:
const handler = ratingHandlers[config.onRatingUpdated];
if (!handler) throw new Error(`Unknown handler: ${config.onRatingUpdated}`);
await handler(rating, skill);

DESER65-002 — BSON Code eval() RCE in review quality model

The review quality scoring model is stored in MongoDB with a qualityScorerFn field of type BSON.Code. When the review moderation service reads this document with promoteValues:true (the default), the BSON.Code value is promoted to a JavaScript function and called via eval() during the scoring pass. An attacker who can write to the reviewQualityModels collection (via a MongoDB injection in another endpoint or via a compromised admin session) can replace the qualityScorerFn with an arbitrary code payload that executes on every review submission.

Vulnerable
// DESER65-002 — VULNERABLE: BSON.Code eval() in quality scorer
const model = await db.collection('reviewQualityModels').findOne({ active: true });
// model.qualityScorerFn is BSON.Code — eval'd by MongoDB driver:
const score = model.qualityScorerFn(review);  // RCE here
Fixed
// DESER65-002 — FIXED: promoteValues:false; projection excludes qualityScorerFn; named strategy
const model = await db.collection('reviewQualityModels').findOne(
  { active: true },
  { promoteValues: false, projection: { qualityScorerFn: 0, scoringStrategy: 1 } }
);
const scorer = reviewScoringStrategies[model.scoringStrategy];
if (!scorer) throw new Error(`Unknown scoring strategy: ${model.scoringStrategy}`);
const score = scorer(review);

DESER65-003 — MessagePack prototype pollution disables rating authentication

The rating event queue uses MessagePack serialization for high-throughput event passing. A crafted MessagePack payload with __proto__ as a map key causes Object.prototype.skipRatingAuth to be set to true after deserialization. The rating API authentication middleware checks if (req.session.skipRatingAuth) return next() to allow internal service calls, so once Object.prototype.skipRatingAuth is polluted, every subsequent request processed by the same worker bypasses the authentication check regardless of whether a valid session is present.

Vulnerable
// DESER65-003 — VULNERABLE: MessagePack without prototype key sanitization
const event = msgpack.decode(rawEventBuffer);
// Crafted payload: { "__proto__": { "skipRatingAuth": true } }
// After decode, Object.prototype.skipRatingAuth === true for entire process
await ratingEventProcessor.handle(event);
Fixed
// DESER65-003 — FIXED: sanitize decoded object; use hasOwnProperty.call in auth middleware
function sanitizeDeserialized(obj) {
  if (obj && typeof obj === 'object') {
    for (const key of Object.keys(obj)) {
      if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
        delete obj[key];
      } else {
        sanitizeDeserialized(obj[key]);
      }
    }
  }
  return obj;
}
const event = sanitizeDeserialized(msgpack.decode(rawEventBuffer));
// In auth middleware: use hasOwnProperty.call to avoid inherited property reads:
if (Object.prototype.hasOwnProperty.call(req.session, 'skipRatingAuth') && req.session.skipRatingAuth) {
  return next();
}

DESER65-004 — node-serialize IIFE RCE in review result aggregation

The review result aggregation pipeline caches aggregated review summaries using node-serialize. An attacker who can write a crafted payload to the aggregation cache (via a Redis injection or a compromised pipeline stage) embeds an IIFE gadget using the _$$ND_FUNC$$_ marker that node-serialize uses to serialize and immediately invoke functions on deserialization. The RCE executes every time any user views the review summary page for the targeted skill, because the summary page triggers the aggregation cache read.

Vulnerable
// DESER65-004 — VULNERABLE: node-serialize on review aggregation cache
const cached = await redis.get(`review:aggregation:${skillId}`);
const summary = serialize.unserialize(cached);  // IIFE gadget executes here
Fixed
// DESER65-004 — FIXED: JSON.parse + Zod validation; detect and evict ND_FUNC payloads
const cached = await redis.get(`review:aggregation:${skillId}`);
if (cached && cached.includes('_$$ND_FUNC$$_')) {
  await redis.del(`review:aggregation:${skillId}`);
  throw new Error('Malicious payload detected in review aggregation cache; entry evicted');
}
const raw = JSON.parse(cached);
const summary = ReviewAggregationSummarySchema.parse(raw);

SkillAudit scans for all SA-SKL-DESER65 patterns — yaml.load with unsafe schemas, BSON.Code eval promotion, MessagePack prototype pollution gadgets, and node-serialize IIFE vectors. Get a free audit to detect deserialization vulnerabilities in your MCP skill or server.