Claude MCP skill insecure deserialization — skill review and rating aggregation pipeline endpoints — SA-SKL-DESER45
SA-SKL-DESER45 documents four insecure deserialization vulnerabilities in MCP skill registry review and rating aggregation pipeline endpoints. Review and rating aggregation pipelines process high volumes of user-submitted review events and compute running rating scores that determine skill ranking and trustworthiness signals in the registry marketplace. DESER45 identifies four distinct deserialization attack surfaces across the aggregation pipeline: YAML RCE via yaml.load() with DEFAULT_FULL_SCHEMA on the aggregation config stored in Redis; BSON Code type eval() during rating computation from MongoDB; MessagePack prototype pollution disabling authentication checks for all subsequent requests in the process; and node-serialize IIFE gadget RCE at aggregation time reachable from any authenticated consumer of the review pipeline API.
yaml.load() DEFAULT_FULL_SCHEMA — !!js/function in aggregateConfig.onRatingCompute achieves RCE at every rating computation event triggered by review submission; fix: FAILSAFE_SCHEMA; JSON for all aggregation config; Zod AggregateConfigSchema; named-event dispatch tableCode type at ratingComputeFn field triggers eval() during rating aggregation at every review completion event; fix: reject BSON Code; promoteValues:false; Zod string-only schema; named-compute lookup__proto__.skipReviewAuth:true pollutes Object.prototype, disabling authentication checks for all subsequent review API requests in process until restart; fix: null-prototype target; Zod strict(); JSON instead of MessagePack_$$ND_FUNC$$_ payloads; sealed config at deploy timeDESER45-001 — YAML RCE via yaml.load() DEFAULT_FULL_SCHEMA on review aggregation config
Severity: CRITICAL
The review aggregation pipeline reads its configuration from a Redis key using yaml.load() with the default DEFAULT_FULL_SCHEMA. This schema supports the !!js/function YAML type, which deserializes function bodies and evaluates them in the Node.js process. An attacker who gains write access to Redis — through a misconfigured Redis AUTH password, an SSRF vulnerability targeting the internal Redis endpoint, or a compromised pipeline worker — can overwrite the aggregation config key to inject a !!js/function value at the aggregateConfig.onRatingCompute field. This function is called at every rating computation event, which is triggered on every new review submission. The injected function runs with the full privileges of the aggregation service process, enabling exfiltration of database credentials, cloud provider IAM tokens, and internal service API keys.
The attack is persistent: the malicious config remains in Redis until explicitly overwritten, meaning every review submission after the injection triggers the attacker's code. High-volume skills that receive many reviews will trigger the payload repeatedly in short succession. The yaml-js and js-yaml libraries both default to permissive schemas in older versions, making this vulnerability easy to introduce during library upgrades that change default schema behavior.
Never use yaml.load() with DEFAULT_FULL_SCHEMA on untrusted or infrastructure-stored data. The !!js/function type is a direct code execution primitive. All YAML deserialization in production services must use FAILSAFE_SCHEMA or JSON_SCHEMA, or be replaced entirely with JSON.parse() for configuration data stored in infrastructure components like Redis.
// review aggregation config loaded from Redis as YAML with DEFAULT_FULL_SCHEMA
const yaml = require('js-yaml');
async function loadAggregateConfig() {
const raw = await redis.get('review:aggregation:config');
// DEFAULT_FULL_SCHEMA supports !!js/function — attacker injects RCE payload
return yaml.load(raw); // yaml.load defaults to DEFAULT_FULL_SCHEMA in js-yaml v3
}
// called on every review submission
async function onReviewSubmitted(reviewEvent) {
const config = await loadAggregateConfig();
await config.onRatingCompute(reviewEvent); // executes attacker function
}
// aggregation config loaded as JSON with Zod validation — no YAML deserialization
import { z } from 'zod';
const AggregateConfigSchema = z.object({
computeMethod: z.enum(['weighted_average', 'bayesian', 'wilson_score']),
minReviewsForRating: z.number().int().min(1).max(100),
weightDecayDays: z.number().min(0).max(365),
});
const COMPUTE_DISPATCH: Record Promise> = {
weighted_average: computeWeightedAverage,
bayesian: computeBayesian,
wilson_score: computeWilsonScore,
};
async function loadAggregateConfig() {
const raw = await redis.get('review:aggregation:config');
const parsed = AggregateConfigSchema.safeParse(JSON.parse(raw ?? '{}'));
if (!parsed.success) throw new Error('Invalid aggregation config');
return parsed.data;
}
async function onReviewSubmitted(reviewEvent: ReviewEvent) {
const config = await loadAggregateConfig();
const fn = COMPUTE_DISPATCH[config.computeMethod];
if (!fn) throw new Error('Unknown compute method');
return fn(reviewEvent); // named dispatch — no eval, no dynamic code
}
DESER45-002 — BSON Code eval() during rating computation from MongoDB
Severity: CRITICAL
The rating model stored in MongoDB includes a ratingComputeFn field that is deserialized as a BSON Code type. The MongoDB Node.js driver evaluates BSON Code objects by calling eval() on their string body when the driver encounters them during document deserialization. An attacker who can write to the ratings collection — through a NoSQL injection vulnerability, a compromised database credential, or a misconfigured MongoDB authentication configuration — can overwrite the ratingComputeFn field with a BSON Code payload. This payload is evaluated at every review completion event that triggers the rating aggregation pipeline, executing arbitrary JavaScript in the aggregation service process.
The promoteValues option in the MongoDB Node.js driver controls whether BSON extended types are promoted to native JavaScript types. When promoteValues is true (the default), BSON Code objects are silently promoted and evaluated. Setting promoteValues: false and explicitly rejecting any deserialized document that contains a Code instance prevents this attack class entirely.
BSON Code type deserialization is equivalent to eval(). Any MongoDB document field that contains a BSON Code value will be evaluated by the driver during deserialization. Rating model documents must be validated with a strict Zod schema that rejects any non-string field values before the document is used in computation logic.
// rating model from MongoDB — BSON Code type triggers eval() during deserialization
const { MongoClient } = require('mongodb');
const client = new MongoClient(process.env.MONGODB_URI); // promoteValues: true (default)
async function getRatingComputeFn(skillId) {
const model = await client.db().collection('rating_models').findOne({ skillId });
// if ratingComputeFn is a BSON Code object, driver promotes it via eval()
return model.ratingComputeFn; // attacker-controlled function body
}
async function onReviewCompleted(skillId, review) {
const fn = await getRatingComputeFn(skillId);
return fn(review); // executes attacker code
}
// rating model from MongoDB — promoteValues:false + Zod string-only + named dispatch
import { MongoClient, Code } from 'mongodb';
import { z } from 'zod';
const client = new MongoClient(process.env.MONGODB_URI!, {
promoteValues: false, // prevent BSON Code promotion/eval
});
const RatingModelSchema = z.object({
skillId: z.string(),
computeMethod: z.enum(['weighted_average', 'bayesian', 'wilson_score']),
parameters: z.record(z.string(), z.number()),
});
const COMPUTE_DISPATCH = { weighted_average, bayesian, wilson_score };
async function getRatingModel(skillId: string) {
const raw = await client.db().collection('rating_models').findOne({ skillId });
if (!raw) throw new Error('Rating model not found');
if (raw.ratingComputeFn instanceof Code) throw new Error('Illegal BSON Code in rating model');
const parsed = RatingModelSchema.safeParse(raw);
if (!parsed.success) throw new Error('Invalid rating model schema');
return parsed.data;
}
async function onReviewCompleted(skillId: string, review: ReviewEvent) {
const model = await getRatingModel(skillId);
const fn = COMPUTE_DISPATCH[model.computeMethod];
return fn(review, model.parameters);
}
DESER45-003 — MessagePack prototype pollution disabling review authentication
Severity: CRITICAL
The review event queue is stored in Redis as MessagePack-encoded data. The MessagePack decoder used by the pipeline does not create a null-prototype object as the deserialization target — it deserializes into a plain {} object literal, making the resulting object's prototype chain vulnerable to pollution. An attacker who can write to the Redis review event queue can inject a MessagePack payload that includes a __proto__ key with skipReviewAuth: true. When this key is deserialized and assigned to the target object, it pollutes Object.prototype, making ({}).skipReviewAuth evaluate to true for every plain object in the process — including the objects used by the authentication middleware to check whether review API requests require authentication.
The pollution persists for the lifetime of the Node.js process. Every subsequent review API request in the same process instance skips authentication, allowing unauthenticated users to submit reviews, modify existing reviews, delete reviews from competitors, or access review management endpoints that should require admin authentication. The only recovery path is a full process restart to clear the polluted prototype.
MessagePack deserialization without null-prototype target enables prototype pollution. Any deserialization format that merges key-value pairs into a plain JavaScript object is vulnerable to prototype pollution via __proto__ key injection. All deserialization targets must use Object.create(null) as the base, followed by strict Zod schema validation, to prevent prototype chain contamination.
// review event queue decoded from Redis as MessagePack — no null-prototype target
const msgpack = require('msgpack5')();
const redis = require('redis').createClient();
async function processReviewEvent() {
const raw = await redis.lpop('review:event:queue');
const event = msgpack.decode(Buffer.from(raw, 'base64'));
// if event contains __proto__: { skipReviewAuth: true }
// Object.prototype.skipReviewAuth is now true for all objects in process
return handleReviewEvent(event);
}
// in authentication middleware — checks polluted prototype property
function requireReviewAuth(req, res, next) {
if (req.skipReviewAuth) return next(); // bypassed after pollution
if (!req.session?.userId) return res.status(401).json({ error: 'Unauthorized' });
next();
}
// review event queue decoded from Redis as JSON with null-prototype safety + Zod
import { z } from 'zod';
const ReviewEventSchema = z.object({
skillId: z.string().uuid(),
reviewerId: z.string().uuid(),
rating: z.number().int().min(1).max(5),
body: z.string().max(5000),
submittedAt: z.string().datetime(),
}).strict(); // reject any extra keys including __proto__
async function processReviewEvent() {
const raw = await redis.lpop('review:event:queue');
if (!raw) return;
// JSON.parse is safe against __proto__ pollution in modern Node.js (v8 >= 7.1)
// but we also apply Zod strict() to reject unexpected keys
const rawObj = JSON.parse(raw);
// create null-prototype copy to be safe
const safeObj = Object.assign(Object.create(null), rawObj);
const parsed = ReviewEventSchema.safeParse(safeObj);
if (!parsed.success) {
await deadLetterQueue.push({ raw, error: parsed.error });
return;
}
return handleReviewEvent(parsed.data);
}
DESER45-004 — node-serialize IIFE gadget RCE in rating aggregation pipeline
Severity: CRITICAL
The rating aggregation pipeline uses node-serialize to deserialize aggregation job configurations. The node-serialize library supports immediately-invoked function expressions (IIFEs) via the _$$ND_FUNC$$_ marker. When the deserializer encounters a string value beginning with this marker, it wraps the string in a function call and evaluates it using eval(). An attacker who can inject data into the aggregation job queue — through a compromised queue producer, a NoSQL injection in the job scheduling endpoint, or a poisoned cache key — can craft a payload with a _$$ND_FUNC$$_-prefixed string that executes arbitrary code during deserialization. The payload is reachable from any authenticated consumer of the review pipeline API that can enqueue aggregation jobs.
Unlike the YAML and BSON Code vectors (DESER45-001, DESER45-002), the node-serialize IIFE vector does not require write access to a specific infrastructure component — it is exploitable by any API caller who can submit review data that eventually reaches the aggregation queue. This makes it the highest-reach vector in the DESER45 chain, with an attack surface spanning all authenticated review pipeline consumers including third-party review aggregation integrations.
node-serialize is an unsafe deserialization library. The _$$ND_FUNC$$_ IIFE gadget in node-serialize provides direct code execution via eval() during deserialization. This library must not be used for any untrusted or infrastructure-stored data. Replace all usages with JSON.parse() combined with Zod schema validation, and add a pre-deserialization check that rejects any payload containing the _$$ND_FUNC$$_ marker string.
// rating aggregation job deserialized with node-serialize — IIFE gadget RCE
const serialize = require('node-serialize');
async function processAggregationJob(jobPayload) {
// attacker payload: {"computeFn":"_$$ND_FUNC$$_(function(){require('child_process').exec('...')})()"}
const job = serialize.unserialize(jobPayload); // triggers eval() on IIFE
return runAggregation(job);
}
// queue consumer — reachable from any authenticated review pipeline API caller
reviewQueue.process(async (job) => {
await processAggregationJob(job.data.payload);
});
// rating aggregation job with JSON.parse + Zod + IIFE marker rejection
import { z } from 'zod';
const AggregationJobSchema = z.object({
skillId: z.string().uuid(),
windowStart: z.string().datetime(),
windowEnd: z.string().datetime(),
computeMethod: z.enum(['weighted_average', 'bayesian', 'wilson_score']),
}).strict();
const IIFE_MARKER = '_$$ND_FUNC$$_';
function safeDeserializeJob(raw: string) {
// reject node-serialize IIFE gadget payloads before any parsing
if (raw.includes(IIFE_MARKER)) {
throw new Error('Illegal serialization marker in aggregation job payload');
}
const rawObj = JSON.parse(raw);
const parsed = AggregationJobSchema.safeParse(rawObj);
if (!parsed.success) {
throw new Error(`Invalid aggregation job schema: ${parsed.error.message}`);
}
return parsed.data;
}
reviewQueue.process(async (job) => {
const data = safeDeserializeJob(job.data.payload);
await runAggregation(data);
});
All four SA-SKL-DESER45 vulnerabilities reflect a consistent pattern of unsafe deserialization practices across the review and rating aggregation pipeline, with each vector exploitable from a different position in the attack surface — from Redis infrastructure access to authenticated API consumers. SkillAudit detects DESER45-001 by flagging yaml.load() calls without explicit FAILSAFE_SCHEMA or JSON_SCHEMA; DESER45-002 by detecting promoteValues: true (or absent) in MongoClient options combined with dynamic field access on deserialized documents; DESER45-003 by detecting MessagePack decode calls without null-prototype target assignment followed by Zod validation; and DESER45-004 by flagging any import or require of the node-serialize package. See also SA-SKL-DESER44 on dependency resolution graph endpoints for the companion deserialization chain.
Compound attack chain: DESER45-003 → DESER45-001 → DESER45-002 → DESER45-004
The four DESER45 findings compose into a layered deserialization kill chain. An attacker first exploits DESER45-003 to inject a MessagePack payload into the review event queue that pollutes Object.prototype.skipReviewAuth = true. This disables authentication middleware for all subsequent review API requests in the affected process, giving the attacker unauthenticated access to review management endpoints.
With unauthenticated access to the review management API, the attacker can overwrite the Redis aggregation config key (DESER45-001) with a YAML payload containing a !!js/function RCE trigger at the onRatingCompute field. This payload fires on every subsequent review submission, establishing persistent code execution. Simultaneously, the attacker can overwrite the MongoDB rating model document (DESER45-002) with a BSON Code payload at the ratingComputeFn field, providing a second persistent RCE channel that fires at every rating aggregation event.
Finally, the attacker uses DESER45-004 to enqueue a node-serialize IIFE payload via the now-unauthenticated aggregation job API, achieving immediate RCE without waiting for the next review submission. The result is four simultaneous persistent RCE channels in the review and rating aggregation pipeline, each triggered by normal review activity and each attributable to legitimate pipeline events rather than obvious attack traffic.
SkillAudit detection
SkillAudit's static analysis rules detect all four DESER45 vulnerability classes during CI pipeline scanning. The YAML schema detector flags any yaml.load() or yaml.safeLoad() call without an explicit schema: yaml.FAILSAFE_SCHEMA or schema: yaml.JSON_SCHEMA option. The BSON Code detector flags MongoClient instantiations without promoteValues: false in options. The MessagePack prototype pollution detector flags msgpack.decode() calls that assign the result to a plain object without a subsequent Object.create(null) copy and Zod validation step. The node-serialize detector flags any import, require, or dynamic import of the node-serialize package anywhere in the codebase. All findings include remediation snippets and links to this advisory.