← Security advisories

Claude MCP skill insecure deserialization — skill test runner and integration test endpoints — SA-SKL-DESER26

SA-SKL-DESER26 documents four insecure deserialization vulnerabilities in MCP skill registry test runner and integration test endpoints. Test runner infrastructure processes configs that arrive through multiple serialization layers — job queues (Redis), test fixture stores (MongoDB), result caches (Redis with MessagePack), and aggregation pipelines (node-serialize). Each layer carries a distinct gadget class: YAML !!js/function achieves RCE at test completion callback evaluation; BSON Code type triggers eval() during fixture setup; MessagePack prototype pollution silently disables linting gates for all subsequent builds; node-serialize IIFE gadgets achieve RCE at suite summary aggregation time.

SA-SKL-DESER26 findings at a glance
CRITICALDESER26-001 — test runner config reads from Redis as YAML via yaml.load() DEFAULT_FULL_SCHEMA; !!js/function in testConfig.onTestComplete achieves RCE at test completion callback evaluation
CRITICALDESER26-002 — test fixture metadata reads from MongoDB as BSON; BSON Code type at setupFn field triggers eval() during fixture setup on every test run
HIGHDESER26-003 — test result cache stored in Redis as MessagePack; __proto__.skipLinting:true pollutes Object.prototype, disabling linting gate for all subsequent build cache reads in the same process
CRITICALDESER26-004 — test suite summary reads via node-serialize; IIFE gadget in serialized summary achieves RCE at suite aggregation time, running as the registry worker process

DESER26-001 — YAML yaml.load() DEFAULT_FULL_SCHEMA RCE in test config

The test runner reads test configuration objects from a Redis job queue. When the queue payload is deserialized using yaml.load(data) with the default schema (which is DEFAULT_FULL_SCHEMA in js-yaml 3.x), any YAML tag is accepted — including !!js/function, which constructs a JavaScript function from a string at deserialization time. An attacker who can write to the Redis queue — via a compromised CI token, a misconfigured Redis ACL, or a Redis injection in an adjacent service — can place a payload that executes arbitrary code when the worker calls the onTestComplete callback.

The callback fires inside the registry worker process after each test completes, with access to the full worker environment: database credentials, signing keys, API tokens, and the filesystem. Because test runner workers typically run with elevated privileges to access the Docker socket or sandbox runner, the blast radius of RCE here is equivalent to full infrastructure compromise.

DESER26-001 fix: Replace yaml.load() with yaml.load(data, { schema: yaml.FAILSAFE_SCHEMA }) (strings only) or switch to JSON.parse() for all queue data. Validate the parsed object with a strict Zod TestConfigSchema. Implement onTestComplete as a server-side enum lookup: the config carries a string key like 'notify-slack', resolved to a known function in a local registry. Never deserialize a function from a queue.

// WRONG — yaml.load() with DEFAULT_FULL_SCHEMA accepts !!js/function
const config = yaml.load(redisPayload);
await config.onTestComplete(result); // RCE if payload contains !!js/function

// RIGHT — JSON + Zod + named-function lookup
const raw = JSON.parse(redisPayload);
const config = TestConfigSchema.parse(raw); // onTestComplete is a string enum
const handler = TEST_COMPLETE_HANDLERS[config.onTestComplete]; // server-side lookup
if (!handler) throw new Error(`Unknown handler: ${config.onTestComplete}`);
await handler(result);

DESER26-002 — BSON Code type triggers eval() during fixture setup

Test fixture metadata is stored in MongoDB and retrieved with the driver's default options (promoteValues: true). MongoDB's BSON format includes a Code type for storing JavaScript expressions. When the driver encounters a Code value at the setupFn field, it deserializes it as a JavaScript object whose string value is then passed to eval() during fixture initialization. An attacker who can write a malicious fixture document — via a fixture upload endpoint, a MongoDB injection, or a compromised test infrastructure account — achieves code execution on every test run that uses that fixture.

Fixture setup runs before the test sandbox is established, meaning the eval() call executes in the main worker process context rather than any sandboxed environment. This gives the attacker access to database connection pools, in-memory secrets, and the Node.js module cache — a full process compromise at fixture initialization time.

DESER26-002 fix: Add an instanceof mongodb.Code check at document ingestion time and reject any document containing a Code type. Set promoteValues: false in the MongoDB driver options. Validate the deserialized document with a Zod schema that uses z.string() for all function-name fields. Resolve setupFn to a named function from a server-side map, never from document content.

