← Security advisories

Claude MCP skill insecure deserialization — skill dependency resolution and package lock pipeline endpoints — SA-SKL-DESER43

SA-SKL-DESER43 documents four insecure deserialization vulnerabilities in MCP skill registry dependency resolution and package lock pipeline endpoints. These are infrastructure-layer vulnerabilities that sit below the HTTP API surface: they target the serialization formats used to store resolver configuration in Redis, package lock manifests in MongoDB, dependency queues in message brokers, and aggregation results in in-process caches. Each vulnerability achieves code execution or authentication bypass at a specific point in the dependency pipeline, and each is reachable from normal authenticated API operations rather than requiring administrative access.

SA-SKL-DESER43 findings at a glance
CRITICALDESER43-001 — dependency resolution config reads from Redis as YAML via yaml.load() DEFAULT_FULL_SCHEMA — !!js/function in resolverConfig.onPackageResolve achieves RCE at every dependency resolution event triggered by skill install or update; fix: FAILSAFE_SCHEMA; JSON for all resolver config; Zod ResolverConfigSchema; named-event dispatch table
CRITICALDESER43-002 — package lock manifest reads from MongoDB as BSON — BSON Code type at lockfileGeneratorFn field triggers eval() during lockfile generation at every dependency pin event; promoteValues:true (default) preserves Code objects enabling eval path; fix: reject BSON Code; promoteValues:false; Zod string-only schema; named-generator lookup
CRITICALDESER43-003 — dependency resolution queue stored in Redis as MessagePack — __proto__.skipDepAuth:true pollutes Object.prototype, disabling authentication checks for all subsequent dependency resolution API requests in process until restart; fix: null-prototype target; Zod strict(); JSON instead of MessagePack
CRITICALDESER43-004 — dependency resolution result aggregation reads via node-serialize — IIFE gadget achieves RCE at dependency aggregation time reachable from any authenticated consumer of the dependency pipeline API; fix: JSON.parse + Zod; detect and reject _$$ND_FUNC$$_ payloads; sealed config at deploy time

DESER43-001 — YAML RCE in dependency resolution config via Redis

Severity: CRITICAL

The dependency resolution pipeline reads resolver configuration from Redis using yaml.load() with the default schema, which in js-yaml prior to v4.0 defaults to DEFAULT_FULL_SCHEMA (or DEFAULT_SAFE_SCHEMA in some versions — always check). When the full schema is active, the !!js/function YAML type is available. An attacker who can write to the Redis key-space (via a Redis SSRF, a compromised background worker, or a misconfigured Redis ACL) writes a payload where resolverConfig.onPackageResolve is a !!js/function value. When any worker processes a dependency resolution event — triggered by any skill install or update API call — the YAML deserializer evaluates the function literal, achieving RCE in the worker process. Because dependency resolution is horizontally scaled, a single Redis write propagates RCE to all worker replicas.

Vulnerable
// Dependency resolution worker — reads resolver config from Redis as YAML
const rawConfig = await redis.get(`resolver:config:${skillId}`);
const resolverConfig = yaml.load(rawConfig);  // DEFAULT_FULL_SCHEMA — !!js/function active

// resolverConfig.onPackageResolve executes attacker-supplied function
await resolverConfig.onPackageResolve(packageName, version);
Fixed
// Dependency resolution worker — reads resolver config from Redis as JSON
const rawConfig = await redis.get(`resolver:config:${skillId}`);
const parsed = JSON.parse(rawConfig);

const ResolverConfigSchema = z.object({
  onPackageResolve: z.enum(['log', 'validate', 'cache', 'skip']),
  strategy:        z.enum(['latest', 'pinned', 'semver']),
});
const resolverConfig = ResolverConfigSchema.parse(parsed);

// dispatch via named-function table — no arbitrary code execution
const handlers = { log: logHandler, validate: validateHandler, cache: cacheHandler, skip: skipHandler };
await handlers[resolverConfig.onPackageResolve](packageName, version);

DESER43-002 — BSON Code eval in package lock manifest via MongoDB

Severity: CRITICAL

The package lock pipeline reads lock manifest documents from MongoDB. The MongoDB BSON driver preserves the BSON Code type as a JavaScript Code object when promoteValues is true (the default). The pipeline stores a lockfileGeneratorFn field in the manifest document and calls it during lockfile generation at every dependency pin event. An attacker who can write to the MongoDB collection stores a BSON Code object at lockfileGeneratorFn. The driver promotes it to a Code instance, and when the pipeline calls doc.lockfileGeneratorFn(), the Code object is passed to eval(), achieving RCE at lockfile generation time for every skill that triggers a dependency pin operation.

