← Security advisories

Claude MCP skill insecure deserialization — CI/CD pipeline configuration and job scheduling endpoints — SA-SKL-DESER46

SA-SKL-DESER46 documents four insecure deserialization vulnerabilities in MCP skill registry CI/CD pipeline configuration and job scheduling endpoints. CI pipeline infrastructure is a privileged execution environment that processes every skill build, test, and artifact delivery event. DESER46 identifies four distinct deserialization attack surfaces: unsafe YAML deserialization of pipeline configuration from Redis achieves RCE at every CI job start event; BSON Code deserialization in the MongoDB job scheduler triggers eval() during job scheduling at every pipeline trigger; prototype pollution via MessagePack deserialization in the pipeline event queue disables authentication checks for all subsequent CI API requests; and node-serialize deserialization in pipeline result aggregation provides an IIFE gadget that achieves RCE reachable from any authenticated consumer of the CI pipeline API.

SA-SKL-DESER46 findings at a glance
CRITICALDESER46-001 — CI pipeline config reads from Redis as YAML via yaml.load() DEFAULT_FULL_SCHEMA — !!js/function in pipelineConfig.onJobStart achieves RCE at every CI job start event triggered by skill build; fix: FAILSAFE_SCHEMA; JSON for all pipeline config; Zod PipelineConfigSchema; named-event dispatch table
CRITICALDESER46-002 — job schedule model reads from MongoDB as BSON — BSON Code type at jobExecutorFn field triggers eval() during job scheduling at every pipeline trigger event; fix: reject BSON Code; promoteValues:false; Zod string-only schema; named-executor lookup
CRITICALDESER46-003 — pipeline event queue stored in Redis as MessagePack — __proto__.skipPipelineAuth:true pollutes Object.prototype, disabling authentication checks for all subsequent CI API requests in process until restart; fix: null-prototype target; Zod strict(); JSON instead of MessagePack
CRITICALDESER46-004 — pipeline result aggregation reads via node-serialize — IIFE gadget achieves RCE at pipeline aggregation time reachable from any authenticated consumer of the CI pipeline API; fix: JSON.parse + Zod; detect and reject _$$ND_FUNC$$_ payloads; sealed config at deploy time

DESER46-001 — YAML RCE in CI pipeline config via Redis DEFAULT_FULL_SCHEMA

Severity: CRITICAL

The CI pipeline service reads pipeline configuration objects from Redis using yaml.load(data) with the default DEFAULT_FULL_SCHEMA. This schema supports the !!js/function YAML type tag, which reconstructs JavaScript function objects from serialized source strings during deserialization. An attacker who can write to the Redis instance — via a Redis AUTH bypass, a misconfigured Redis ACL, or a prior compromise of a service with Redis write access — plants a crafted YAML value at the pipeline configuration key with a !!js/function payload at the pipelineConfig.onJobStart field.

When the CI pipeline service deserializes this configuration at the start of the next CI job triggered by any skill build, the reconstructed function executes in the Node.js process with full server privileges. The trigger event is automatic: every push to a skill's source repository fires a CI job start event, meaning the attacker payload executes without any additional user interaction once the poisoned configuration key is in Redis. The RCE achieves full access to the CI environment including build secrets, signing keys, registry credentials, and cloud provider tokens stored in environment variables.

yaml.load() with DEFAULT_FULL_SCHEMA deserializes arbitrary JavaScript functions. The js-yaml library's DEFAULT_FULL_SCHEMA supports !!js/function, !!js/regexp, and !!js/undefined type tags that reconstruct JavaScript objects from YAML. Any call to yaml.load() on data from an external source — including Redis, MongoDB, or message queues — must use FAILSAFE_SCHEMA or DEFAULT_SAFE_SCHEMA. Pipeline configuration must be stored as JSON, not YAML.

Vulnerable
// CI pipeline config from Redis — unsafe yaml.load() with DEFAULT_FULL_SCHEMA
const redis = new Redis(process.env.REDIS_URL);

async function loadPipelineConfig(pipelineId) {
  const raw = await redis.get(`pipeline:config:${pipelineId}`);
  return yaml.load(raw); // !!js/function in onJobStart achieves RCE at every job start
}
Fixed
// CI pipeline config from Redis — JSON + Zod validation
import { z } from 'zod';
const PipelineConfigSchema = z.object({
  pipelineId: z.string().uuid(),
  onJobStart: z.enum(['notify', 'log', 'audit']), // named dispatch, never a function
  timeoutSeconds: z.number().int().min(60).max(3600),
  environment: z.record(z.string(), z.string()).optional(),
});

async function loadPipelineConfig(pipelineId) {
  const raw = await redis.get(`pipeline:config:${pipelineId}`);
  if (!raw) throw new Error('Pipeline config not found');
  const parsed = PipelineConfigSchema.safeParse(JSON.parse(raw));
  if (!parsed.success) throw new Error('Invalid pipeline config: ' + parsed.error);
  return parsed.data;
}

DESER46-002 — BSON Code eval in MongoDB job scheduler

Severity: CRITICAL

