← Security advisories

Claude MCP skill insecure deserialization — skill test suite execution and coverage reporting endpoints — SA-SKL-DESER34

SA-SKL-DESER34 documents four insecure deserialization vulnerabilities in MCP skill registry test suite execution and coverage reporting endpoints. These endpoints manage automated testing for skills registered in the marketplace: executing test suites against skill implementations, tracking coverage metrics, queuing test execution events across worker nodes, and aggregating test results for publisher dashboards. All four vulnerabilities arise from deserializing attacker-influenced data with unsafe deserialization primitives — yaml.load with DEFAULT_FULL_SCHEMA, BSON Code type promotion in MongoDB, MessagePack with mutable prototype targets, and node-serialize — each of which allows an attacker to embed executable code or prototype-polluting payloads in data that the registry reads back during normal test execution and reporting flows.

SA-SKL-DESER34 findings at a glance
CRITICALDESER34-001 — test runner config reads from Redis as YAML via yaml.load() DEFAULT_FULL_SCHEMA; !!js/function in runnerConfig.onTestComplete achieves RCE at test completion event
CRITICALDESER34-002 — coverage report metadata reads from MongoDB as BSON; BSON Code type at formatFn field triggers eval() during coverage formatting; fix: reject BSON Code; promoteValues:false; Zod string-only schema; named-formatter lookup
CRITICALDESER34-003 — test execution event queue stored in Redis as MessagePack; __proto__.skipTestAuth:true pollutes Object.prototype, disabling authentication checks for all subsequent test API requests in process
CRITICALDESER34-004 — test result aggregation reads via node-serialize; IIFE gadget achieves RCE at test result aggregation time reachable from any authenticated test consumer

DESER34-001 — yaml.load DEFAULT_FULL_SCHEMA on test runner config enables RCE at test completion event

The test suite execution worker reads its runner configuration from Redis, where it was stored as a YAML-serialized object by the test scheduling service. The deserialization call uses yaml.load(configString) without specifying a schema, which defaults to DEFAULT_FULL_SCHEMA and enables the !!js/function YAML type tag. An attacker who can write to the Redis key path used for runner configuration — reachable through any endpoint that accepts runner configuration input — can store a payload containing runnerConfig.onTestComplete: !!js/function 'function(result) { require("child_process").exec(PAYLOAD); }'. When any test suite completes, the runner deserializes this configuration and invokes onTestComplete with the test result, triggering arbitrary code execution in the worker process.

The worker process typically has access to the registry's deployment credentials: environment variables containing database connection strings, cloud provider tokens, and the CI service account keys used to run skills against test environments. Code executing in the worker context can exfiltrate all of these credentials in a single process.env dump. Because the worker process is designed to execute test suites against real skill implementations, it also has network access to the internal test environments — giving the attacker a persistent foothold in the internal network from which to pivot to production systems.

DESER34-001 fix: Replace yaml.load(configString) with yaml.load(configString, { schema: yaml.FAILSAFE_SCHEMA }), which supports only strings, sequences, and mappings — no executable types. Better: store all runner configuration as JSON rather than YAML and deserialize with JSON.parse followed by Zod schema validation against a strict RunnerConfigSchema that only permits string, number, and boolean fields. Replace the onTestComplete callback pattern with a named-event dispatch table: the config specifies an event name from an allowlist, and the worker maps that name to a pre-registered handler function at startup — no deserialized function objects ever execute.

WRONG
// Redis stores runner config as YAML
const configYaml = await redis.get(`runner:config:${runnerId}`);
const config = yaml.load(configYaml); // DEFAULT_FULL_SCHEMA — executes !!js/function
// Attacker payload fires here on every test completion
await config.onTestComplete(testResult);
RIGHT
const configJson = await redis.get(`runner:config:${runnerId}`);
const rawConfig = JSON.parse(configJson);
const config = RunnerConfigSchema.parse(rawConfig); // Zod strict schema
// Named dispatch — no deserialized functions ever called
const handler = testCompletionHandlers[config.onTestCompleteEvent];
if (handler) await handler(testResult, config);

DESER34-002 — BSON Code type promotion in MongoDB coverage metadata triggers eval during coverage formatting

Coverage report metadata is stored in MongoDB and read back by the formatting service that renders coverage reports for publisher dashboards. The MongoDB driver's default configuration promotes BSON Code objects to JavaScript functions using eval() when it encounters them during document deserialization. An attacker who can influence the content of coverage metadata documents — reachable through any endpoint that accepts coverage configuration input — can store a document with a formatFn field containing a BSON Code object. When the formatting service reads this document and accesses doc.formatFn, the BSON driver executes the embedded code string through eval(), giving the attacker arbitrary code execution in the formatting service process.

The formatting service process is the most dangerous execution context for a coverage reporting vulnerability because it generates reports for all publishers on the platform simultaneously. Code executing in the formatter has read access to coverage data for every skill in the registry — including skills belonging to other organizations. It also has the database credentials used to query coverage data, giving the attacker access to the full coverage history database. Coverage data includes the specific test cases that pass and fail for each skill, which reveals the security-relevant test coverage boundaries — the attack surfaces that are not covered by automated testing and therefore represent the most likely paths for undetected vulnerabilities in production skills.

