← Security advisories

Claude MCP skill insecure deserialization — skill evaluation and scoring pipeline endpoints — SA-SKL-DESER39

SA-SKL-DESER39 documents four insecure deserialization vulnerabilities in MCP skill registry skill evaluation and scoring pipeline endpoints. The evaluation pipeline is a high-privilege execution context — it runs automated quality scoring, security checks, and rubric-based assessments against skill submissions, and its workers hold scoring API credentials and evaluation database write access. Exploitation of any DESER39 finding achieves code execution in this privileged context. DESER39-001 exploits YAML deserialization of evaluation pipeline config stored in Redis to execute arbitrary JavaScript at every scoring event. DESER39-002 exploits BSON Code deserialization of scoring rubric evaluator functions to execute arbitrary code during rubric evaluation. DESER39-003 uses MessagePack prototype pollution to disable authentication checks for all subsequent evaluation API requests in the process. DESER39-004 uses a node-serialize IIFE gadget in evaluation aggregation to achieve RCE reachable from any authenticated consumer of the evaluation API.

SA-SKL-DESER39 findings at a glance
CRITICALDESER39-001 — evaluation pipeline config reads from Redis as YAML via yaml.load() DEFAULT_FULL_SCHEMA; !!js/function in evalConfig.onScoreCompute achieves RCE at every evaluation scoring event; fix: FAILSAFE_SCHEMA; JSON for all eval config; Zod EvalConfigSchema; named-event dispatch table
CRITICALDESER39-002 — scoring rubric reads from MongoDB as BSON; BSON Code type at rubricEvaluatorFn field triggers eval() during rubric evaluation at score computation time; fix: reject BSON Code; promoteValues:false; Zod string-only schema; named-evaluator lookup
CRITICALDESER39-003 — evaluation result queue stored in Redis as MessagePack; __proto__.skipEvalAuth:true pollutes Object.prototype, disabling authentication checks for all subsequent evaluation API requests in process; fix: null-prototype target; Zod strict(); JSON instead of MessagePack
CRITICALDESER39-004 — evaluation aggregation reads via node-serialize; IIFE gadget achieves RCE at evaluation aggregation time reachable from any authenticated consumer of the evaluation pipeline API; fix: JSON.parse + Zod; detect and reject _$$ND_FUNC$$_ payloads; sealed config at deploy time

DESER39-001 — YAML RCE via evaluation pipeline config in Redis

Severity: CRITICAL

The evaluation pipeline worker reads its configuration from Redis using yaml.load(configBuffer, { schema: yaml.DEFAULT_FULL_SCHEMA }). The DEFAULT_FULL_SCHEMA includes the !!js/function YAML type, which deserializes function-valued fields by calling new Function() on the serialized source string. An attacker who can write to the Redis key that holds the evaluation pipeline config — via a Redis AUTH bypass, a misconfigured Redis ACL, or a prior RCE on a service that writes config to Redis — can inject a !!js/function value at the evalConfig.onScoreCompute field. This function is called at every evaluation scoring event, achieving persistent RCE in the evaluation worker process at a cadence proportional to evaluation submission volume.

Vulnerable
// evaluation-worker.js — yaml.load with DEFAULT_FULL_SCHEMA
const configBuffer = await redis.get('eval:pipeline:config');
const evalConfig = yaml.load(configBuffer, { schema: yaml.DEFAULT_FULL_SCHEMA });
// evalConfig.onScoreCompute is now callable — !!js/function payload executes here
await evalConfig.onScoreCompute(skillId, scoreData);
Fixed
// evaluation-worker.js — FAILSAFE_SCHEMA + JSON for config + Zod
const EvalConfigSchema = z.object({
  scoringWeights: z.record(z.string(), z.number().min(0).max(1)),
  onScoreCompute: z.enum(['default', 'weighted', 'rubric']), // named dispatch only
  maxConcurrentEvals: z.number().int().min(1).max(100),
});

const raw = await redis.get('eval:pipeline:config');
// FAILSAFE_SCHEMA: only strings, nulls, booleans — no !!js/function
const parsed = yaml.load(raw, { schema: yaml.FAILSAFE_SCHEMA });
const evalConfig = EvalConfigSchema.parse(JSON.parse(JSON.stringify(parsed)));
const handler = scoreComputeHandlers[evalConfig.onScoreCompute]; // named dispatch table
await handler(skillId, scoreData);

DESER39-002 — BSON Code RCE via scoring rubric evaluator function

Severity: CRITICAL

The scoring rubric document is stored in MongoDB and read via the default MongoClient driver settings that promote BSON types to native JavaScript equivalents. The BSON Code type — which the MongoDB driver promotes to a JavaScript Code object — appears at the rubricEvaluatorFn field of rubric documents. The evaluation pipeline calls eval(rubric.rubricEvaluatorFn.code) to invoke the evaluator function, treating the BSON Code object's code property as the function body to evaluate. An attacker who can write a rubric document to MongoDB — via a MongoDB injection in the rubric creation endpoint, a misconfigured MongoDB user with write access, or a prior compromise of the rubric management service — can inject arbitrary JavaScript in the rubricEvaluatorFn field that executes at score computation time for every skill evaluated with that rubric.

Vulnerable
// scoring-engine.js — BSON Code promotion + eval()
const rubric = await Rubric.findById(rubricId); // default promoteValues:true
// rubric.rubricEvaluatorFn may be a BSON Code object if stored with Code type
if (rubric.rubricEvaluatorFn instanceof Code) {
  eval(rubric.rubricEvaluatorFn.code); // RCE
}
Fixed
// scoring-engine.js — promoteValues:false + named evaluator lookup
const rubric = await Rubric.findById(rubricId, {}, { promoteValues: false });