The job scheduling service reads job schedule documents from MongoDB using the default driver settings, which set promoteValues: true. This causes the MongoDB driver to automatically promote BSON Code objects to JavaScript Code objects in the deserialized result. If the job schedule document contains a BSON Code type at the jobExecutorFn field — either because an attacker has written directly to MongoDB or because the application stores user-supplied data without type validation — the driver reconstructs a JavaScript Code object whose valueOf() or toString() method is called by the scheduling infrastructure, triggering eval() of the attacker's payload.

The trigger event is every pipeline trigger: when a skill CI job is queued, the scheduler reads the job document to determine which executor function to invoke. The eval() executes in the Node.js process with full server privileges, achieving RCE with access to all environment variables and secrets available to the scheduler service. Because the BSON Code payload is stored in MongoDB and executed on every pipeline trigger, the attack is persistent and fires repeatedly until the malicious document is removed from the database.

BSON Code type promotion executes JavaScript during deserialization. MongoDB's default promoteValues: true driver setting promotes BSON Code objects to JavaScript Code objects. Any MongoDB query that might return documents containing attacker-controlled data must use promoteValues: false. Schema validation via Zod must reject any field that is expected to be a string but deserializes as a non-string type.

Vulnerable
// Job schedule reads from MongoDB — BSON Code type triggers eval()
const client = new MongoClient(process.env.MONGO_URL); // promoteValues:true (default)

async function loadJobSchedule(jobId) {
  const db = client.db('registry');
  const job = await db.collection('job_schedules').findOne({ _id: jobId });
  // job.jobExecutorFn may be a BSON Code object — toString()/valueOf() triggers eval()
  return job;
}
Fixed
// Job schedule reads from MongoDB — promoteValues:false + Zod string schema
import { z } from 'zod';
const JobScheduleSchema = z.object({
  pipelineId: z.string(),
  jobExecutorFn: z.enum(['build', 'test', 'lint', 'package', 'deploy']), // named lookup, never eval
  cronExpression: z.string().regex(/^[\d\s*/,-]+$/),
  timeoutSeconds: z.number().int().min(60).max(3600),
});

const client = new MongoClient(process.env.MONGO_URL, { promoteValues: false });

async function loadJobSchedule(jobId) {
  const db = client.db('registry');
  const raw = await db.collection('job_schedules').findOne({ _id: jobId });
  if (!raw) throw new Error('Job schedule not found');
  const parsed = JobScheduleSchema.safeParse(raw);
  if (!parsed.success) throw new Error('Invalid job schedule: ' + parsed.error);
  return parsed.data;
}

DESER46-003 — Prototype pollution via MessagePack pipeline event queue disables auth

Severity: CRITICAL

The CI pipeline event queue is stored in Redis and serialized using MessagePack. When the pipeline service dequeues and deserializes pipeline events, the MessagePack decoder uses Object.assign(target, decoded) without a null-prototype target object. An attacker who can enqueue malicious pipeline events crafts a MessagePack payload that sets __proto__.skipPipelineAuth to true. When the payload is decoded, the prototype assignment pollutes Object.prototype, causing every subsequent object created in the same process to have skipPipelineAuth: true as an inherited property.

The CI pipeline authentication middleware checks if (req.context.skipPipelineAuth) to bypass authentication for internal service-to-service calls. After prototype pollution, this condition evaluates to true for all requests in the process, disabling authentication checks for all subsequent CI API requests until the process restarts. An attacker can then trigger arbitrary pipeline jobs, access pipeline secrets, and read build artifacts without authentication by making API requests in the window between the pollution event and the next process restart.

MessagePack deserialization without null-prototype targets enables prototype pollution. Any deserialization format that produces plain JavaScript objects — including MessagePack, BSON, and even JSON.parse() — can cause prototype pollution if the decoded data is merged into an existing object using Object.assign() or spread syntax without a null-prototype target. Use Object.create(null) as the target, apply Zod strict() validation on the result, and store pipeline events as JSON rather than MessagePack to eliminate this attack surface.

Vulnerable
// Pipeline event queue deserialization — MessagePack without null-prototype target
import { decode } from '@msgpack/msgpack';

async function processPipelineEvent(rawEvent) {
  const decoded = decode(rawEvent); // __proto__.skipPipelineAuth:true pollutes Object.prototype
  const event = Object.assign({}, decoded); // pollution spreads to all objects in process
  await handlePipelineEvent(event);
}
Fixed
// Pipeline event queue deserialization — JSON + null-prototype + Zod strict()
import { z } from 'zod';
const PipelineEventSchema = z.object({
  eventType: z.enum(['job.start', 'job.complete', 'job.fail', 'artifact.upload']),
  pipelineId: z.string().uuid(),
  jobId: z.string().uuid(),
  triggeredBy: z.string().uuid(),
  at: z.string().datetime(),
}).strict(); // reject unknown keys including __proto__

async function processPipelineEvent(rawEvent) {
  const decoded = JSON.parse(rawEvent);
  // null-prototype target prevents prototype pollution
  const safe = Object.assign(Object.create(null), decoded);
  const parsed = PipelineEventSchema.safeParse(safe);
  if (!parsed.success) {
    logger.warn('Invalid pipeline event rejected', { error: parsed.error });
    return;
  }
  await handlePipelineEvent(parsed.data);
}

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

