← Blog

Claude MCP skill insecure deserialization — skill dependency resolution and package lock management endpoints (SA-SKL-DESER72)

SA-SKL-DESER72 identifies four insecure deserialization vulnerabilities in MCP skill registry skill dependency resolution and package lock management endpoints. YAML deserialization via yaml.load() with DEFAULT_FULL_SCHEMA on dependency resolution configuration stored in Redis allows a !!js/function gadget in the depConfig.onResolutionComplete field to achieve remote code execution inside the resolution worker at every dependency resolution event triggered by any publisher publishing or updating a skill. BSON deserialization with the Code type enabled on package lock models stored in MongoDB allows an attacker who can write to the lock document to populate the lockfileProcessorFn field with executable BSON code that runs eval() during lock file processing at every install event. MessagePack deserialization of the dependency event queue stored in Redis allows an attacker to inject a __proto__.skipDepAuth:true key that pollutes Object.prototype and silently disables authentication for all subsequent dependency API requests processed by the same worker. And node-serialize deserialization of package resolution result aggregation data allows an IIFE gadget to achieve RCE at aggregation time, reachable from any user who views a skill's dependency graph page.

SA-SKL-DESER72 findings at a glance
CRITICALDESER72-001 — dependency resolution config reads from Redis as YAML via yaml.load() DEFAULT_FULL_SCHEMA — !!js/function in depConfig.onResolutionComplete achieves RCE at every dependency resolution event triggered by any publisher publishing or updating a skill
CRITICALDESER72-002 — package lock model reads from MongoDB as BSON — BSON Code type at lockfileProcessorFn field triggers eval() during lock file processing at every install event
CRITICALDESER72-003 — dependency event queue stored in Redis as MessagePack — __proto__.skipDepAuth:true pollutes Object.prototype, disabling authentication for all subsequent dependency API requests in same worker
CRITICALDESER72-004 — package resolution result aggregation reads via node-serialize — IIFE gadget achieves RCE at aggregation time reachable from any user viewing skill dependency graph

DESER72-001 — yaml.load RCE via dependency resolution config onResolutionComplete hook in Redis

The dependency resolution worker reads per-skill resolution configuration from Redis using yaml.load() with the DEFAULT_FULL_SCHEMA option, which enables all YAML types including the !!js/function tag that constructs arbitrary JavaScript functions from serialized source strings. The configuration document includes a lifecycle hook field — depConfig.onResolutionComplete — that the worker invokes after completing dependency resolution to trigger downstream tasks such as cache invalidation, security advisory checks, and resolution telemetry reporting. An attacker who can write a crafted YAML document to the Redis key controlling a target skill's resolution config can populate onResolutionComplete with a !!js/function gadget that executes arbitrary code inside the resolution worker process the next time any publisher triggers a dependency resolution event for any skill — because resolution workers are shared across the skill catalog, not isolated per publisher.

The attack surface for writing to the Redis key includes any code path that accepts publisher-supplied configuration and stores it to the resolution config namespace without schema validation: skill publish endpoints that accept a dependency config block, CI/CD webhook handlers that accept a resolution override payload, and administrative bulk-import operations that process publisher-submitted manifest files. Because the resolution event fires on every publish, update, and dependency audit operation across the entire skill catalog, the malicious hook executes repeatedly and reliably without any further attacker action after the initial write. The resolution worker has network access to the registry's internal services — the audit database, the billing API, and the notification queue — making post-exploitation lateral movement straightforward once RCE is achieved.

Vulnerable
// DESER72-001 — VULNERABLE: yaml.load with DEFAULT_FULL_SCHEMA on resolution config
const yaml = require('js-yaml');
const redis = require('../redis');

async function runDependencyResolution(skillId, manifest) {
  const raw = await redis.get(`dep:config:${skillId}`);
  // DEFAULT_FULL_SCHEMA enables !!js/function — RCE on deserialization
  const depConfig = yaml.load(raw, { schema: yaml.DEFAULT_FULL_SCHEMA });

  const result = await resolveManifest(manifest, depConfig);

  if (typeof depConfig.onResolutionComplete === 'function') {
    await depConfig.onResolutionComplete(result);  // executes attacker function
  }

  return result;
}

module.exports = { runDependencyResolution };

Resolution workers are shared across the entire skill catalog — a single crafted config entry executes attacker code on every subsequent publish, update, and dependency audit across all publisher skills in the registry. FAILSAFE_SCHEMA eliminates the !!js/function type entirely; Zod schema validation on deserialized output ensures only the expected config shape reaches the resolution worker; a named handler dispatch table replaces the arbitrary function invocation with a bounded set of pre-registered lifecycle callbacks.

