Claude MCP skill insecure deserialization — skill review workflow and approval gate endpoints — SA-SKL-DESER35
SA-SKL-DESER35 documents four insecure deserialization vulnerabilities in MCP skill registry review workflow and approval gate endpoints. These endpoints orchestrate the editorial pipeline through which skill submissions transition from draft to published: state machine config governing approval transitions, comment metadata rendered during review, event queues coordinating approval notifications, and review summary aggregation surfaced to review consumers. Each deserialization surface uses an unsafe format or schema that allows attacker-controlled data stored in persistence layers to trigger remote code execution or authentication bypass when read back during routine review operations.
yaml.load() DEFAULT_FULL_SCHEMA — !!js/function in workflowConfig.onApprovalTransition achieves RCE at every approval state changeCode type at formatCommentFn field triggers eval() during comment rendering in the review UI__proto__.skipApprovalAuth:true pollutes Object.prototype, disabling authentication checks for all subsequent approval API requests in the processnode-serialize — IIFE gadget achieves RCE at review summary aggregation time, reachable from any authenticated review consumerDESER35-001 — YAML RCE in review workflow state machine config
Severity: CRITICAL
The review workflow state machine stores its configuration in Redis as a YAML string and deserializes it on each approval state transition using yaml.load(config, { schema: yaml.DEFAULT_FULL_SCHEMA }). The DEFAULT_FULL_SCHEMA in the js-yaml library supports the !!js/function YAML type, which deserializes to a live JavaScript function via new Function(). An attacker who can write to the Redis key containing the workflow config — via a compromised Redis credential, a misconfigured Redis ACL, or a prior injection vulnerability — can embed a !!js/function value at the workflowConfig.onApprovalTransition field. This function is called on every approval state change, achieving RCE at the application layer with the privileges of the Node.js process handling the review workflow.
// review/workflow.js
const yaml = require('js-yaml');
const redis = require('./redis');
async function loadWorkflowConfig(skillId) {
const raw = await redis.get(`workflow:config:${skillId}`);
// DEFAULT_FULL_SCHEMA supports !!js/function — RCE if config is attacker-controlled
return yaml.load(raw, { schema: yaml.DEFAULT_FULL_SCHEMA });
}
async function onApprovalTransition(skillId, fromState, toState) {
const config = await loadWorkflowConfig(skillId);
// config.onApprovalTransition is a live function if YAML contained !!js/function
if (config.onApprovalTransition) {
await config.onApprovalTransition(skillId, fromState, toState);
}
}
// review/workflow.js
const yaml = require('js-yaml');
const { z } = require('zod');
const redis = require('./redis');
const WorkflowConfigSchema = z.object({
onApprovalTransition: z.enum(['notify_author', 'update_index', 'send_badge', 'noop']),
notificationChannels: z.array(z.string()).optional(),
timeoutMs: z.number().int().min(1000).max(30000).optional(),
});
// Named dispatch table — no live function deserialization
const transitionHandlers = {
notify_author: (skillId, from, to) => notifyAuthor(skillId, from, to),
update_index: (skillId, from, to) => updateSearchIndex(skillId, from, to),
send_badge: (skillId, from, to) => sendApprovalBadge(skillId, from, to),
noop: () => {},
};
async function loadWorkflowConfig(skillId) {
const raw = await redis.get(`workflow:config:${skillId}`);
if (!raw) return null;
// FAILSAFE_SCHEMA: only strings, numbers, booleans, nulls, arrays, maps — no !!js/*
const parsed = yaml.load(raw, { schema: yaml.FAILSAFE_SCHEMA });
return WorkflowConfigSchema.parse(parsed);
}
async function onApprovalTransition(skillId, fromState, toState) {
const config = await loadWorkflowConfig(skillId);
if (!config) return;
const handler = transitionHandlers[config.onApprovalTransition];
if (handler) await handler(skillId, fromState, toState);
}
DESER35-002 — BSON Code eval in review comment metadata
Severity: CRITICAL
Review comment metadata is stored in MongoDB and retrieved with the default MongoDB Node.js driver settings, which enable BSON type promotion including the Code type. The comment document includes a formatCommentFn field intended to hold the name of a formatting function as a string. When the driver reads a document where formatCommentFn is stored as a BSON Code object rather than a string, the driver deserializes it to a JavaScript function wrapper. The review rendering code then calls this value directly, triggering eval() of attacker-controlled JavaScript during comment display in the review interface.
// review/comments.js
const { MongoClient } = require('mongodb');
async function renderComment(commentId) {
const doc = await db.collection('comments').findOne({ _id: commentId });
// If formatCommentFn was stored as BSON Code, it deserializes to a function
if (typeof doc.formatCommentFn === 'function') {
return doc.formatCommentFn(doc.body); // eval() of attacker code
}
return doc.body;
}
// review/comments.js
const { MongoClient, BSON } = require('mongodb');
const { z } = require('zod');
const CommentSchema = z.object({
_id: z.any(),
body: z.string().max(10000),
// formatCommentFn must be a plain string key into the allowed formatter map
formatCommentFn: z.enum(['plain', 'markdown', 'code_block']).optional().default('plain'),
authorId: z.string(),
createdAt: z.date(),
});
const formatters = {
plain: (body) => escapeHtml(body),
markdown: (body) => renderMarkdown(body),
code_block: (body) => `${escapeHtml(body)}`,
};
async function renderComment(commentId) {
const doc = await db.collection('comments').findOne(
{ _id: commentId },
{ promoteValues: false } // prevent BSON Code promotion to JS function
);
// Reject any document where formatCommentFn is not a plain string
if (doc?.formatCommentFn instanceof BSON.Code) {
throw new Error('Rejected BSON Code in formatCommentFn — possible deserialization attack');
}
const comment = CommentSchema.parse(doc);
const formatter = formatters[comment.formatCommentFn];
return formatter(comment.body);
}
DESER35-003 — MessagePack prototype pollution in approval event queue
Severity: CRITICAL
The approval event queue is stored in Redis as MessagePack-encoded objects and consumed by the approval notification worker using msgpack.decode(buffer) with the default target {}. When an attacker can write to the event queue — via a compromised queue producer, an SSRF that reaches Redis, or a prior injection vulnerability — they can encode a payload where the key path __proto__ is set with skipApprovalAuth: true. MessagePack decoding with a plain object target merges this into Object.prototype, making ({}).skipApprovalAuth === true for all subsequently created objects in the process. Any approval API route that guards with if (!req.context.skipApprovalAuth) then fails open, allowing unauthenticated approval actions.
// review/approval-worker.js
const msgpack = require('msgpack');
async function processApprovalEvent(buffer) {
const event = msgpack.decode(buffer); // target is {}, vulnerable to __proto__ pollution
// If __proto__.skipApprovalAuth was set, all subsequent auth checks fail open
if (!event.skipApprovalAuth) {
await verifyApprovalSession(event.actorId);
}
await applyApprovalTransition(event.skillId, event.toState);
}
// review/approval-worker.js
const msgpack = require('msgpack');
const { z } = require('zod');
const ApprovalEventSchema = z.object({
skillId: z.string().uuid(),
actorId: z.string().uuid(),
toState: z.enum(['approved', 'rejected', 'needs_changes', 'withdrawn']),
timestamp: z.number().int(),
}).strict(); // reject any extra keys including __proto__
async function processApprovalEvent(buffer) {
// Decode into null-prototype object to prevent prototype chain pollution
const raw = msgpack.decode(buffer, { codec: msgpack.createCodec({ binarraybuffer: true }) });
const safeRaw = Object.assign(Object.create(null), raw);
// Validate strictly — unknown keys (including __proto__ mutations) are rejected
const event = ApprovalEventSchema.parse(safeRaw);
// Authentication is never conditional on event-level flags
await verifyApprovalSession(event.actorId);
await applyApprovalTransition(event.skillId, event.toState);
}
DESER35-004 — node-serialize IIFE gadget in review summary aggregation
Severity: CRITICAL
The review summary aggregation pipeline reads pre-computed summary objects from a cache using node-serialize. The node-serialize library supports IIFE (immediately-invoked function expression) gadgets via the _$$ND_FUNC$$_ key prefix: when a serialized string contains a value of the form {"key":"_$$ND_FUNC$$_function(){...}()"}, deserialization calls the function immediately. An attacker who can write to the summary cache can inject such a payload, achieving RCE when any authenticated user triggers review summary aggregation — a low-privilege reachable path that does not require admin access.
// review/summary.js
const serialize = require('node-serialize');
const redis = require('./redis');
async function getReviewSummary(skillId) {
const cached = await redis.get(`review:summary:${skillId}`);
if (cached) {
// node-serialize IIFE gadget: _$$ND_FUNC$$_ prefix triggers eval
return serialize.unserialize(cached);
}
return computeReviewSummary(skillId);
}
// review/summary.js
const { z } = require('zod');
const redis = require('./redis');
const ReviewSummarySchema = z.object({
skillId: z.string().uuid(),
approvedCount: z.number().int().nonnegative(),
rejectedCount: z.number().int().nonnegative(),
pendingCount: z.number().int().nonnegative(),
lastReviewedAt: z.string().datetime().nullable(),
});
async function getReviewSummary(skillId) {
const cached = await redis.get(`review:summary:${skillId}`);
if (cached) {
// Detect and reject any _$$ND_FUNC$$_ gadget payload before parsing
if (cached.includes('_$$ND_FUNC$$_')) {
await redis.del(`review:summary:${skillId}`); // evict poisoned cache entry
throw new Error('Rejected node-serialize gadget in review summary cache');
}
const parsed = JSON.parse(cached); // safe JSON only — no code execution
return ReviewSummarySchema.parse(parsed);
}
return computeReviewSummary(skillId);
}
Never use node-serialize for untrusted cache data. The _$$ND_FUNC$$_ IIFE gadget is a known, documented behaviour of node-serialize. Any cache tier (Redis, Memcached, file-based) that can be written to by an attacker — through SSRF, compromised credentials, or a prior injection — becomes an RCE vector when node-serialize.unserialize() is called on its contents. Replace with JSON.parse + Zod and add an explicit string scan for _$$ND_FUNC$$_ as a defence-in-depth detection layer.
Remediation summary
| Finding | Severity | Primary remediation | Secondary hardening |
|---|---|---|---|
| DESER35-001 | Critical | FAILSAFE_SCHEMA; JSON for workflow config; Zod WorkflowConfigSchema | Named-transition dispatch table; seal config at deploy time |
| DESER35-002 | Critical | Reject BSON Code; promoteValues:false; Zod string-only schema | Named-formatter lookup; escape output on render |
| DESER35-003 | Critical | Null-prototype target; Zod strict(); JSON instead of MessagePack | Reject events with extra keys at schema level |
| DESER35-004 | Critical | JSON.parse + Zod; detect and reject _$$ND_FUNC$$_ payloads | Evict poisoned cache entries; alert on detection |
SkillAudit scans for all four SA-SKL-DESER35 patterns. The audit engine detects yaml.load with non-FAILSAFE schemas, node-serialize.unserialize calls, MessagePack decode without null-prototype targets, and BSON Code type promotion. See related advisories: SA-SKL-DESER34 and SA-SKL-DESER33. Connect your repository at skillaudit.dev.