Severity: CRITICAL

The pipeline result aggregation service uses the node-serialize package to deserialize pipeline result objects retrieved from a shared result store. The node-serialize package's unserialize() function reconstructs JavaScript functions from serialized strings and immediately invokes any Immediately Invoked Function Expression (IIFE) it encounters in the payload. An attacker who can write a crafted result object to the pipeline result store places a payload at a standard aggregation key with an IIFE gadget as the value of any field.

When the aggregation service processes the next batch of pipeline results — triggered automatically by the completion of any CI job — the node-serialize call deserializes the malicious payload and executes the IIFE with full server privileges. The attack is reachable from any authenticated consumer of the CI pipeline API who can submit a pipeline job and influence the result object written to the result store. This includes skill authors who run audits via SkillAudit's CI integration, making this a supply-chain RCE path that escalates from skill-audit-consumer to registry-infrastructure-compromise.

node-serialize is not safe for untrusted data. The node-serialize package was designed for Node.js object serialization and explicitly supports function serialization via IIFE gadgets. It must never be used to deserialize data from external sources, shared stores, or message queues. Use JSON.parse() combined with Zod schema validation for all pipeline result deserialization. Add a payload inspection step that rejects any string containing the _$$ND_FUNC$$_ marker before passing data to any deserializer.

Vulnerable
// Pipeline result aggregation — node-serialize IIFE gadget achieves RCE
import { unserialize } from 'node-serialize';

async function aggregatePipelineResults(pipelineId) {
  const raw = await resultStore.get(`pipeline:results:${pipelineId}`);
  const results = unserialize(raw); // IIFE in any field achieves RCE
  return computeAggregates(results);
}
Fixed
// Pipeline result aggregation — JSON.parse + IIFE detection + Zod schema
import { z } from 'zod';
const PipelineResultSchema = z.object({
  pipelineId: z.string().uuid(),
  jobResults: z.array(z.object({
    jobId: z.string().uuid(),
    status: z.enum(['success', 'failure', 'timeout', 'cancelled']),
    durationMs: z.number().int().nonneg(),
    exitCode: z.number().int(),
  })),
  completedAt: z.string().datetime(),
});

async function aggregatePipelineResults(pipelineId) {
  const raw = await resultStore.get(`pipeline:results:${pipelineId}`);
  if (!raw) return null;

  // reject node-serialize payloads before parsing
  if (raw.includes('_$$ND_FUNC$$_')) {
    logger.error('node-serialize IIFE payload detected in pipeline results', { pipelineId });
    throw new Error('Malformed pipeline result rejected');
  }

  const parsed = PipelineResultSchema.safeParse(JSON.parse(raw));
  if (!parsed.success) throw new Error('Invalid pipeline result: ' + parsed.error);
  return computeAggregates(parsed.data);
}

All four SA-SKL-DESER46 vulnerabilities reflect a consistent pattern of unsafe deserialization practices in CI pipeline configuration and job scheduling infrastructure that processes every skill build in the registry. SkillAudit detects DESER46-001 by flagging yaml.load() calls without explicit FAILSAFE_SCHEMA on data sourced from Redis or external stores; DESER46-002 by detecting MongoDB client instantiation without promoteValues: false in services that handle CI job documents; DESER46-003 by detecting MessagePack decode calls without null-prototype targets or Zod strict() validation; and DESER46-004 by detecting any import or require of the node-serialize package. See also SA-SKL-DESER45 on review rating aggregation pipeline endpoints for the companion chain targeting review infrastructure deserialization.

Defense-in-depth for CI pipeline deserialization

The four DESER46 findings share a common root cause: pipeline configuration and job scheduling data flows through multiple serialization boundaries — application code writes to Redis or MongoDB, CI workers read from those stores — without consistent schema enforcement at each boundary. A defense-in-depth approach requires three complementary controls. First, all pipeline configuration must be stored as JSON with explicit Zod schema validation at both write time and read time, so that invalid or malicious payloads are rejected before they reach the deserializer. Second, all MongoDB client instances in CI-related services must set promoteValues: false to prevent BSON Code promotion, and all Redis reads must use JSON rather than YAML or MessagePack. Third, pipeline services must run with the minimum required privileges and in isolated execution contexts, so that an RCE payload achieved via any of the four DESER46 paths cannot pivot to registry infrastructure or cloud provider credentials outside the CI worker's scope.

SkillAudit detection

SkillAudit's static analysis rules detect all four DESER46 vulnerability classes during CI pipeline scanning. The unsafe YAML schema detector flags any yaml.load() call that does not explicitly pass { schema: yaml.FAILSAFE_SCHEMA } or { schema: yaml.DEFAULT_SAFE_SCHEMA } as options. The BSON Code promotion detector flags any new MongoClient() call that does not include promoteValues: false. The prototype pollution detector flags MessagePack or other binary deserializer decode calls that pass the result directly to Object.assign({}, ...) or spread syntax without a null-prototype intermediate. The node-serialize detector flags any import or require of the node-serialize package. All findings include remediation snippets and links to this advisory.