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.
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 tablerubricEvaluatorFn field triggers eval() during rubric evaluation at score computation time; fix: reject BSON Code; promoteValues:false; Zod string-only schema; named-evaluator lookup__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_$$ND_FUNC$$_ payloads; sealed config at deploy timeDESER39-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.
// 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);
// 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.
// 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
}
// 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.
// 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
// 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.
// 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
// 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
| Finding | Severity | Primary remediation | Secondary hardening |
|---|---|---|---|
| DESER39-001 | Critical | FAILSAFE_SCHEMA for all YAML reads from Redis; JSON for eval config; Zod EvalConfigSchema; named dispatch table | Rotate Redis credentials; audit all Redis keys for YAML config storage; set Redis ACLs to minimum required write permissions |
| DESER39-002 | Critical | promoteValues:false in MongoClient options; reject BSON Code type; Zod string-only rubric fields; named evaluator lookup | Audit existing rubric documents for BSON Code fields; re-index rubric collection after migration |
| DESER39-003 | Critical | JSON 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-004 | Critical | Remove node-serialize; JSON.parse + Zod; pre-parse _$$ND_FUNC$$_ rejection; sealed config at deploy time | Rotate 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.