Vulnerable
// Package lock pipeline — reads from MongoDB with default promoteValues:true
const manifest = await db.collection('lockManifests').findOne({ skillId });
// BSON Code type promoted to Code object by driver
const lockfile = await manifest.lockfileGeneratorFn(manifest.deps);  // eval() path
Fixed
// Package lock pipeline — promoteValues:false + schema enforcement
const manifest = await db.collection('lockManifests').findOne(
  { skillId },
  { promoteValues: false }
);

// reject any document containing BSON Code type
if (manifest.lockfileGeneratorFn instanceof Code) {
  throw new Error('Unexpected BSON Code in lockfile manifest');
}

const ManifestSchema = z.object({
  deps: z.record(z.string()),
  lockfileGeneratorFn: z.string(),  // string name, not callable
});
const safe = ManifestSchema.parse(manifest);

// named lookup — no eval
const generators = { semver: semverGenerator, exact: exactGenerator };
const lockfile = await generators[safe.lockfileGeneratorFn](safe.deps);

DESER43-003 — MessagePack prototype pollution in dependency resolution queue

Severity: CRITICAL

The dependency resolution queue stores task objects in Redis serialized as MessagePack. The deserialization step uses msgpack.decode() with a plain object target. An attacker injects a task payload with __proto__.skipDepAuth: true. When the worker deserializes this payload, the __proto__ key pollutes Object.prototype, setting skipDepAuth: true on every plain object in the process. All subsequent dependency resolution handlers that check if (task.skipDepAuth) or if (!options.skipDepAuth) will skip authentication, allowing unauthenticated dependency resolution requests until the worker process restarts.

Vulnerable
// Dependency resolution queue consumer — MessagePack with plain object target
const task = msgpack.decode(rawBytes);  // __proto__ pollution via attacker task

if (!task.skipDepAuth) {  // bypassed after prototype pollution
  await verifySession(task.sessionToken);
}
await resolvePackage(task.packageName, task.version);
Fixed
// Dependency resolution queue consumer — JSON + null-prototype + Zod strict
const rawTask = JSON.parse(rawString);
const task = Object.assign(Object.create(null), rawTask);  // null prototype

const TaskSchema = z.object({
  sessionToken: z.string().uuid(),
  packageName:  z.string().regex(/^[@a-z0-9._\/-]+$/),
  version:      z.string().regex(/^\d+\.\d+\.\d+/),
}).strict();  // reject extra keys including __proto__

const safe = TaskSchema.parse(task);
await verifySession(safe.sessionToken);
await resolvePackage(safe.packageName, safe.version);

DESER43-004 — node-serialize IIFE RCE in dependency result aggregation

Severity: CRITICAL

The dependency resolution result aggregation pipeline reads aggregated results using node-serialize. The node-serialize library uses a custom format where function literals are encoded as strings with the _$$ND_FUNC$$_ prefix. When these strings are deserialized, any IIFE (Immediately Invoked Function Expression) suffix — }() — causes the function to execute immediately during deserialization. Any authenticated consumer of the dependency pipeline API can store a crafted aggregation result containing this payload. The next time the aggregation pipeline reads and deserializes the result, the IIFE executes in the pipeline worker's Node.js context with full process privileges.

Vulnerable
// Dependency aggregation pipeline — reads results via node-serialize
const raw = await redis.get(`dep:aggregation:${skillId}`);
const result = serialize.unserialize(raw);  // IIFE in _$$ND_FUNC$$_ executes here
return result.packages;
Fixed
// Dependency aggregation pipeline — JSON.parse + payload scanning + Zod
const raw = await redis.get(`dep:aggregation:${skillId}`);

// reject any payload containing the node-serialize function marker
if (raw.includes('_$$ND_FUNC$$_')) {
  logger.warn({ skillId }, 'node-serialize gadget detected in dep aggregation');
  throw new Error('Unsafe serialization format in aggregation result');
}

const parsed = JSON.parse(raw);

const AggResultSchema = z.object({
  packages: z.record(z.string()),
  resolvedAt: z.string().datetime(),
});
const safe = AggResultSchema.parse(parsed);
return safe.packages;

All four SA-SKL-DESER43 vulnerabilities share the root cause of using unsafe deserialization formats for infrastructure-layer data stores. SkillAudit detects these patterns with AST queries targeting yaml.load() calls without explicit FAILSAFE_SCHEMA argument, MongoDB findOne() calls without promoteValues:false in collections storing function-type fields, MessagePack decode calls on queue-sourced data, and serialize.unserialize() usage anywhere in the codebase. For the broader deserialization attack surface see the related SA-SKL-DESER42 advisory on version compatibility and migration pipeline endpoints.