← Blog

Claude MCP skill insecure deserialization — skill performance benchmarking and load testing pipeline endpoints (SA-SKL-DESER69)

SA-SKL-DESER69 identifies four critical insecure deserialization vulnerabilities across the MCP skill registry's performance benchmarking and load testing pipeline. The benchmarking subsystem reads configuration from Redis using YAML's unsafe DEFAULT_FULL_SCHEMA, enabling remote code execution via !!js/function gadgets at every benchmark completion event; the load testing pipeline reads scenario models from MongoDB as BSON, where the BSON Code type at a callback field triggers eval() during every scenario step execution; the benchmark event queue uses MessagePack deserialization that allows prototype pollution to disable authentication for the entire benchmarking API within the affected worker; and the load test result aggregation path uses node-serialize, where IIFE gadgets achieve RCE at aggregation time reachable by any user who views a skill's performance badge.

SA-SKL-DESER69 findings at a glance
CRITICALDESER69-001 — benchmark config reads from Redis as YAML via yaml.load() DEFAULT_FULL_SCHEMA — !!js/function in benchmarkConfig.onBenchmarkComplete achieves RCE at every benchmark completion event triggered by any publisher running performance tests
CRITICALDESER69-002 — load test scenario model reads from MongoDB as BSON — BSON Code type at scenarioExecutorFn field triggers eval() during load test execution at every test scenario step
CRITICALDESER69-003 — benchmark event queue stored in Redis as MessagePack — __proto__.skipBenchmarkAuth:true pollutes Object.prototype, disabling authentication for all subsequent benchmarking API requests in same worker
CRITICALDESER69-004 — load test result aggregation reads via node-serialize — IIFE gadget achieves RCE at aggregation time reachable from any user viewing skill performance badge

DESER69-001 — YAML DEFAULT_FULL_SCHEMA in benchmark config enables RCE at every benchmark completion event

The benchmarking service reads per-skill benchmark configuration from a Redis key using js-yaml's yaml.load() without an explicit schema argument, which defaults to DEFAULT_FULL_SCHEMA and enables the !!js/function YAML type. The benchmark configuration document contains an onBenchmarkComplete callback field that the benchmarking worker invokes after each run to post-process results. Any publisher who can write to the Redis configuration key — through the benchmark configuration update endpoint, through a Redis misconfiguration, or through any other write path — can store a !!js/function value at onBenchmarkComplete. When the next benchmark completes for that skill, the worker deserializes the YAML and invokes the attacker-controlled function, achieving RCE inside the benchmarking worker process with its full set of environment variables, IAM credentials, and network access to internal infrastructure. Because benchmark completion events are triggered by any publisher running performance tests against their skill, this RCE is reachable without any further privilege beyond publisher status.

Vulnerable
// DESER69-001 — VULNERABLE: yaml.load with DEFAULT_FULL_SCHEMA
const yaml = require('js-yaml');
const redis = require('../redis');

async function loadBenchmarkConfig(skillId) {
  const raw = await redis.get(`benchmark-config:${skillId}`);
  if (!raw) return null;
  // DEFAULT_FULL_SCHEMA enables !!js/function — attacker injects RCE callback
  const config = yaml.load(raw);
  return config;
}

async function runBenchmark(skillId, benchmarkParams) {
  const config = await loadBenchmarkConfig(skillId);
  const results = await executeBenchmark(skillId, benchmarkParams, config);
  if (config && config.onBenchmarkComplete) {
    // RCE: attacker-controlled !!js/function executes here
    await config.onBenchmarkComplete(results);
  }
  return results;
}

module.exports = { loadBenchmarkConfig, runBenchmark };

YAML's !!js/function type deserializes arbitrary JavaScript functions that execute synchronously during the callback invocation — there is no sandboxing. The fix is to always pass yaml.FAILSAFE_SCHEMA (strings, lists, and maps only), validate the result against a strict BenchmarkConfigSchema with Zod, and replace the arbitrary callback field with a named handler lookup from an allowlist — so only pre-registered, code-reviewed handler names are callable.

Fixed
// DESER69-001 — FIXED: FAILSAFE_SCHEMA; Zod BenchmarkConfigSchema; named handler lookup
const yaml = require('js-yaml');
const { z } = require('zod');
const redis = require('../redis');
const { benchmarkHandlers } = require('./benchmark-handlers');

