Claude MCP skill insecure deserialization — skill release and version publishing endpoints — SA-SKL-DESER37
SA-SKL-DESER37 documents four insecure deserialization vulnerabilities in MCP skill registry release and version publishing endpoints. Release and version publishing surfaces represent the final step of a skill's supply chain — they process configuration, metadata, event queues, and artifact data at high privilege with cloud storage credentials and registry publish keys in scope. YAML DEFAULT_FULL_SCHEMA deserialization of release configuration cached in Redis executes arbitrary JavaScript at every version publish event, propagating to all service instances sharing the same cache key. BSON Code deserialization of version metadata from MongoDB triggers eval() during the version validation step that runs before every install. MessagePack deserialization of the version publish event queue allows prototype pollution that disables authentication checks for all subsequent version API requests in the same process. And node-serialize deserialization of release artifact aggregation data achieves RCE reachable from any authenticated release consumer, with cloud storage and container registry credentials in scope.
yaml.load() with DEFAULT_FULL_SCHEMA on Redis-cached release config; !!js/function in releaseConfig.onVersionPublish achieves RCE at every version publish event; propagates to all service instances sharing same cache key; fix: FAILSAFE_SCHEMA; JSON for all release config; Zod ReleaseConfigSchema; named-event dispatch tableCode type at versionValidatorFn field triggers eval() during version validation; default MongoClient settings promote BSON Code silently; fix: reject BSON Code; promoteValues:false; Zod string-only schema; named-validator lookup__proto__.skipVersionAuth:true pollutes Object.prototype, disabling authentication checks for all subsequent version API requests in process; fix: null-prototype target; Zod strict(); JSON instead of MessagePacknode-serialize deserialization of release artifact aggregation data; IIFE gadget achieves RCE at aggregation time reachable from any authenticated release consumer; aggregation worker holds cloud storage keys and container registry credentials; fix: JSON.parse + Zod; detect and reject _$$ND_FUNC$$_ payloads; sealed config at deploy timeDESER37-001 — YAML RCE on release config executes arbitrary code at every version publish
Severity: CRITICAL
The release configuration document is stored in Redis as a YAML string and loaded with yaml.load(configYaml, { schema: yaml.DEFAULT_FULL_SCHEMA }). The DEFAULT_FULL_SCHEMA includes the !!js/function tag, which constructs a JavaScript Function object from its string argument and evaluates it during deserialization. An attacker who can write to the Redis cache key — via a compromised skill owner session, a Redis SSRF chain, or an unauthenticated Redis instance on an internal network segment — can inject a !!js/function payload at releaseConfig.onVersionPublish.
The injected function executes at every version publish event, on every service instance that reads from the same Redis key. Because release config is cached at service startup and refreshed on cache expiry, the RCE may persist across service restarts until the cache key is explicitly evicted. The release service process holds cloud storage write keys (for artifact upload), container registry push credentials, and npm publish tokens — all reachable from the injected function's execution context.
// release-config.js — loads release config from Redis cache
async function loadReleaseConfig(skillId) {
const configYaml = await redis.get(`release:config:${skillId}`);
if (!configYaml) return getDefaultConfig();
return yaml.load(configYaml, { schema: yaml.DEFAULT_FULL_SCHEMA });
// !!js/function in onVersionPublish executes at deserialization
}
// release-config.js — safe release config loading
const ReleaseConfigSchema = z.object({
onVersionPublish: z.enum(['notify', 'index', 'archive', 'none']),
artifactRetentionDays: z.number().int().min(1).max(365),
autoIndexLatest: z.boolean(),
});
async function loadReleaseConfig(skillId) {
const raw = await redis.get(`release:config:${skillId}`);
if (!raw) return getDefaultConfig();
const parsed = JSON.parse(raw); // JSON only, never YAML
return ReleaseConfigSchema.parse(parsed);
}
const VERSION_PUBLISH_HANDLERS = {
notify: notifySubscribers,
index: indexVersion,
archive: archiveVersion,
none: () => {},
};
async function onVersionPublish(skillId, version) {
const config = await loadReleaseConfig(skillId);
const handler = VERSION_PUBLISH_HANDLERS[config.onVersionPublish];
await handler(skillId, version); // dispatch table, not eval
}
DESER37-002 — BSON Code eval on version metadata triggers arbitrary code during version validation
Severity: CRITICAL
Version metadata documents stored in MongoDB include a versionValidatorFn field intended to hold the name of the validator to run before accepting an install. The default MongoClient configuration promotes BSON Code type objects to JavaScript functions via eval() when reading documents with code-type fields. An attacker who can write to the MongoDB collection — via a compromised admin session, a MongoDB injection in an adjacent endpoint, or direct database access — can store a BSON Code object at versionValidatorFn.
The injected code executes at every version validation step, which runs before every skill install across all users of the registry. Because version metadata is shared infrastructure, one malicious document triggers execution on behalf of every install request for that version — not just the attacker's own installs. The validation worker's execution context includes the registry's signing key, audit log write access, and install quota management credentials.
// version-validator.js — runs before every install
async function validateVersion(skillId, version) {
const meta = await db.collection('version_metadata').findOne({
skillId, version
}); // default MongoClient promotes BSON Code to Function
if (meta.versionValidatorFn) {
return meta.versionValidatorFn(skillId, version); // eval() path
}
return true;
}
// version-validator.js — safe version validation
const VALIDATORS = {
'semver-compat': validateSemverCompat,
'schema-v1': validateSchemaV1,
'signature-required': validateSignatureRequired,
};
const VersionMetaSchema = z.object({
skillId: z.string(),
version: z.string().regex(/^[0-9]+\.[0-9]+\.[0-9]+$/),
versionValidatorFn: z.enum(Object.keys(VALIDATORS)),
});
async function validateVersion(skillId, version) {
const raw = await db.collection('version_metadata').findOne(
{ skillId, version },
{ promoteValues: false } // reject BSON Code type
);
const meta = VersionMetaSchema.parse(raw);
const handler = VALIDATORS[meta.versionValidatorFn];
return handler(skillId, version);
}
BSON Code promotion is a silent eval(). MongoDB's default MongoClient configuration promotes Code BSON type to JavaScript functions and calls them when accessed as properties. Set promoteValues: false in your MongoClient options and use Zod string-only schemas for all fields that contain identifiers, names, or callable references.
DESER37-003 — MessagePack prototype pollution disables version authentication for entire process
Severity: CRITICAL
The version publish event queue is stored in Redis as MessagePack-encoded objects. The deserialization target is a plain object literal {}, which inherits from Object.prototype. A MessagePack payload containing __proto__ as a map key merges its values directly into Object.prototype, affecting every object created by the process for the remainder of its lifetime. An attacker who can write to the Redis event queue can inject {"__proto__": {"skipVersionAuth": true}}.
Once Object.prototype.skipVersionAuth is true, any authentication check in the version API that evaluates if (options.skipVersionAuth) or if (req.skipVersionAuth) — including those on newly created request objects — evaluates to true. This disables authentication for all subsequent version publish, install, and delete requests handled by the poisoned process, allowing unauthenticated access to private skill versions until the process restarts.
// version-queue.js — processes version publish events from Redis
async function processVersionEvent() {
const raw = await redis.lpop('version:publish:queue');
if (!raw) return;
const event = msgpack.decode(raw); // __proto__ pollution via map keys
if (event.skipVersionAuth) return processUnauthenticated(event);
await verifyVersionAuth(event);
await publishVersion(event);
}
// version-queue.js — safe version event processing
const VersionEventSchema = z.object({
skillId: z.string(),
version: z.string(),
publisherId: z.string(),
timestamp: z.number(),
}).strict(); // rejects unknown keys including __proto__
async function processVersionEvent() {
const raw = await redis.lpop('version:publish:queue');
if (!raw) return;
const decoded = JSON.parse(raw); // JSON instead of MessagePack
const event = VersionEventSchema.parse(
Object.assign(Object.create(null), decoded) // null-prototype target
);
await verifyVersionAuth(event);
await publishVersion(event);
}
DESER37-004 — node-serialize IIFE RCE on release artifact aggregation
Severity: CRITICAL
The release artifact aggregation worker deserializes aggregation records using node-serialize. The node-serialize library supports Immediately Invoked Function Expressions (IIFEs) via its _$$ND_FUNC$$_ marker: any string field containing _$$ND_FUNC$$_(function(){...})() is deserialized as a function and immediately invoked. An attacker who can write an aggregation record — via a compromised release consumer session or a write-side injection in the aggregation pipeline — can achieve RCE at aggregation time.
The aggregation worker runs with elevated privilege: it holds AWS S3 write keys for artifact storage, container registry push credentials for Docker image releases, and GitHub App tokens for release note publication. These credentials are available in the worker process's environment at the time the IIFE executes. The attack is reachable from any authenticated release consumer because aggregation records are written as part of the standard release flow.
// artifact-aggregator.js — aggregates release artifacts
const serialize = require('node-serialize');
async function aggregateArtifacts(releaseId) {
const records = await db.collection('artifact_records')
.find({ releaseId }).toArray();
return records.map(r => serialize.unserialize(r.data));
// _$$ND_FUNC$$_ gadget in r.data triggers RCE
}
// artifact-aggregator.js — safe artifact aggregation
const ArtifactRecordSchema = z.object({
releaseId: z.string(),
artifactType: z.enum(['source', 'binary', 'docker', 'npm']),
artifactUrl: z.string().url(),
checksum: z.string().regex(/^sha256:[0-9a-f]{64}$/),
sizeBytes: z.number().int().nonneg(),
});
function rejectNDFunc(raw) {
if (typeof raw === 'string' && raw.includes('_$$ND_FUNC$$_')) {
throw new Error('Rejected: node-serialize gadget detected');
}
return raw;
}
async function aggregateArtifacts(releaseId) {
const records = await db.collection('artifact_records')
.find({ releaseId }).toArray();
return records.map(r => {
rejectNDFunc(r.data);
return ArtifactRecordSchema.parse(JSON.parse(r.data));
});
}
Remediation summary
| Finding | Severity | Primary remediation | Secondary hardening |
|---|---|---|---|
| DESER37-001 | Critical | Replace yaml.load(DEFAULT_FULL_SCHEMA) with FAILSAFE_SCHEMA; migrate all release config to JSON; validate with Zod ReleaseConfigSchema | Named-event dispatch table; seal release config at deploy time; Redis key signing |
| DESER37-002 | Critical | Set promoteValues:false on MongoClient; validate all callable-name fields with Zod string enum; use named-validator lookup table | Reject BSON Code on ingest; schema migration to string-only fields |
| DESER37-003 | Critical | Replace MessagePack with JSON; deserialize into null-prototype objects; validate with Zod strict() | Reject any payload containing __proto__, constructor, or prototype keys before deserialization |
| DESER37-004 | Critical | Remove node-serialize; use JSON.parse + Zod; detect and reject _$$ND_FUNC$$_ marker before parsing | Sealed config at deploy time; aggregation worker credential rotation; least-privilege IAM for storage keys |
Find deserialization vulnerabilities like these before attackers do. SkillAudit scans your MCP skill registry release and version publishing endpoints for all four SA-SKL-DESER37 patterns plus the broader deserialization advisory series. See the SA-SKL-DESER36 CI/CD pipeline advisory and the SA-SKL-DESER35 review workflow advisory for related findings. Connect your repository at skillaudit.dev.