DESER26-003 — MessagePack prototype pollution disables linting gate

The test result cache is stored in Redis serialized as MessagePack. When a cache entry is deserialized with msgpack.decode(buffer) and the result is merged into a plain object via Object.assign(target, decoded), a payload containing __proto__ as a MessagePack map key pollutes Object.prototype. The specific gadget here is __proto__.skipLinting: true, which causes every subsequent linting gate check in the process — which reads config.skipLinting from a plain object — to return true for the remainder of the process lifetime.

Linting gate bypass has a subtle but serious impact: skills that would have been blocked from publication due to linting violations pass through the CI pipeline cleanly. If the linting rules catch security anti-patterns (hardcoded credentials, dangerous eval patterns, missing input validation), disabling linting is equivalent to disabling a security control for every skill published from that worker instance until it restarts.

DESER26-003 fix: Use Object.create(null) as the merge target instead of {} — a null-prototype object cannot receive __proto__ pollution. Validate the decoded object with Zod.strict() which strips unknown keys including __proto__. Consider replacing MessagePack with JSON for cache entries, which does not support binary map keys and is handled safely by most parsers.

// WRONG — Object.assign with plain target allows __proto__ pollution
const decoded = msgpack.decode(cacheBuffer);
const result = Object.assign({}, decoded); // pollutes Object.prototype if __proto__ present

// RIGHT — null-prototype target + Zod schema stripping
const decoded = msgpack.decode(cacheBuffer);
const target = Object.create(null);
Object.assign(target, decoded);
const result = TestResultCacheSchema.strict().parse(target); // strips unknown keys

DESER26-004 — node-serialize IIFE gadget in suite summary achieves RCE

The test suite summary aggregation step reads a serialized summary object from a queue entry using node-serialize's unserialize() function. The node-serialize library supports serializing JavaScript functions by wrapping them in a closure string prefixed with _$$ND_FUNC$$_. When unserialize() encounters this prefix, it calls eval() on the function string. If the function string is an IIFE (immediately-invoked function expression), it executes at deserialization time — before any application code has a chance to inspect the value.

The suite summary aggregation step runs in the registry orchestration layer, which has broader system access than individual test workers: it reads from multiple worker queues, writes aggregated results to the main database, and may trigger downstream notifications and publishing workflows. RCE at this layer means an attacker can manipulate suite summary results to falsify security scan outcomes, suppress linting failures, or trigger false-positive "all tests passed" signals that unlock automatic skill publication.

DESER26-004 fix: Remove node-serialize entirely. Replace with JSON.parse() followed by a Zod schema validation. Add an explicit guard that rejects any input containing the string _$$ND_FUNC$$_ before attempting to parse. For configuration that must survive process restarts, write it to a local file at deploy time and read it from disk at startup, never from a Redis queue at runtime.

// WRONG — node-serialize unserialize() executes IIFE gadgets
const { unserialize } = require('node-serialize');
const summary = unserialize(queuePayload); // RCE if payload contains _$$ND_FUNC$$_

// RIGHT — JSON.parse + Zod + gadget detection guard
if (queuePayload.includes('_$$ND_FUNC$$_')) {
  throw new Error('Rejected: node-serialize gadget detected in queue payload');
}
const raw = JSON.parse(queuePayload);
const summary = SuiteSummarySchema.parse(raw);
Detect SA-SKL-DESER26 in your registry

SkillAudit scans for yaml.load() without FAILSAFE_SCHEMA, BSON Code deserialization, MessagePack prototype pollution vectors, and node-serialize usage across all queue consumers in your MCP skill registry codebase.

Scan your registry
FindingSeverityDeserialization pathGadget / Impact
DESER26-001CRITICALyaml.load() DEFAULT_FULL_SCHEMA from Redis!!js/function in onTestComplete → RCE at test completion
DESER26-002CRITICALBSON from MongoDB (promoteValues:true)BSON Code at setupFn → eval() during fixture setup
DESER26-003HIGHMessagePack from Redis cache__proto__.skipLinting:true → linting gate disabled process-wide
DESER26-004CRITICALnode-serialize from queue entryIIFE gadget in suite summary → RCE at aggregation time

See also: SA-SKL-DESER25 (CI/CD pipeline build trigger deserialization patterns) and SA-SKL-DESER24 (search index update deserialization) for the full deserialization attack surface across MCP skill registry infrastructure.