const BenchmarkConfigSchema = z.object({
  timeoutMs: z.number().int().min(1000).max(300000).optional(),
  concurrency: z.number().int().min(1).max(100).optional(),
  onBenchmarkComplete: z.enum(Object.keys(benchmarkHandlers)).optional()
});

async function loadBenchmarkConfig(skillId) {
  const raw = await redis.get(`benchmark-config:${skillId}`);
  if (!raw) return null;
  // FAILSAFE_SCHEMA: only strings, sequences, and mappings — no !!js/function
  const parsed = yaml.load(raw, { schema: yaml.FAILSAFE_SCHEMA });
  return BenchmarkConfigSchema.parse(parsed);
}

async function runBenchmark(skillId, benchmarkParams) {
  const config = await loadBenchmarkConfig(skillId);
  const results = await executeBenchmark(skillId, benchmarkParams, config);
  if (config && config.onBenchmarkComplete) {
    // Named handler lookup — only pre-registered handlers callable
    const handler = benchmarkHandlers[config.onBenchmarkComplete];
    if (handler) await handler(results);
  }
  return results;
}

module.exports = { loadBenchmarkConfig, runBenchmark };

CVSS score: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H — Base Score 9.9 (CRITICAL); scope changed because benchmarking worker has access to internal infrastructure beyond the registry application.

DESER69-002 — BSON Code type in load test scenario triggers eval() at every test scenario step

The load testing pipeline reads scenario model documents from MongoDB using the Node.js MongoDB driver with default options, which promotes BSON Code objects to JavaScript functions via eval(). The scenario model document contains a scenarioExecutorFn field that the load testing worker calls to advance the test state at each scenario step. Any publisher who can write a scenario document with a BSON Code value at scenarioExecutorFn — through the scenario creation API or through direct MongoDB access — will have their code evaluated inside the load testing worker at every step of every test run. Because load testing scenarios are executed repeatedly at high concurrency, the attacker's payload executes thousands of times per test run, providing an extremely reliable and persistent RCE foothold that survives worker restarts as long as the malicious scenario document remains in MongoDB.

Vulnerable
// DESER69-002 — VULNERABLE: BSON Code type promotes to eval()
const { MongoClient } = require('mongodb');
const client = new MongoClient(process.env.MONGO_URI);

async function loadTestScenario(scenarioId) {
  const db = client.db('skillregistry');
  // Default options: promoteValues:true promotes BSON Code to JS function via eval()
  const scenario = await db.collection('loadtest_scenarios')
    .findOne({ _id: scenarioId });
  return scenario;
}

async function executeLoadTestStep(scenario, stepCtx) {
  // RCE: BSON Code at scenarioExecutorFn evaluates attacker payload
  const result = await scenario.scenarioExecutorFn(stepCtx);
  return result;
}

module.exports = { loadTestScenario, executeLoadTestStep };

BSON Code promotion via eval() executes inside the load testing worker without any sandboxing, with full access to the worker's environment variables, file system, and network. Setting promoteValues: false prevents BSON Code from being promoted to a live function. Projecting out the scenarioExecutorFn field entirely at the query level ensures the field never reaches application code. Replacing the arbitrary callback with a named strategy lookup from an allowlist enforces the intended execution model.

Fixed
// DESER69-002 — FIXED: promoteValues:false; projection excludes field; named strategy
const { MongoClient } = require('mongodb');
const { z } = require('zod');
const { scenarioStrategies } = require('./scenario-strategies');
const client = new MongoClient(process.env.MONGO_URI);

const LoadTestScenarioSchema = z.object({
  _id: z.string(),
  skillId: z.string(),
  name: z.string().max(256),
  stepCount: z.number().int().min(1).max(10000),
  strategyName: z.enum(Object.keys(scenarioStrategies))
});

async function loadTestScenario(scenarioId) {
  const db = client.db('skillregistry');
  const scenario = await db.collection('loadtest_scenarios').findOne(
    { _id: scenarioId },
    {
      // promoteValues:false prevents BSON Code -> eval() promotion
      promoteValues: false,
      // Projection excludes scenarioExecutorFn — never reaches application
      projection: { scenarioExecutorFn: 0 }
    }
  );
  return LoadTestScenarioSchema.parse(scenario);
}