Fixed
// DESER72-001 — FIXED: FAILSAFE_SCHEMA; Zod DepConfigSchema; named handler dispatch
const yaml = require('js-yaml');
const { z } = require('zod');
const redis = require('../redis');

const DepConfigSchema = z.object({
  onResolutionComplete: z.enum(['invalidate_cache', 'run_advisory_check', 'emit_telemetry']).optional(),
  resolverFlags: z.record(z.string(), z.boolean()).optional()
});

const RESOLUTION_HANDLERS = {
  invalidate_cache: (result) => invalidateResolutionCache(result.skillId),
  run_advisory_check: (result) => checkSecurityAdvisories(result.dependencies),
  emit_telemetry: (result) => emitResolutionTelemetry(result)
};

async function runDependencyResolution(skillId, manifest) {
  const raw = await redis.get(`dep:config:${skillId}`);
  // FAILSAFE_SCHEMA: only strings, numbers, booleans, nulls — no !!js/function
  const parsed = yaml.load(raw, { schema: yaml.FAILSAFE_SCHEMA });
  const depConfig = DepConfigSchema.parse(parsed);

  const result = await resolveManifest(manifest, depConfig);

  if (depConfig.onResolutionComplete) {
    const handler = RESOLUTION_HANDLERS[depConfig.onResolutionComplete];
    if (handler) await handler(result);
  }

  return result;
}

module.exports = { runDependencyResolution };

CVSS score: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H — Base Score 9.9 (CRITICAL); scope changed because the shared resolution worker processes all publisher skills; RCE inside the worker grants full access to the registry's internal service mesh.

DESER72-002 — BSON Code eval() on lockfileProcessorFn during package lock processing

The package lock management service reads lock file documents from MongoDB using the BSON driver with default settings, which includes support for the Code BSON type. The lock document schema includes a lockfileProcessorFn field — originally designed to allow configurable lock file transformation logic during the registry's internal tooling migration — that the service passes to eval() when it is present and of type Code. Any attacker who can write to the MongoDB collection storing lock documents — through a MongoDB injection in a lock update endpoint, through a compromised publisher account with write access to their own lock document, or through a misconfigured MongoDB user with broader write permissions — can insert a Code BSON value at the lockfileProcessorFn field. The eval() call fires during lock file processing at every install event for any skill whose lock document contains the crafted field, with the execution running in the Node.js process context of the lock processing service.

The lockfileProcessorFn field was not part of the original lock document schema and was never exposed through the API layer — it was added directly to MongoDB documents during a migration by an internal tooling script that has since been decommissioned. The field's presence in the schema was never formally deprecated or removed, and no validation layer blocks its persistence in new documents written through the API. The practical implication is that any publisher who can write to their own skill's lock document through the registry's dependency management API can insert an arbitrary code payload that executes inside the lock processing service on every install event for their skill — including installs triggered by other users who install that skill as a dependency.

Vulnerable
// DESER72-002 — VULNERABLE: BSON Code type enables eval() on lockfileProcessorFn
const { MongoClient, Code } = require('mongodb');

async function processLockFile(skillId, installContext) {
  const db = await MongoClient.connect(process.env.MONGO_URI);
  // promoteValues: true (default) — BSON Code objects deserialized as Code instances
  const lockDoc = await db.collection('lock_files').findOne({ skillId });

  if (lockDoc.lockfileProcessorFn instanceof Code) {
    // eval() on attacker-controlled BSON Code value
    const processor = eval(`(${lockDoc.lockfileProcessorFn.code})`);
    await processor(installContext);
  }

  return applyLockConstraints(installContext, lockDoc.constraints);
}

The lockfileProcessorFn field is a decommissioned migration artifact that was never removed from the schema — its continued presence creates a persistent eval() injection point reachable through any lock document write path. Setting promoteValues:false prevents BSON Code objects from deserializing as executable Code instances; excluding the field from all projection queries ensures it never reaches application code; and replacing the eval() invocation with a named processor dispatch eliminates the arbitrary code execution surface entirely.

Fixed
// DESER72-002 — FIXED: promoteValues:false; projection excludes lockfileProcessorFn; named dispatch
const { MongoClient } = require('mongodb');

const LOCK_PROCESSORS = {
  'npm-v3': processNpmV3Lock,
  'yarn-v4': processYarnV4Lock,
  'pnpm-v9': processPnpmV9Lock
};

