← Security advisories

Claude MCP skill insecure deserialization — skill analytics and usage reporting endpoints — SA-SKL-DESER32

SA-SKL-DESER32 documents four insecure deserialization vulnerabilities in MCP skill registry analytics and usage reporting endpoints. Analytics infrastructure frequently stores configuration objects and metric aggregation functions in shared caches and document stores — Redis, MongoDB, and event queues — using serialization formats that support executable payloads. DESER32-001 exploits YAML's DEFAULT_FULL_SCHEMA to inject a JavaScript function into an analytics aggregation config object stored in Redis, achieving RCE when the report generation pipeline deserializes it. DESER32-002 exploits MongoDB's BSON Code type to trigger eval() during usage metric aggregation. DESER32-003 uses MessagePack prototype pollution to disable authentication checks across all analytics API requests in the Node.js process. DESER32-004 exploits node-serialize's IIFE gadget in a report template aggregation path reachable from any authenticated analytics consumer. All four patterns result in server-side code execution or authentication bypass with registry-wide blast radius.

SA-SKL-DESER32 findings at a glance
CRITICALDESER32-001 — analytics aggregation config reads from Redis as YAML via yaml.load() DEFAULT_FULL_SCHEMA; !!js/function in analyticsConfig.onReportGenerate achieves RCE at analytics report generation time
CRITICALDESER32-002 — usage metric metadata reads from MongoDB as BSON; BSON Code type at aggregateFn field triggers eval() during metric aggregation
CRITICALDESER32-003 — analytics event queue stored in Redis as MessagePack; __proto__.skipAnalyticsAuth:true pollutes Object.prototype, disabling authentication checks for all subsequent analytics API requests in process
CRITICALDESER32-004 — analytics report template aggregation reads via node-serialize; IIFE gadget achieves RCE at template aggregation time reachable from any authenticated analytics consumer

DESER32-001 — YAML DEFAULT_FULL_SCHEMA RCE via analytics aggregation config in Redis

Analytics pipeline configuration objects — including event filter rules, aggregation window definitions, and report generation hooks — are frequently stored in Redis for fast retrieval by distributed worker processes. When these config objects are serialized as YAML and read back using yaml.load() with the default schema (which is DEFAULT_FULL_SCHEMA in js-yaml versions before the breaking change that made FAILSAFE_SCHEMA the default), any YAML document that contains a !!js/function tag will have its payload evaluated as a JavaScript function at load time.

The analyticsConfig.onReportGenerate hook is the most accessible injection point. This field is called at the beginning of every analytics report generation run to allow custom pre-processing logic. An attacker who can write a malicious config object to the Redis key that stores this configuration — by exploiting a Redis authentication vulnerability, a misconfigured Redis instance without auth, or a path that accepts user-controlled analytics config parameters — can inject a !!js/function payload into the onReportGenerate field. Every subsequent analytics report generation run — which occurs on a timer for all registered skills — will execute the attacker's function in the context of the reporting worker process, with access to all environment variables including ANTHROPIC_API_KEY, database connection strings, and cloud provider credentials.

DESER32-001 fix: Replace yaml.load() with yaml.load(str, {schema: yaml.FAILSAFE_SCHEMA}) which only supports strings, arrays, and maps — no executable types. Migrate all analytics config storage to JSON. Apply a Zod AnalyticsConfigSchema after deserialization to validate field types. Replace function-valued config fields (onReportGenerate, onEventFilter, etc.) with a named-event dispatch table keyed by string enum values.

WRONG
async function getAnalyticsConfig(skillId) {
  const raw = await redis.get(`analytics:config:${skillId}`);
  return yaml.load(raw); // DEFAULT_FULL_SCHEMA — executes !!js/function
}

// Later: config.onReportGenerate(reportCtx) → RCE
RIGHT
const AnalyticsConfigSchema = z.object({
  windowSeconds: z.number().int().min(1).max(86400),
  onReportGenerate: z.enum(['summarize', 'aggregate', 'passthrough']),
  filters: z.array(z.string()).max(50)
});

async function getAnalyticsConfig(skillId) {
  const raw = await redis.get(`analytics:config:${skillId}`);
  const parsed = JSON.parse(raw); // JSON only — no executable types
  return AnalyticsConfigSchema.parse(parsed);
}

const reportHandlers = {
  summarize: summarizeReport,
  aggregate: aggregateReport,
  passthrough: passthroughReport
};

DESER32-002 — BSON Code eval() RCE via usage metric metadata in MongoDB

Usage metric documents stored in MongoDB may include an aggregateFn field that specifies how the metric should be aggregated across time windows. When these documents are retrieved using the MongoDB Node.js driver's default settings, BSON Code type values in document fields are preserved as JavaScript Code objects. When the metric aggregation pipeline calls aggregateFn(metricValue, window) without first checking the type of aggregateFn, the BSON Code object's eval() behavior is triggered, executing the stored JavaScript in the current process context.