async function executeLoadTestStep(scenario, stepCtx) {
  // Named strategy lookup — only pre-registered strategies callable
  const strategy = scenarioStrategies[scenario.strategyName];
  if (!strategy) throw new Error(`Unknown strategy: ${scenario.strategyName}`);
  return strategy(stepCtx);
}

module.exports = { loadTestScenario, executeLoadTestStep };

CVSS score: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H — Base Score 9.9 (CRITICAL); persistent RCE at high concurrency; scope changed due to internal infrastructure access from load testing worker.

DESER69-003 — MessagePack prototype pollution in benchmark event queue disables benchmarking API authentication

The benchmark event queue stores event payloads in Redis serialized as MessagePack using the msgpack5 library without prototype pollution protection. When the benchmarking worker dequeues and deserializes an event, the MessagePack decoder reconstructs the object graph from the binary payload, including any keys present in the payload. An attacker who can write to the Redis event queue — through the benchmark event submission endpoint or through any other write path — can craft a MessagePack payload containing __proto__ as a key with skipBenchmarkAuth: true as a nested value. After deserialization, Object.prototype.skipBenchmarkAuth is true for every plain object in the worker process. If the benchmarking API's authentication middleware checks req.skipBenchmarkAuth without using hasOwnProperty, the polluted prototype makes this check pass for every subsequent request handled by the same worker, disabling authentication for all benchmarking API endpoints until the worker is restarted.

Vulnerable
// DESER69-003 — VULNERABLE: MessagePack prototype pollution
const msgpack = require('msgpack5')();
const redis = require('../redis');

async function dequeueBenchmarkEvent() {
  const raw = await redis.lpop('benchmark-event-queue');
  if (!raw) return null;
  // No prototype pollution protection — __proto__ key pollutes Object.prototype
  const event = msgpack.decode(Buffer.from(raw, 'base64'));
  return event;
}

// Auth middleware checks property without hasOwnProperty guard
function requireBenchmarkAuth(req, res, next) {
  if (req.skipBenchmarkAuth) return next(); // bypassed after pollution
  if (!req.session || !req.session.userId) {
    return res.status(401).json({ error: 'Unauthorized' });
  }
  next();
}

module.exports = { dequeueBenchmarkEvent, requireBenchmarkAuth };

Prototype pollution that sets Object.prototype.skipBenchmarkAuth = true silently disables authentication for every request handled by the affected worker for the remainder of its lifetime. The fix requires sanitizing deserialized objects to remove __proto__ and constructor keys before use, and guarding all property checks in security-sensitive middleware with Object.prototype.hasOwnProperty.call() so that prototype-inherited values never satisfy security checks.

Fixed
// DESER69-003 — FIXED: sanitizeDeserialized(); hasOwnProperty.call in auth
const msgpack = require('msgpack5')();
const { z } = require('zod');
const redis = require('../redis');

const BenchmarkEventSchema = z.object({
  eventType: z.enum(['run.start', 'run.complete', 'run.error']),
  skillId: z.string().uuid(),
  publisherId: z.string().uuid(),
  runId: z.string().uuid(),
  timestamp: z.number().int()
});

function sanitizeDeserialized(obj) {
  if (typeof obj !== 'object' || obj === null) return obj;
  const safe = Object.create(null);
  for (const key of Object.keys(obj)) {
    if (key === '__proto__' || key === 'constructor' || key === 'prototype') continue;
    safe[key] = sanitizeDeserialized(obj[key]);
  }
  return safe;
}

async function dequeueBenchmarkEvent() {
  const raw = await redis.lpop('benchmark-event-queue');
  if (!raw) return null;
  const decoded = msgpack.decode(Buffer.from(raw, 'base64'));
  const sanitized = sanitizeDeserialized(decoded);
  return BenchmarkEventSchema.parse(sanitized);
}

// Auth middleware uses hasOwnProperty.call — prototype pollution cannot bypass
function requireBenchmarkAuth(req, res, next) {
  const skip = Object.prototype.hasOwnProperty.call(req, 'skipBenchmarkAuth')
    && req.skipBenchmarkAuth === true;
  if (skip) return next();
  if (!req.session || !req.session.userId) {
    return res.status(401).json({ error: 'Unauthorized' });
  }
  next();
}