async function processLockFile(skillId, installContext) {
  const db = await MongoClient.connect(process.env.MONGO_URI, {
    // promoteValues: false — BSON Code stays as opaque object, not evaluated
    promoteValues: false
  });
  // Projection explicitly excludes lockfileProcessorFn field
  const lockDoc = await db.collection('lock_files').findOne(
    { skillId },
    { projection: { lockfileProcessorFn: 0, constraints: 1, lockFormat: 1 } }
  );

  const processor = LOCK_PROCESSORS[lockDoc.lockFormat];
  if (!processor) throw new Error(`Unsupported lock format: ${lockDoc.lockFormat}`);
  await processor(installContext);

  return applyLockConstraints(installContext, lockDoc.constraints);
}

CVSS score: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H — Base Score 8.8 (HIGH); any publisher with write access to their own lock document can insert the BSON Code payload; execution fires on every install of that skill, including transitive dependency installs by other publishers.

DESER72-003 — MessagePack prototype pollution via __proto__.skipDepAuth disables dependency API authentication

The dependency resolution event queue is stored in Redis as MessagePack-encoded objects. The queue consumer reads event payloads using a MessagePack decoder that does not filter or sanitize keys before merging the deserialized object into the application context. An attacker who can write a crafted MessagePack message to the Redis queue — through a dependency event injection endpoint, through a compromised publisher account with queue write access, or through a Redis injection vulnerability in the event submission path — can include a __proto__ key in the payload. When the MessagePack decoder produces an object with a __proto__ key and the application merges it into an existing object using Object.assign() or spread syntax, the __proto__ key pollutes Object.prototype, adding the attacker-controlled properties to the prototype chain of every plain object created in the same Node.js worker process.

Setting __proto__.skipDepAuth:true causes the authentication middleware to skip credential validation for all subsequent dependency API requests processed by the affected worker. Because the registry's dependency API authentication check reads options.skipDepAuth from the request context — a plain object — and the prototype pollution has injected skipDepAuth:true into Object.prototype, every options object created after the pollution inherits the bypass flag without it being explicitly set. The worker remains poisoned until it is restarted, processing all subsequent requests without authentication for the duration of its uptime. In production configurations where workers are long-lived and handle requests from all publishers, a single crafted queue message disables dependency API authentication for the entire worker pool until a deployment or manual restart clears the prototype pollution.

Vulnerable
// DESER72-003 — VULNERABLE: MessagePack __proto__ pollution disables dep auth
const msgpack = require('msgpack5')();
const redis = require('../redis');

async function consumeDepEvents(worker) {
  const raw = await redis.brpop('dep:events', 0);
  // No key sanitization — __proto__ key pollutes Object.prototype
  const event = msgpack.decode(Buffer.from(raw[1], 'binary'));

  Object.assign(worker.context, event);  // __proto__.skipDepAuth:true injected here

  await processDepEvent(worker.context, event);
}

// In auth middleware:
function requireDepAuth(options = {}) {
  // options inherits skipDepAuth:true from polluted Object.prototype
  if (options.skipDepAuth) return next();  // bypassed for all requests
  return validateDepCredentials(options);
}

Prototype pollution via a single queue message disables authentication for all dependency API requests processed by the affected worker until restart — one malicious message silences the auth layer for the entire worker's remaining uptime. A sanitizeDeserialized() function that strips __proto__, constructor, and prototype keys before merge prevents prototype pollution from reaching application objects; replacing Object.assign with explicit field extraction ensures only expected event fields enter the worker context; and using Object.create(null) for the options object in auth middleware prevents prototype chain inheritance entirely.

Fixed
// DESER72-003 — FIXED: sanitizeDeserialized(); hasOwnProperty.call in auth; Object.create(null)
const msgpack = require('msgpack5')();
const redis = require('../redis');

function sanitizeDeserialized(obj) {
  if (typeof obj !== 'object' || obj === null) return obj;
  const safe = Object.create(null);
  for (const key of Object.keys(obj)) {
    if (key === '__proto__' || key === 'constructor' || key === 'prototype') continue;
    safe[key] = sanitizeDeserialized(obj[key]);
  }
  return safe;
}

async function consumeDepEvents(worker) {
  const raw = await redis.brpop('dep:events', 0);
  const decoded = msgpack.decode(Buffer.from(raw[1], 'binary'));
  const event = sanitizeDeserialized(decoded);  // __proto__ stripped

  // Explicit field extraction — no Object.assign spread
  worker.context.skillId = event.skillId;
  worker.context.publisherId = event.publisherId;
  worker.context.eventType = event.eventType;

  await processDepEvent(worker.context, event);
}

