← Security advisories

Claude MCP skill insecure deserialization — skill release automation and publish queue endpoints — SA-SKL-DESER27

SA-SKL-DESER27 documents four insecure deserialization vulnerabilities in MCP skill registry release automation and publish queue endpoints. Release pipelines present a uniquely dangerous deserialization surface: they process configuration objects, hook definitions, and manifest summaries from multiple storage backends — Redis queues, MongoDB documents, MessagePack caches — often using deserializers that support executable code types. All four findings achieve code execution in the publish pipeline, with DESER27-001, DESER27-002, and DESER27-004 providing direct RCE, and DESER27-003 providing prototype pollution that silently bypasses signature verification for every subsequent publish job in the process.

SA-SKL-DESER27 findings at a glance
CRITICALDESER27-001 — Publish queue reads release config from Redis as YAML via yaml.load() DEFAULT_FULL_SCHEMA; !!js/function in releaseConfig.onPublishComplete achieves RCE at publish completion callback evaluation
CRITICALDESER27-002 — Release automation reads pre-publish hook config from MongoDB as BSON; BSON Code type at hookFn field triggers eval() during pre-publish hook execution on every publish job
HIGHDESER27-003 — Publish job state cached in Redis as MessagePack; __proto__.skipSignatureVerification:true pollutes Object.prototype, bypassing signature verification for all subsequent publish jobs in the process
CRITICALDESER27-004 — Release manifest aggregation reads summary via node-serialize; IIFE gadget achieves RCE at manifest aggregation time; fix: JSON.parse + Zod; detect and reject _$$ND_FUNC$$_ payloads

DESER27-001 — YAML RCE in release config via publish completion callback

The publish queue worker reads release configuration objects from Redis using yaml.load(data, { schema: yaml.DEFAULT_FULL_SCHEMA }). The DEFAULT_FULL_SCHEMA (also the default when no schema is specified) supports the !!js/function YAML type, which deserializes a string as a JavaScript function and returns a callable function object. When a release config object stored in Redis contains a releaseConfig.onPublishComplete field serialized as a !!js/function YAML type, the deserializer constructs a function from the string at load time. The publish worker then calls this callback when the publish job completes, executing attacker-controlled code in the Node.js process with the same privileges as the publish service.

An attacker who can write to the Redis queue — via a Redis authentication bypass, a misconfigured Redis instance without auth, or a previous compromise of any service with write access to the queue — can inject a malicious release config that runs arbitrary code on the next publish event for any skill. The RCE occurs in the background worker, not in a synchronous HTTP handler, making it harder to detect through request logging and easier to maintain as a persistent backdoor.

DESER27-001 fix: Replace yaml.load() with yaml.load(data, { schema: yaml.FAILSAFE_SCHEMA }) or switch to JSON.parse() for all queue data. Validate the parsed object against a Zod ReleaseConfigSchema that rejects any non-string, non-number field. Implement callback dispatch as a named-function lookup from a server-side registry — the config stores a string key like 'notify-slack', the worker resolves it to a known local function. Never deserialize a callable from queue data.

WRONG
// Publish worker reads release config from Redis
const rawConfig = await redis.get(`release:config:${jobId}`);
const releaseConfig = yaml.load(rawConfig); // DEFAULT_FULL_SCHEMA supports !!js/function
// ...
await releaseConfig.onPublishComplete(result); // RCE if attacker injected !!js/function
RIGHT
const ReleaseConfigSchema = z.object({
  skillId: z.string().uuid(),
  version: z.string().regex(/^\d+\.\d+\.\d+$/),
  onPublishComplete: z.enum(['notify-slack', 'notify-email', 'update-status', 'none']),
  notifyChannels: z.array(z.string()).max(10).optional()
});

const PUBLISH_CALLBACKS = {
  'notify-slack': notifySlack,
  'notify-email': notifyEmail,
  'update-status': updateStatusPage,
  'none': () => {}
};

const rawConfig = await redis.get(`release:config:${jobId}`);
const parsed = JSON.parse(rawConfig);  // no code-type support
const releaseConfig = ReleaseConfigSchema.parse(parsed);  // Zod validation