module.exports = { dequeueBenchmarkEvent, requireBenchmarkAuth };

CVSS score: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H — Base Score 9.9 (CRITICAL); authentication bypass affects all benchmarking endpoints in the polluted worker; scope changed.

DESER69-004 — node-serialize IIFE gadget in load test aggregation achieves RCE reachable from performance badge view

The load test result aggregation service reads aggregated result objects from a Redis cache using node-serialize's unserialize() function, which evaluates Immediately Invoked Function Expressions (IIFEs) embedded in the serialized string using the pattern _$$ND_FUNC$$_function(){...}(). When a user views a skill's performance badge on the registry, the badge rendering path calls the aggregation service to retrieve the latest benchmark summary. Any attacker who can write to the Redis aggregation cache — through the result submission endpoint or through any Redis write path — can store a payload containing an IIFE gadget. The next time any user views the performance badge, the aggregation service deserializes the malicious payload and the IIFE executes inside the aggregation worker, achieving RCE that is passively triggered by normal user activity without requiring any further attacker interaction.

Vulnerable
// DESER69-004 — VULNERABLE: node-serialize unserialize() with IIFE gadget
const serialize = require('node-serialize');
const redis = require('../redis');

async function getLoadTestAggregation(skillId) {
  const raw = await redis.get(`loadtest-aggregation:${skillId}`);
  if (!raw) return null;
  // node-serialize evaluates _$$ND_FUNC$$_function(){...}() IIFEs — RCE
  const aggregation = serialize.unserialize(raw);
  return aggregation;
}

async function renderPerformanceBadge(skillId) {
  const aggregation = await getLoadTestAggregation(skillId);
  return formatBadge(aggregation);
}

module.exports = { getLoadTestAggregation, renderPerformanceBadge };

node-serialize's IIFE gadget pattern executes arbitrary code at deserialization time with no option to disable it — the library must not be used to deserialize untrusted data under any circumstances. The fix is to replace node-serialize with JSON.parse and validate the result against a strict Zod LoadTestAggregationSchema; any existing cache entries containing the _$$ND_FUNC$$_ marker must be evicted from Redis before the fix is deployed because they will continue to trigger RCE on the vulnerable code path until evicted.

Fixed
// DESER69-004 — FIXED: JSON.parse + Zod LoadTestAggregationSchema; evict IIFE payloads
const { z } = require('zod');
const redis = require('../redis');

const LoadTestAggregationSchema = z.object({
  skillId: z.string().uuid(),
  p50LatencyMs: z.number().nonnegative(),
  p95LatencyMs: z.number().nonnegative(),
  p99LatencyMs: z.number().nonnegative(),
  throughputRps: z.number().nonnegative(),
  errorRate: z.number().min(0).max(1),
  sampleCount: z.number().int().nonnegative(),
  computedAt: z.string().datetime()
});

const IIFE_MARKER = '_$$ND_FUNC$$_';

async function getLoadTestAggregation(skillId) {
  const raw = await redis.get(`loadtest-aggregation:${skillId}`);
  if (!raw) return null;
  // Evict any legacy node-serialize payloads containing IIFE gadgets
  if (raw.includes(IIFE_MARKER)) {
    await redis.del(`loadtest-aggregation:${skillId}`);
    return null;
  }
  const parsed = JSON.parse(raw);
  return LoadTestAggregationSchema.parse(parsed);
}

async function renderPerformanceBadge(skillId) {
  const aggregation = await getLoadTestAggregation(skillId);
  if (!aggregation) return renderDefaultBadge(skillId);
  return formatBadge(aggregation);
}

module.exports = { getLoadTestAggregation, renderPerformanceBadge };

CVSS score: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H — Base Score 10.0 (CRITICAL); no authentication required; triggered passively by any user viewing a performance badge; full RCE with scope change.

Scan your MCP skill for DESER69 and 200+ other vulnerability classes

SkillAudit checks for all SA-SKL-DESER vulnerability patterns including unsafe YAML schema deserialization, BSON Code type promotion, MessagePack prototype pollution, and node-serialize IIFE gadgets. Get a graded report with line-level code fixes in 60 seconds.

Get a free audit