// In auth middleware:
function requireDepAuth(options) {
  // Object.create(null) — no prototype chain, no inherited skipDepAuth
  const safeOptions = Object.create(null);
  if (options && Object.prototype.hasOwnProperty.call(options, 'skipDepAuth')) {
    safeOptions.skipDepAuth = options.skipDepAuth;
  }
  if (safeOptions.skipDepAuth === true) return next();
  return validateDepCredentials(safeOptions);
}

CVSS score: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H — Base Score 9.9 (CRITICAL); scope changed because prototype pollution in a shared worker process affects all publisher requests processed by that worker; authentication bypass persists for the worker's entire uptime after a single queue write.

DESER72-004 — node-serialize IIFE RCE in package resolution result aggregation

The package resolution result aggregation service reads accumulated resolution results from a data store using node-serialize's unserialize() function. The node-serialize library supports immediately invoked function expressions (IIFEs) embedded in serialized strings using the _$$ND_FUNC$$_ marker prefix, which causes the function body to execute immediately upon deserialization rather than being stored as a callable. Any attacker who can write a crafted serialized string to the aggregation data store — through a resolution result injection endpoint, through a compromised resolution worker that writes to the aggregation namespace, or through a path traversal vulnerability in the result file reader — can embed an IIFE payload that achieves RCE inside the aggregation service process when any user views a skill's dependency graph page, which triggers the aggregation read.

The aggregation service runs in the same process as the dependency graph API, which serves responses to any authenticated user who views a skill's dependency information page. Because dependency graph viewing is available to all registered users — not just skill owners — the attack surface for triggering the aggregation read is the entire registered user base of the registry. The aggregation service has file system access to resolution result caches and network access to the registry's internal services, making it a high-value RCE target. The node-serialize library has been publicly known to have this IIFE vulnerability since 2017; its presence in a production aggregation service represents a dependency hygiene failure in addition to the direct security defect.

Vulnerable
// DESER72-004 — VULNERABLE: node-serialize IIFE RCE in resolution result aggregation
const serialize = require('node-serialize');
const { readResolutionResults } = require('../store/resolution');

async function aggregateResolutionResults(skillId) {
  const raw = await readResolutionResults(skillId);
  // node-serialize unserialize() executes _$$ND_FUNC$$_ IIFEs on deserialization
  const results = serialize.unserialize(raw);  // RCE if raw contains IIFE payload
  return computeAggregateStats(results);
}

The node-serialize IIFE vulnerability has been publicly documented since 2017 — its continued use in production aggregation services represents both a known-CVE dependency failure and a live RCE entry point reachable from any registered user's dependency graph view. Replacing node-serialize with JSON.parse eliminates the IIFE execution surface entirely; Zod schema validation on the parsed output ensures only the expected aggregation result shape reaches the stats computation; and an eviction check for the _$$ND_FUNC$$_ prefix blocks any legacy serialized payloads that may remain in the data store from prior writes.

Fixed
// DESER72-004 — FIXED: JSON.parse + Zod ResolutionAggregationSchema; evict _$$ND_FUNC$$_
const { z } = require('zod');
const { readResolutionResults } = require('../store/resolution');

const ResolutionResultSchema = z.object({
  resolvedAt: z.string().datetime(),
  dependencyCount: z.number().int().min(0),
  advisoryCount: z.number().int().min(0),
  lockfileHash: z.string().regex(/^[a-f0-9]{64}$/),
  resolverVersion: z.string()
});

const ResolutionAggregationSchema = z.array(ResolutionResultSchema);

async function aggregateResolutionResults(skillId) {
  const raw = await readResolutionResults(skillId);

  // Evict any legacy node-serialize payloads before parsing
  if (raw.includes('_$$ND_FUNC$$_')) {
    await evictResolutionResultEntry(skillId);
    throw new Error('Evicted malformed resolution result for skillId: ' + skillId);
  }

  const parsed = JSON.parse(raw);
  const results = ResolutionAggregationSchema.parse(parsed);
  return computeAggregateStats(results);
}

CVSS score: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H — Base Score 8.8 (HIGH); any authenticated user who views a skill dependency graph page can trigger the aggregation read; RCE inside the aggregation service grants access to resolution caches and internal registry services.

Scan your MCP skill for DESER72 and 200+ other vulnerability classes

SkillAudit checks for all SA-SKL-DESER vulnerability patterns including yaml.load RCE in dependency resolution config, BSON Code eval() on package lock processor fields, MessagePack prototype pollution disabling authentication, and node-serialize IIFE RCE in resolution aggregation. Get a graded report with line-level code fixes in 60 seconds.

Get a free audit