const callback = PUBLISH_CALLBACKS[releaseConfig.onPublishComplete];
await callback(result);  // only known local functions, never deserialized code

DESER27-002 — BSON Code eval in pre-publish hook via MongoDB

The release automation service reads pre-publish hook configurations from MongoDB documents where the hookFn field may contain a BSON Code type. The MongoDB Node.js driver, when promoteValues is not set to false, promotes BSON Code objects by calling eval() on the code string when the document is used in certain evaluation contexts. When the publish service reads the hook config and executes await config.hookFn(context), the BSON Code type triggers eval() with the attacker-supplied code string, executing arbitrary JavaScript in the publish service process.

The BSON Code injection vector is particularly dangerous because MongoDB documents often come from multiple upstream writers — admin interfaces, migration scripts, seed data importers — any of which may write a document with a Code type field if they are using a BSON library that supports it. An attacker who compromises any writer with access to the hook config collection can plant a malicious hook that executes on every subsequent publish job, persisting through process restarts and deployments as long as the MongoDB document survives.

DESER27-002 fix: At ingestion time, check config.hookFn instanceof mongodb.Code and reject documents that contain BSON Code types. Set promoteValues: false as a driver option to prevent automatic promotion. Validate against a Zod schema that accepts only string-type values for the hookFn field. Dispatch hooks via a named-function lookup from a server-side registry, never by evaluating a field value.

// WRONG — BSON Code type triggers eval() during hook execution
const hookConfig = await db.collection('publish_hooks').findOne({ skillId });
await hookConfig.hookFn(publishContext); // eval() if hookFn is BSON Code type

// RIGHT — reject Code types at ingestion; named-function dispatch
const HookConfigSchema = z.object({
  skillId: z.string().uuid(),
  hookFn: z.enum(['validate-semver', 'check-license', 'run-tests', 'none']),
  hookParams: z.record(z.string()).optional()
});

const HOOK_REGISTRY = {
  'validate-semver': validateSemver,
  'check-license': checkLicense,
  'run-tests': runTests,
  'none': async () => {}
};

const rawDoc = await db.collection('publish_hooks').findOne(
  { skillId },
  { promoteValues: false }  // prevent BSON Code promotion
);
if (rawDoc?.hookFn instanceof mongodb.Code) {
  throw new Error('BSON Code type rejected in hook config');
}
const hookConfig = HookConfigSchema.parse(rawDoc);
await HOOK_REGISTRY[hookConfig.hookFn](publishContext);

DESER27-003 — MessagePack prototype pollution bypasses signature verification

Publish job state objects are cached in Redis as MessagePack. When the publish worker deserializes a job state object using a MessagePack library that does not apply null-prototype targets, an attacker who can inject into the Redis cache can craft a payload containing __proto__ as a map key with a value of {"skipSignatureVerification": true}. The deserialization copies this into Object.prototype via Object.assign or equivalent. From that point forward, every new JavaScript object in the process — including the signature verification config objects read from sealed configuration files — has skipSignatureVerification: true as an inherited property, bypassing the signature gate for every subsequent publish job until the process restarts.

Prototype pollution via deserialization is a persistent, process-wide attack that affects all subsequent operations after the poisoned cache entry is read. Because the bypass is inherited by new objects rather than modifying existing ones, standard integrity checks on configuration objects may pass — the config file is genuine and unmodified — while the runtime behavior reflects the attacker's injected property. Detecting this in a running process requires explicit checks for Object.prototype modifications, which most logging and monitoring systems do not perform.

DESER27-003 fix: Use Object.create(null) as the target for all MessagePack deserialization, preventing __proto__ from reaching Object.prototype. Validate the deserialized object against a Zod strict() schema that rejects unexpected keys. Replace MessagePack with JSON for publish job state, or use a MessagePack library with built-in prototype pollution protection. Add an explicit Object.prototype pollution check in the worker startup path.

// WRONG — Object.assign with deserialized MessagePack pollutes Object.prototype
const raw = await redis.getBuffer(`publish:job:${jobId}`);
const jobState = msgpack.decode(raw);  // __proto__ key copies to Object.prototype
// All subsequent objects: { ...defaults, ...jobState } inherit skipSignatureVerification: true