// Reject any BSON Code type outright
if (rubric.rubricEvaluatorFn?.constructor?.name === 'Code') {
  throw new Error('BSON Code type rejected in rubric evaluator field');
}

// rubricEvaluatorFn must be a string key into the allowed evaluator map
const evaluatorKey = z.enum(['standard', 'security', 'compatibility', 'docs']).parse(
  rubric.rubricEvaluatorFn
);
const evaluator = rubricEvaluators[evaluatorKey]; // safe named dispatch
await evaluator(skillId, scoreData);

DESER39-003 — Prototype pollution via MessagePack in evaluation result queue

Severity: CRITICAL

The evaluation result queue is stored in Redis using MessagePack serialization and deserialized using msgpack.decode(buffer) with no prototype hardening. MessagePack does not natively distinguish between object keys and prototype properties — a crafted MessagePack payload with a __proto__ map key merges properties into Object.prototype. A payload containing {"__proto__": {"skipEvalAuth": true}} pollutes Object.prototype.skipEvalAuth to true for the entire process, and any authentication check in the evaluation API that reads req.context.skipEvalAuth without an own-property check will be permanently bypassed for all subsequent requests in the same process — not just the one that triggered the deserialization.

Vulnerable
// eval-queue-consumer.js — msgpack.decode with no prototype hardening
const queueEntry = msgpack.decode(buffer);
// if buffer contains {"__proto__":{"skipEvalAuth":true}}, all subsequent
// requests in this process bypass auth checks that read obj.skipEvalAuth
Fixed
// eval-queue-consumer.js — JSON + null-prototype target + Zod strict
const EvalResultSchema = z.object({
  evalId: z.string().uuid(),
  skillId: z.string().uuid(),
  scores: z.record(z.string(), z.number().min(0).max(100)),
  completedAt: z.string().datetime(),
}).strict(); // .strict() rejects unknown keys including __proto__

// Use JSON: no prototype pollution vectors from __proto__ key
const raw = JSON.parse(buffer.toString('utf8'));
// Assign to null-prototype object to prevent any prototype chain writes
const safe = Object.assign(Object.create(null), raw);
const result = EvalResultSchema.parse(safe);

DESER39-004 — node-serialize IIFE RCE in evaluation aggregation

Severity: CRITICAL

The evaluation aggregation worker reads summarized evaluation state using the node-serialize library's unserialize() function. The node-serialize format supports Immediately Invoked Function Expressions (IIFEs) via the _$$ND_FUNC$$_ marker prefix, which are executed synchronously on deserialization. An attacker who can write a crafted aggregation record to the data store — via any of the evaluation write endpoints, a prior compromise of an evaluation service, or a Redis/MongoDB write-access vulnerability — can inject a _$$ND_FUNC$$_function(){RCE payload}() string that executes at aggregation time. The aggregation worker typically holds scoring API credentials, cloud storage keys for the evaluation report archive, and database write access to the evaluation scoring tables.

Vulnerable
// aggregation-worker.js — node-serialize.unserialize() with IIFE gadget
const serialize = require('node-serialize');
const rawAgg = await db.get('eval:aggregation:latest');
const agg = serialize.unserialize(rawAgg); // IIFE in _$$ND_FUNC$$_ executes here
Fixed
// aggregation-worker.js — JSON.parse + _$$ND_FUNC$$_ rejection + Zod
const AggregationSchema = z.object({
  totalEvals: z.number().int().min(0),
  avgScore: z.number().min(0).max(100),
  passRate: z.number().min(0).max(1),
  updatedAt: z.string().datetime(),
}).strict();

const rawAgg = await db.get('eval:aggregation:latest');

// Reject node-serialize IIFE gadgets before parsing
if (rawAgg.includes('_$$ND_FUNC$$_')) {
  throw new Error('Rejected: node-serialize IIFE gadget detected in aggregation payload');
}

const agg = AggregationSchema.parse(JSON.parse(rawAgg));

Evaluation pipeline workers are high-privilege targets. Workers that compute security scores and run automated rubric evaluations for skill submissions typically hold write access to the evaluation scoring database, cloud storage credentials for the report archive, and third-party API keys for external scanning tools. Any RCE in an evaluation worker is a full platform compromise, not a single-tenant incident. Treat all deserialization in evaluation pipeline code as critical-severity regardless of the apparent attack surface.

Remediation summary

FindingSeverityPrimary remediationSecondary hardening
DESER39-001CriticalFAILSAFE_SCHEMA for all YAML reads from Redis; JSON for eval config; Zod EvalConfigSchema; named dispatch tableRotate Redis credentials; audit all Redis keys for YAML config storage; set Redis ACLs to minimum required write permissions
DESER39-002CriticalpromoteValues:false in MongoClient options; reject BSON Code type; Zod string-only rubric fields; named evaluator lookupAudit existing rubric documents for BSON Code fields; re-index rubric collection after migration
DESER39-003CriticalJSON for queue serialization; null-prototype deserialization target; Zod strict() schema rejecting __proto__Add process-level Object.prototype pollution monitoring; alert on own-property count anomalies
DESER39-004CriticalRemove node-serialize; JSON.parse + Zod; pre-parse _$$ND_FUNC$$_ rejection; sealed config at deploy timeRotate all credentials held by aggregation worker; audit all data stores for existing IIFE payloads

SkillAudit scans evaluation and scoring pipeline code for all four SA-SKL-DESER39 patterns. See also SA-SKL-DESER38 and SA-SKL-DESER37. Connect your repository at skillaudit.dev.