Claude MCP skill insecure deserialization — skill plugin and extension management endpoints — SA-SKL-DESER31
SA-SKL-DESER31 documents four insecure deserialization vulnerabilities in MCP skill registry plugin and extension management endpoints. Plugin configuration stored in Redis is deserialized via yaml.load() with the unsafe DEFAULT_FULL_SCHEMA, enabling RCE via !!js/function gadgets at plugin installation time. Extension metadata fetched from MongoDB trusts BSON Code type at the initFn field, triggering eval() during extension initialization. Plugin event queue entries stored as MessagePack enable prototype pollution that disables the plugin sandbox for all subsequent events in the process. And plugin manifest aggregation using node-serialize provides an IIFE RCE gadget reachable from any authenticated plugin consumer.
yaml.load(DEFAULT_FULL_SCHEMA); !!js/function in pluginConfig.onInstall achieves RCE at plugin installation time, firing on every install eventinitFn field triggers eval() during extension initialization__proto__.skipPluginSandbox:true pollutes Object.prototype, disabling sandbox enforcement for all subsequent plugin events in processnode-serialize; IIFE gadget achieves RCE at manifest aggregation time reachable from any authenticated plugin consumerDESER31-001 — yaml.load() DEFAULT_FULL_SCHEMA on plugin config enables RCE at installation
Plugin configuration is stored in Redis as YAML and deserialized when the plugin is installed or when the installation event handler fires. The code uses yaml.load(configStr) without specifying a schema, which defaults to DEFAULT_FULL_SCHEMA in js-yaml versions before 4.0 — the schema that permits arbitrary JavaScript object construction via YAML type tags. An attacker who can write to the Redis plugin configuration key — through a compromised plugin publisher account, a Redis injection in another endpoint, or a misconfigured Redis ACL — can place a YAML document containing a !!js/function tag at the pluginConfig.onInstall key. When any user installs the affected plugin, the registry's plugin manager deserializes the configuration, evaluates the JavaScript function, and executes it in the registry process. This fires on every install event, turning a single compromised configuration document into a persistent backdoor that executes in the registry process for every subsequent installation.
DESER31-001 fix: Replace yaml.load(configStr) with yaml.load(configStr, { schema: yaml.FAILSAFE_SCHEMA }), which supports only strings, sequences, and mappings — no arbitrary type construction. Better: use JSON for all plugin configuration, eliminating YAML deserialization entirely. Apply a Zod PluginConfigSchema after deserialization to reject any config that does not conform to the expected shape. Use a named-event dispatch table that maps event names to server-side handler functions — never store callable code in plugin config.
const configStr = await redis.get(`plugin:config:${pluginId}`);
const pluginConfig = yaml.load(configStr); // DEFAULT_FULL_SCHEMA — !!js/function allowed
// !!js/function in pluginConfig.onInstall → RCE
if (pluginConfig.onInstall) pluginConfig.onInstall(context);
const configStr = await redis.get(`plugin:config:${pluginId}`);
// FAILSAFE_SCHEMA: strings, sequences, mappings only — no type construction
const rawConfig = yaml.load(configStr, { schema: yaml.FAILSAFE_SCHEMA });
// Zod schema: reject anything outside the expected plugin config shape
const pluginConfig = PluginConfigSchema.parse(rawConfig);
// Named-event dispatch: event names map to server-side handlers only
const handler = PLUGIN_EVENT_HANDLERS[pluginConfig.onInstallEventName];
if (handler) await handler(context);
DESER31-002 — MongoDB BSON Code type at extension initFn triggers eval() during initialization
Extension metadata is stored in MongoDB and read using the standard MongoDB Node.js driver. When promoteValues is not set to false, the driver deserializes BSON Code type fields by invoking eval() on the code string during the deserialization pass. An attacker who can write to the extension metadata collection — through a compromised registry admin account or a MongoDB injection — can store a BSON Code value at the initFn field of an extension document. When the registry reads the extension metadata to initialize the extension, the BSON driver evaluates the code string, achieving code execution in the registry process at initialization time. Because extension initialization happens on startup and on every extension hot-reload, a poisoned extension document produces persistent RCE that survives process restarts.
DESER31-002 fix: Pass { promoteValues: false } to all MongoDB collection reads that handle untrusted data. Add an explicit check that rejects any field value that is an instance of BSON.Code before using it. Apply a Zod string-only schema to the initFn field. Replace callable initFn with a named-initializer lookup table that maps string keys to server-side initializer implementations.
DESER31-003 — MessagePack prototype pollution disables plugin sandbox for all subsequent events
Plugin event queue entries are stored in Redis as MessagePack. When an entry is decoded without a null-prototype target object, a carefully crafted MessagePack document containing {"__proto__": {"skipPluginSandbox": true}} sets Object.prototype.skipPluginSandbox to true on the global prototype chain. Any code path in the registry that checks if (config.skipPluginSandbox) — where config is an ordinary object without an explicit skipPluginSandbox own property — will now read the prototype-inherited value and skip the sandbox check. This disables sandbox enforcement for every plugin event processed in the same Node.js process for the remainder of its lifetime, until the process is restarted and the prototype chain is clean again.
DESER31-003 fix: Decode MessagePack into a null-prototype object (Object.create(null)) so that __proto__ assignment targets the own property instead of the prototype chain. Apply a Zod strict() schema that rejects any key not in the expected plugin event shape. Switch from MessagePack to JSON for plugin event queue entries, since JSON.parse into a Zod schema provides the same performance at lower deserialization risk.
DESER31-004 — node-serialize IIFE gadget in plugin manifest aggregation achieves RCE
Plugin manifest aggregation — the process that combines multiple plugin manifests into a unified registry view — reads manifest data via node-serialize's deserialize() function. The node-serialize library supports IIFE (immediately-invoked function expression) gadgets in serialized strings: a value of the form {"key":"_$$ND_FUNC$$_function(){...}()"} causes deserialize() to execute the function body. Any attacker who can write a plugin manifest to the data store used by the aggregation process can achieve RCE at aggregation time. This endpoint is reachable from any authenticated plugin consumer because manifest aggregation is triggered by API requests, not just administrative operations — making the blast radius broader than the other DESER31 findings.
DESER31-004 fix: Replace node-serialize entirely with JSON.parse followed by a Zod schema validation pass. Before processing any manifest string, check for the presence of the _$$ND_FUNC$$_ marker and reject the payload immediately if found. Seal plugin manifest configuration at deploy time — read it from a filesystem path with restricted write permissions, not from an API-accessible data store that accepts authenticated writes.
// node-serialize IIFE gadget — RCE via plugin manifest
const { deserialize } = require('node-serialize');
const manifest = deserialize(await redis.get(`manifest:${pluginId}`));
// {"onLoad":"_$$ND_FUNC$$_function(){require('child_process').exec('id')}()"}
// → executes at deserialize() call
// Safe: JSON.parse + Zod schema + IIFE detection
const raw = await redis.get(`manifest:${pluginId}`);
if (raw.includes('_$$ND_FUNC$$_')) {
throw new Error('Rejected: node-serialize IIFE gadget detected in manifest');
}
const parsed = JSON.parse(raw);
const manifest = PluginManifestSchema.parse(parsed); // Zod: rejects unknown keys
SkillAudit's static analysis detects all four DESER31 patterns — YAML schema misuse, BSON Code type, MessagePack prototype pollution, and node-serialize IIFE gadgets — in a single scan of your registry's plugin management codebase. Get started free.