// RIGHT — null-prototype target; Zod strict; JSON instead of MessagePack
const PublishJobStateSchema = z.object({
  jobId: z.string().uuid(),
  skillId: z.string().uuid(),
  status: z.enum(['pending', 'running', 'complete', 'failed']),
  startedAt: z.string().datetime()
}).strict();  // reject unexpected keys including __proto__

const raw = await redis.get(`publish:job:${jobId}`);  // JSON string
const parsed = JSON.parse(raw);  // no __proto__ gadget in JSON.parse
const jobState = PublishJobStateSchema.parse(parsed);

DESER27-004 — node-serialize IIFE RCE in release manifest aggregation

The release manifest aggregation service reads summary objects from Redis using node-serialize's unserialize() function. node-serialize supports a function serialization format where any value matching the pattern _$$ND_FUNC$$_function(){ ... }() is treated as an Immediately Invoked Function Expression and executed during deserialization. An attacker who can write to the manifest summary Redis keys can inject a payload containing this pattern in any string field, achieving RCE at the moment the aggregation service reads and deserializes the summary.

The node-serialize IIFE gadget is well-documented and has been exploited in multiple production Node.js applications. The critical factor in DESER27-004 is that the manifest aggregation service runs on a schedule — typically after each batch of publish jobs completes — meaning the RCE trigger is predictable: an attacker who injects the payload into a Redis key knows that the next aggregation cycle will execute their code. This predictability makes DESER27-004 suitable for persistent backdoor installation rather than just opportunistic exploitation.

DESER27-004 fix: Replace node-serialize entirely with JSON.parse() and Zod schema validation. At any Redis read point, check for the _$$ND_FUNC$$_ marker before deserialization and reject the entry if present. Store manifest summaries as plain JSON. Never store or read config objects from a network-accessible cache using a serialization format that supports executable code types.

// WRONG — node-serialize executes IIFE gadgets on unserialize()
const raw = await redis.get(`manifest:summary:${batchId}`);
const summary = nodeSerialize.unserialize(raw);  // executes _$$ND_FUNC$$_ payloads

// RIGHT — JSON + Zod + pre-scan for node-serialize markers
const ManifestSummarySchema = z.object({
  batchId: z.string().uuid(),
  skillCount: z.number().int().nonnegative(),
  successCount: z.number().int().nonnegative(),
  failureCount: z.number().int().nonnegative(),
  completedAt: z.string().datetime()
}).strict();

const raw = await redis.get(`manifest:summary:${batchId}`);
if (raw?.includes('_$$ND_FUNC$$_')) {
  throw new Error('node-serialize gadget detected in manifest summary; rejecting');
}
const parsed = JSON.parse(raw);
const summary = ManifestSummarySchema.parse(parsed);
Detect SA-SKL-DESER27 in your registry

SkillAudit scans for unsafe deserializers (yaml.load with DEFAULT_FULL_SCHEMA, node-serialize, MessagePack without null-prototype targets), BSON Code type handling, and prototype pollution vectors across all publish pipeline and release automation workers in your MCP skill registry codebase.

Scan your registry
FindingSeverityVectorImpact
DESER27-001CRITICALyaml.load() DEFAULT_FULL_SCHEMA on release config from RedisRCE at publish completion via !!js/function in onPublishComplete callback
DESER27-002CRITICALBSON Code type in MongoDB pre-publish hook configRCE via eval() during pre-publish hook execution on every publish job
DESER27-003HIGHMessagePack __proto__ pollution in Redis publish job stateProcess-wide bypass of signature verification for all subsequent publish jobs
DESER27-004CRITICALnode-serialize IIFE gadget in Redis manifest summaryRCE at manifest aggregation time; predictable trigger enables persistent backdoor

See also: SA-SKL-DESER26 (test runner deserialization patterns) and SA-SKL-INJECTION32 for the companion command injection vulnerabilities in container build and OCI image push endpoints that share the same supply-chain attack surface as the publish pipeline.