Claude MCP skill insecure deserialization — skill dependency resolution and lockfile generation endpoints — SA-SKL-DESER33
SA-SKL-DESER33 documents four critical insecure deserialization vulnerabilities in MCP skill registry dependency resolution and lockfile generation endpoints. All four findings achieve code execution or complete authentication bypass through unsafe deserialization of data read from intermediary stores — Redis, MongoDB, and third-party serialization libraries. DESER33-001 uses yaml.load with the DEFAULT_FULL_SCHEMA to execute an attacker-controlled !!js/function gadget embedded in the dependency resolver configuration retrieved from Redis, achieving RCE on every skill install. DESER33-002 triggers Node.js eval() through the BSON Code type deserialized from a MongoDB lockfile metadata document, executing during lockfile validation. DESER33-003 leverages MessagePack deserialization to perform prototype pollution via __proto__ injection in the dependency event queue, permanently disabling authentication checks for all subsequent dependency API requests in the worker process. DESER33-004 exploits node-serialize's IIFE gadget pattern in lockfile template aggregation, granting RCE to any authenticated dependency consumer who can influence template content in the registry store.
yaml.load() DEFAULT_FULL_SCHEMA; !!js/function in resolverConfig.onConflictResolve achieves RCE at dependency resolution time, firing on every installvalidateFn field triggers eval() during lockfile validation; fix: reject BSON Code; promoteValues:false; Zod string-only schema; named-validator lookup__proto__.skipDependencyAuth:true pollutes Object.prototype, disabling authentication checks for all subsequent dependency API requests in processDESER33-001 — yaml.load DEFAULT_FULL_SCHEMA RCE via resolver config function gadget firing on every install
The dependency resolver worker reads its conflict resolution configuration from a Redis key using the js-yaml library's yaml.load() function with the DEFAULT_FULL_SCHEMA (the default when no schema is specified). The DEFAULT_FULL_SCHEMA includes the !!js/function, !!js/regexp, and !!js/undefined YAML types that allow serialized JavaScript functions to be embedded in YAML documents and reconstructed at parse time. The resolverConfig.onConflictResolve field — a callback function invoked whenever the resolver encounters a version conflict between two skills that require different versions of the same dependency — is deserialized directly from this Redis key.
An attacker who can write to the Redis instance (via a Redis authentication bypass, SSRF to Redis, or compromised deployment pipeline) can replace the resolver config with a YAML document embedding a !!js/function gadget in the onConflictResolve field. This gadget executes when the resolver processes its first version conflict, which occurs during nearly every install of a skill with transitive dependencies. The execution context is the dependency resolver worker process, which typically runs with the service account credentials used for registry artifact publishing — meaning the RCE payload has access to registry push credentials, cloud storage tokens, and internal service endpoints.
The fire-on-every-install characteristic makes DESER33-001 particularly dangerous for persistence: even after the initial compromise is detected and the production registry process is restarted, the malicious resolver config remains in Redis and re-executes the payload whenever a new install triggers conflict resolution. The attacker achieves automatic re-compromise on each install until the Redis key is explicitly cleaned and the config is restored from a trusted source.
DESER33-001 fix: Replace yaml.load(resolverConfigYaml) with yaml.load(resolverConfigYaml, { schema: yaml.FAILSAFE_SCHEMA }) which restricts deserialized types to plain strings, sequences, and mappings — !!js/function is not representable. Better: store resolver config as JSON and parse with JSON.parse followed by Zod's ResolverConfigSchema. Replace the onConflictResolve callback with a named-strategy discriminated union: { strategy: 'newest' | 'oldest' | 'highest-semver' | 'lowest-semver' } dispatched through a server-side lookup table with no dynamic code evaluation.
// resolverConfig retrieved from Redis as YAML string
const resolverConfig = yaml.load(await redis.get('resolver:config'));
// resolverConfig.onConflictResolve may be !!js/function gadget
const resolution = resolverConfig.onConflictResolve(conflict);
const raw = await redis.get('resolver:config');
// Parse as JSON — no code types possible
const parsed = JSON.parse(raw);
// Validate shape — only allows known strategy strings
const resolverConfig = ResolverConfigSchema.parse(parsed);
// Dispatch via lookup table — no dynamic evaluation
const strategyFn = CONFLICT_STRATEGIES[resolverConfig.conflictStrategy];
if (!strategyFn) throw new Error('Unknown conflict strategy');
const resolution = strategyFn(conflict);
DESER33-002 — BSON Code type triggers eval() during lockfile validation via MongoDB document deserialization
The lockfile validation worker reads lockfile metadata documents from MongoDB using the Node.js MongoDB driver with default deserialization options. MongoDB's BSON format includes a Code type that represents serialized JavaScript functions — when the driver encounters a BSON Code value in a document, it reconstructs a JavaScript function object from the stored code string using internal evaluation. The lockfile metadata document stores a validateFn field that specifies how the lockfile's integrity should be verified: legitimate values are strings like "sha256" or "sha512" that are looked up in a validator dispatch table.
An attacker who can write to MongoDB (via injection, compromised migration script, or a registry administrative endpoint with insufficient validation) can store a BSON Code value in the validateFn field of any lockfile metadata document. When the validation worker next processes that lockfile, the MongoDB driver deserializes the Code type, triggering eval() of the attacker's payload during the validation phase. Because lockfile validation occurs on every dependency install and every lockfile integrity check, the payload executes repeatedly in the worker process context. The eval executes with the same permissions as the lockfile validation service account, which often includes read access to the full artifact store and write access to the lockfile generation pipeline.
DESER33-002 fix: Pass { promoteValues: false } to the MongoDB driver's find and findOne calls, which prevents automatic promotion of BSON Code to JavaScript Function objects. Additionally, validate the validateFn field with Zod's z.enum(['sha256', 'sha512', 'blake3']) before dispatch — any value that is not a known string key is rejected before it can reach the lookup table. Store lockfile metadata documents with an explicit JSON schema validation rule at the MongoDB collection level to prevent Code values from being inserted at all.
DESER33-003 — MessagePack prototype pollution via __proto__ in dependency event queue disables all process auth checks
The dependency event processing worker reads job payloads from a Redis queue where events are stored as MessagePack-encoded objects. The MessagePack decoder is configured to deserialize directly into plain JavaScript objects using Object.assign({}, decoded). When the decoded event payload contains a key named __proto__, the assignment propagates that key's value up to Object.prototype, affecting all subsequently created objects in the worker process. The specific payload { "__proto__": { "skipDependencyAuth": true } } sets Object.prototype.skipDependencyAuth = true, which causes every authentication check that tests if (req.context.skipDependencyAuth) to evaluate to true — bypassing dependency API authentication for all requests processed by the worker until it restarts.
Prototype pollution is especially dangerous in long-running worker processes because the polluted prototype persists across all requests handled by that process, not just the request that introduced the pollution. Every dependency API call processed by the affected worker after the poison payload is consumed operates without authentication verification — the pollution is effectively a process-wide authentication disable switch. In a horizontally scaled deployment where event queue workers auto-scale under load, an attacker can submit enough poison payloads to eventually pollute all running worker instances, achieving registry-wide dependency authentication bypass until the fleet is fully cycled.
DESER33-003 fix: Replace Object.assign({}, decoded) with Object.assign(Object.create(null), decoded) as the MessagePack decode target — a null-prototype object cannot pollute Object.prototype because it has no prototype chain. Additionally, validate the decoded payload against a Zod strict schema that rejects any keys not explicitly listed in the event schema; __proto__ and constructor keys will be rejected before they reach the assignment. For maximum safety, migrate event serialization from MessagePack to JSON — JSON.parse always creates prototype-safe plain objects — and apply the same Zod strict validation after parsing.
const buf = await redis.lpop('dep:events');
// MessagePack decode into plain object — __proto__ key pollutes prototype
const event = msgpack.decode(buf);
const job = Object.assign({}, event);
// All subsequent auth checks are bypassed if skipDependencyAuth was injected
await processDepEvent(job);
const buf = await redis.lpop('dep:events');
// Decode to null-prototype object — cannot pollute Object.prototype
const raw = msgpack.decode(buf, { target: Object.create(null) });
// Validate strict schema — rejects unknown keys including __proto__
const event = DepEventSchema.strict().parse(raw);
await processDepEvent(event);
DESER33-004 — node-serialize IIFE gadget in lockfile template aggregation achieves RCE from any authenticated consumer
The lockfile template aggregation service uses the node-serialize library to store and retrieve reusable lockfile templates — parameterized lockfile skeletons that skill publishers can define once and reuse across multiple skill versions. When a consumer requests lockfile generation, the aggregation service reads the relevant templates from the registry store, deserializes them with serialize.unserialize(), and merges them into the generated lockfile. The node-serialize library is known to execute Immediately Invoked Function Expressions (IIFEs) during deserialization: any value matching the pattern _$$ND_FUNC$$_function(){ ... }() is evaluated at unserialize time.
Any authenticated dependency consumer who has permission to create or update lockfile templates — a capability typically granted to all skill publishers — can store a template containing the IIFE gadget pattern. The next time the aggregation service processes a lockfile generation request that references that template, the IIFE executes in the aggregation service process. Because lockfile template aggregation is an on-demand operation triggered by dependency installation, the payload fires within seconds of a consumer submitting an install request that includes the poisoned template. The aggregation service typically runs with the same service account as the dependency resolution worker, providing access to registry push credentials and artifact store write permissions.
DESER33-004 fix: Remove node-serialize entirely. Store lockfile templates as JSON and parse with JSON.parse followed by Zod's LockfileTemplateSchema — JSON has no executable type primitives. Before parsing any stored template, scan the raw string for the _$$ND_FUNC$$_ marker and reject the document immediately if detected. Seal lockfile templates at deploy time by signing each template with an HMAC key held by the CI pipeline; the aggregation service verifies the signature before deserializing, preventing runtime template injection regardless of storage backend compromise.
SkillAudit scans your registry's dependency resolution and lockfile generation endpoints for all four DESER33 patterns, plus the other deserialization families documented in the SA-SKL-DESER series. Get started free — 3 audits/month on public repos, results in 60 seconds.