The BSON Code eval() path is particularly dangerous in analytics infrastructure because metric aggregation runs continuously in the background against all stored metric documents, not just those belonging to the current API request. An attacker who can inject a BSON Code document into MongoDB — through a MongoDB authentication vulnerability, an insufficiently validated document write path, or a path that accepts raw BSON from client-controlled input — achieves code execution that fires on every metric aggregation cycle, potentially exfiltrating data continuously until the malicious document is removed.

DESER32-002 fix: Add an explicit instanceof BSON.Code check and throw on any Code type encountered in deserialized documents. Set promoteValues: false in the MongoDB driver options to prevent automatic promotion of BSON types to native JavaScript types. Apply a Zod string-only schema to the aggregateFn field. Use a named-aggregator lookup table that maps string names to aggregator functions rather than storing callable code in documents.

DESER32-003 — MessagePack prototype pollution via analytics event queue disables authentication

Analytics event queues stored in Redis as MessagePack payloads present a prototype pollution risk during deserialization. When msgpack.decode() processes a MessagePack object that contains a key string __proto__, the resulting JavaScript object assignment obj["__proto__"] = {skipAnalyticsAuth: true} modifies Object.prototype itself. Because all JavaScript objects inherit from Object.prototype, every subsequent if (req.skipAnalyticsAuth) check in the analytics API request handler now evaluates as truthy — the pollution persists for the entire lifetime of the Node.js process, affecting all concurrent and subsequent requests.

The skipAnalyticsAuth property name is an educated guess by an attacker who can read the registry's authentication middleware source code (from a public GitHub repository or a prior code disclosure). An attacker who controls the content of a MessagePack object written to the analytics event queue — through any path that processes user-submitted analytics events without strict type validation — can disable authentication for all analytics API endpoints across all orgs in the registry until the worker process restarts.

DESER32-003 fix: Parse MessagePack into a null-prototype object (Object.create(null)) to prevent prototype chain pollution. Apply a strict Zod schema before consuming any deserialized field. Migrate analytics event queue serialization to JSON, which is immune to BSON Code and MessagePack prototype pollution. Independently verify authentication state from the session store on every request — never from request-object properties that could be polluted.

DESER32-004 — node-serialize IIFE gadget RCE via analytics report template aggregation

Analytics report templates — objects that define the layout, sections, and data bindings for generated reports — may be stored using node-serialize for its compact object representation. node-serialize uses a known gadget: any string value that begins with _$$ND_FUNC$$_ is treated as a serialized JavaScript function and executed immediately (IIFE) during deserialization. An attacker who can write to the report template store — through any path that accepts user-controlled template data — can inject an IIFE payload that executes arbitrary code when the template is deserialized at report aggregation time.

The report template aggregation path is accessible to any authenticated analytics consumer because templates are shared across org members who want to generate consistent report formats. An authenticated attacker with read access to report templates submits a malicious template through the template creation or update API, then waits for the aggregation worker to load it. Because template aggregation runs on a schedule for all skills with active report subscriptions, the payload fires for all subsequent aggregation runs until the template is removed — without requiring any further action from the attacker.

DESER32-004 fix: Replace node-serialize with JSON.parse() combined with a Zod schema that validates all template fields as plain data types. Add an explicit pre-parse check that rejects any input string containing _$$ND_FUNC$$_. Seal report templates at deploy time — do not allow authenticated users to store arbitrary template objects; instead provide a template DSL with a fixed set of approved layout primitives that are assembled server-side.

WRONG
async function getReportTemplate(templateId) {
  const raw = await redis.get(`report:template:${templateId}`);
  return serialize.unserialize(raw); // IIFE gadget — RCE on any _$$ND_FUNC$$_ payload
}
RIGHT
const ReportTemplateSchema = z.object({
  sections: z.array(z.enum(['summary', 'timeline', 'breakdown', 'trend'])),
  groupBy: z.enum(['skill', 'org', 'day', 'week']).optional(),
  limit: z.number().int().min(1).max(1000).optional()
});

async function getReportTemplate(templateId) {
  const raw = await redis.get(`report:template:${templateId}`);
  if (raw.includes('_$$ND_FUNC$$_')) throw new Error('unsafe payload rejected');
  const parsed = JSON.parse(raw);
  return ReportTemplateSchema.parse(parsed);
}

SkillAudit scans your registry's analytics and usage reporting infrastructure for all four DESER32 patterns, plus the full SA-SKL-DESER series covering deserialization in every registry subsystem. Get started free — 3 audits/month on public repos, results in 60 seconds.