Claude MCP skill insecure deserialization — skill version compatibility and migration pipeline endpoints — SA-SKL-DESER42
SA-SKL-DESER42 documents four insecure deserialization vulnerabilities in MCP skill registry skill version compatibility and migration pipeline endpoints. Version migration pipelines are high-privilege server-side processes that run with broad filesystem and database access — they read transformation scripts from persistent stores, execute migration logic against live data, and aggregate results for reporting. Each of these storage reads is an opportunity for unsafe deserialization to convert a stored attacker payload into server-side code execution. This advisory covers YAML RCE via a function gadget in the compatibility config, BSON Code eval() in the migration executor, MessagePack prototype pollution that disables all in-process auth checks, and a node-serialize IIFE gadget that fires during migration result aggregation.
yaml.load() DEFAULT_FULL_SCHEMA; !!js/function in compatConfig.onMigrationExecute achieves RCE at every migration execution event; fix: FAILSAFE_SCHEMA; JSON for all compat config; Zod CompatConfigSchema; named-event dispatch tableCode type at migrationExecutorFn field triggers eval() during migration execution at version upgrade time; fix: reject BSON Code; promoteValues:false; Zod string-only schema; named-executor lookup__proto__.skipMigrationAuth:true pollutes Object.prototype, disabling authentication checks for all subsequent migration API requests in process; fix: null-prototype target; Zod strict(); JSON instead of MessagePacknode-serialize; IIFE gadget achieves RCE at migration aggregation time reachable from any authenticated consumer of the migration pipeline API; fix: JSON.parse + Zod; detect and reject _$$ND_FUNC$$_ payloads; sealed config at deploy timeDESER42-001 — YAML RCE via !!js/function in version compatibility config
Severity: CRITICAL
The version compatibility pipeline reads its configuration document from Redis at migration startup using yaml.load() without specifying a safe schema. The DEFAULT_FULL_SCHEMA used by default supports the !!js/function tag, which serializes JavaScript function source code. When the config document stored at the Redis key contains a compatConfig.onMigrationExecute field tagged !!js/function, the YAML parser instantiates that function at load time. The function executes with the Node.js process environment before the migration pipeline processes a single record. An attacker who can write to the Redis key — via SSRF against the Redis port, a compromised internal service, or a Redis misconfiguration — achieves arbitrary code execution on every server that starts a migration process.
Migration configs are shared across all pipeline workers. In horizontally-scaled deployments, all migration workers read from the same Redis key at startup. A single write of a malicious YAML payload achieves RCE on every migration worker simultaneously, not just the one that happens to handle the next request.
// version compatibility config loaded from Redis with unsafe YAML schema
const rawConfig = await redis.get('migration:compat:config');
const compatConfig = yaml.load(rawConfig); // DEFAULT_FULL_SCHEMA — !!js/function allowed
// if compatConfig.onMigrationExecute is a !!js/function, it was already called above
migrationPipeline.on('execute', compatConfig.onMigrationExecute);
// version compatibility config — FAILSAFE_SCHEMA + JSON + Zod
const CompatConfigSchema = z.object({
onMigrationExecute: z.enum(['log', 'validate', 'transform', 'skip']),
maxRetries: z.number().int().min(0).max(10),
timeoutMs: z.number().int().min(1000).max(300_000),
targetVersionRange: z.string().regex(/^\d+\.\d+\.\d+ - \d+\.\d+\.\d+$/),
});
const EXECUTE_HANDLERS = {
log: (ctx) => logger.info(ctx),
validate: (ctx) => validateMigrationContext(ctx),
transform: (ctx) => applyMigrationTransform(ctx),
skip: () => {},
};
const rawConfig = await redis.get('migration:compat:config');
// FAILSAFE_SCHEMA: only strings, no !!js/function, !!js/regexp, !!python/* etc.
const yamlParsed = yaml.load(rawConfig, { schema: yaml.FAILSAFE_SCHEMA });
const parsed = CompatConfigSchema.safeParse(JSON.parse(JSON.stringify(yamlParsed)));
if (!parsed.success) throw new Error('Invalid compat config');
// named dispatch — no dynamic code, no eval
const handler = EXECUTE_HANDLERS[parsed.data.onMigrationExecute];
migrationPipeline.on('execute', handler);
DESER42-002 — BSON Code eval() in migration executor fires at version upgrade time
Severity: CRITICAL
The migration pipeline reads migration scripts from MongoDB as BSON documents. The migrationExecutorFn field is intended to hold a string identifier naming which migration function to run. Instead, the MongoDB driver's default promoteValues: true behavior preserves BSON Code objects — the BSON type for JavaScript source code — as live JavaScript objects with a .code property. When the pipeline executes eval(doc.migrationExecutorFn.code) to run the migration logic, it executes attacker-controlled JavaScript. The trigger is any version upgrade event that causes the migration pipeline to fetch and run a migration script document. An attacker who can write a BSON document with a Code value to the migration scripts collection — via a compromised skill submission pipeline, a MongoDB injection, or a misconfigured index write — achieves RCE at every subsequent version upgrade.
// migration script read from MongoDB — BSON Code type preserved
const script = await db.collection('migration_scripts').findOne({
fromVersion: req.body.fromVersion,
toVersion: req.body.toVersion,
});
// if script.migrationExecutorFn is a BSON Code object, eval runs attacker code
const result = eval(script.migrationExecutorFn.code || script.migrationExecutorFn);
// migration script read from MongoDB — promoteValues:false + named lookup
const MIGRATION_EXECUTORS = {
'schema_v1_to_v2': migrateSchemav1Tov2,
'config_v2_to_v3': migrateConfigv2Tov3,
'permissions_v3_to_v4': migratePermissionsv3Tov4,
};
const script = await db.collection('migration_scripts').findOne(
{ fromVersion: req.body.fromVersion, toVersion: req.body.toVersion },
{ promoteValues: false } // BSON Code stays as Code object, never auto-converted
);
// validate the executor name is a plain string
const executorName = script?.migrationExecutorFn;
if (typeof executorName !== 'string') throw new Error('Invalid migration executor type');
const executor = MIGRATION_EXECUTORS[executorName];
if (!executor) throw new Error(`Unknown migration executor: ${executorName}`);
const result = await executor(script.context);
DESER42-003 — MessagePack prototype pollution disables migration auth checks
Severity: CRITICAL
The migration pipeline event queue stores job payloads in Redis as MessagePack-encoded objects. The MessagePack decoder deserializes map keys without sanitization, so a payload containing the key __proto__ with value {"skipMigrationAuth": true} merges these properties into Object.prototype. Every subsequent plain object created in the same Node.js process inherits skipMigrationAuth: true. The migration API's authentication middleware performs the check as if (req.context.skipMigrationAuth) return next() — a falsy check on a property that now exists on every object in the process. All migration API requests processed after the polluted queue item bypass authentication, allowing unauthenticated access to migration execution, status, and history endpoints for the lifetime of the process.
Prototype pollution persists until process restart. Once Object.prototype.skipMigrationAuth is set, every plain object in the process inherits it. The auth bypass affects all requests to all routes that check the polluted property — not just the route that processed the malicious queue item. A single poisoned queue entry disables migration auth until the Node.js worker is restarted.
// migration event queue decoded from Redis as MessagePack
const encoded = await redis.lpop('migration:event:queue');
const event = msgpack.decode(encoded); // __proto__ key merges into Object.prototype
// later in auth middleware — now always skipped after pollution
router.use((req, res, next) => {
if (req.context.skipMigrationAuth) return next(); // Object.prototype.skipMigrationAuth = true
if (!req.session?.userId) return res.status(401).end();
next();
});
// migration event queue — JSON instead of MessagePack + null-prototype target + Zod
const MigrationEventSchema = z.object({
eventId: z.string().uuid(),
fromVersion: z.string().regex(/^\d+\.\d+\.\d+$/),
toVersion: z.string().regex(/^\d+\.\d+\.\d+$/),
triggeredBy: z.string().uuid(),
scheduledAt: z.string().datetime(),
}).strict(); // reject unknown keys including __proto__
const raw = await redis.lpop('migration:event:queue');
const rawObj = JSON.parse(raw, (key, value) => {
if (key === '__proto__' || key === 'constructor' || key === 'prototype') return undefined;
return value;
});
// assign to null-prototype object — no prototype chain to pollute
const event = Object.assign(Object.create(null), rawObj);
const parsed = MigrationEventSchema.safeParse(event);
if (!parsed.success) throw new Error('Invalid migration event');
DESER42-004 — node-serialize IIFE gadget achieves RCE at migration aggregation time
Severity: CRITICAL
The migration result aggregation service reads aggregated result documents from Redis using node-serialize's unserialize() function. The node-serialize library supports serializing JavaScript functions by embedding their source code as a string prefixed with _$$ND_FUNC$$_. When the library deserializes an object whose function field is wrapped in an immediately-invoked function expression (IIFE) — the pattern _$$ND_FUNC$$_function(){ /* payload */ }() — the function executes at deserialization time. Any authenticated user of the migration pipeline API can write a crafted aggregation result to Redis by exploiting a separate write path, then trigger deserialization by calling the aggregation summary endpoint. The IIFE executes with full Node.js process privileges.
// migration result aggregation — node-serialize on Redis data
const raw = await redis.get(`migration:results:${migrationId}`);
const aggregated = serialize.unserialize(raw); // IIFE gadget executes here
return res.json(aggregated.summary);
// migration result aggregation — JSON.parse + Zod + IIFE detection
const MigrationResultSchema = z.object({
migrationId: z.string().uuid(),
status: z.enum(['pending', 'running', 'completed', 'failed', 'rolled_back']),
recordsTotal: z.number().int().nonneg(),
recordsDone: z.number().int().nonneg(),
errors: z.array(z.object({ code: z.string(), message: z.string() })).max(100),
completedAt: z.string().datetime().nullable(),
}).strict();
const raw = await redis.get(`migration:results:${migrationId}`);
if (!raw) return res.status(404).json({ error: 'Not found' });
// reject any payload that contains the node-serialize function marker
if (raw.includes('_$$ND_FUNC$$_')) {
logger.error({ migrationId, raw: raw.slice(0, 200) }, 'node-serialize gadget detected in migration results');
return res.status(500).json({ error: 'Internal error' });
}
const parsed = MigrationResultSchema.safeParse(JSON.parse(raw));
if (!parsed.success) return res.status(500).json({ error: 'Invalid result format' });
return res.json(parsed.data);