DESER34-002 fix: Pass { promoteValues: false } to the MongoDB find query options to prevent automatic promotion of BSON Code, Symbol, and Timestamp types to JavaScript native values. After deserialization, validate the coverage metadata document against a Zod schema that only permits string, number, boolean, and array fields — reject any document that contains a formatFn field that is not a plain string. Replace the dynamic formatter invocation with a named-formatter lookup table: the document stores a formatter name from an allowlist (e.g., "lcov", "html", "json"), and the service maps that name to a pre-registered formatter function. No document-supplied code ever executes.

DESER34-003 — MessagePack deserialization with mutable prototype target enables test authentication bypass via prototype pollution

Test execution events are queued in Redis as MessagePack-serialized objects and consumed by the test execution API. The MessagePack deserialization call uses a plain object literal as the deserialization target, which allows a MessagePack map with a __proto__ key to merge its properties into Object.prototype. An attacker who can enqueue a test execution event — reachable through any authenticated endpoint that submits test jobs — can include {"__proto__": {"skipTestAuth": true}} in the MessagePack payload. After this event is deserialized by the worker, every subsequent object created in the Node.js process inherits skipTestAuth: true through the polluted prototype. Any authentication check in the test API that reads req.context.skipTestAuth or similar properties will find the pollution value and bypass authentication for all subsequent test requests.

Prototype pollution via MessagePack is particularly dangerous in test execution contexts because the pollution persists for the lifetime of the worker process and affects all subsequent requests processed by that worker. A single malicious test event submitted by any authenticated user can silently disable authentication for every test API request handled by the affected worker until the process restarts. Under load, the affected worker processes hundreds of test requests per minute — all of which execute without authentication verification for the duration of the attack. Any test consumer whose request happens to be routed to the affected worker gains unauthenticated access to all test execution capabilities, including executing test suites against other organizations' skills.

DESER34-003 fix: Replace MessagePack deserialization with JSON for all test execution event data. If MessagePack is required for performance reasons, deserialize into a null-prototype object (Object.create(null)) to prevent __proto__ merging. After deserialization, validate the event against a strict Zod schema with strict() mode enabled — reject any event that contains __proto__, constructor, or prototype keys. Never read authentication bypass flags from deserialized event data; derive authentication state exclusively from the session token in the request headers.

DESER34-004 — node-serialize IIFE gadget in test result aggregation achieves RCE reachable from any authenticated test consumer

Test result aggregation reads intermediate aggregation results from a shared store using node-serialize's unserialize() function. The node-serialize library supports immediately-invoked function expressions (IIFEs) through its _$$ND_FUNC$$_ marker, executing any function literal that appears in a serialized object's field values at deserialization time. An attacker who can write to the aggregation result store — reachable through any authenticated endpoint that contributes test results to an ongoing aggregation batch — can store a serialized object with a field containing the IIFE marker followed by a function literal. When the aggregation service reads and deserializes this entry, the IIFE executes in the aggregation service process.

The aggregation service has access to the full test result history database and the credentials required to query it. It also runs in a process with elevated permissions compared to individual test workers because it needs to read results from all workers and write the final aggregated report to the publisher-facing database. Code executing in the aggregation service context can read the complete test history for all skills across all organizations, write arbitrary results to the publisher database — poisoning coverage reports with false pass/fail data — and access the aggregation service's deployment credentials for further lateral movement.

DESER34-004 fix: Replace all node-serialize usage with JSON.parse followed by Zod schema validation. Add an explicit pre-deserialization check that rejects any string containing the _$$ND_FUNC$$_ marker before passing it to any deserialization function. Seal the aggregation configuration at deploy time by embedding it as a module constant rather than reading it from a shared store — eliminate the runtime deserialization of aggregation config entirely. For intermediate aggregation results that must be stored externally, use a schema-validated JSON format with a content-addressable key that includes a HMAC of the allowed fields, preventing attacker-controlled values from reaching the aggregation pipeline.

WRONG
const { unserialize } = require('node-serialize');
// Attacker stored: {"result": "_$$ND_FUNC$$_function(){require('child_process').exec(CMD)}()"}
const aggregated = unserialize(await redis.get(`aggregation:${batchId}`));
await db.saveReport(aggregated);
RIGHT
const raw = await redis.get(`aggregation:${batchId}`);
// Reject node-serialize gadget payloads before any deserialization
if (raw.includes('_$$ND_FUNC$$_')) {
  throw new Error('Rejected: node-serialize gadget detected in aggregation store');
}
const parsed = JSON.parse(raw);
const aggregated = AggregationResultSchema.parse(parsed); // Zod strict schema
await db.saveReport(aggregated);

SkillAudit scans your registry's test suite execution and coverage reporting services for all four DESER34 patterns — YAML RCE, BSON Code eval, MessagePack prototype pollution, and node-serialize gadgets — plus the full SA-SKL-DESER series. Get started free — 3 audits/month on public repos, results in 60 seconds.