Insecure Deserialization in MCP Skill Registry Skill CI/CD Pipeline and Build Artifact Management Endpoints
SA-SKL-DESER74 documents four insecure deserialization vulnerabilities across the CI/CD pipeline integration and build artifact management surface of MCP skill registries. The findings span YAML RCE on pipeline callbacks, BSON Code eval on artifact validators, MessagePack prototype pollution disabling build auth, and node-serialize IIFE RCE on build status badges.
yaml.load() DEFAULT_FULL_SCHEMA; !!js/function gadget in pipelineConfig.onBuildSuccess achieves RCE at every successful CI build event triggered by any publisher pushing a commitBSON Code type at artifactValidatorFn field triggers eval() during artifact validation at every build completion__proto__.skipBuildAuth:true pollutes Object.prototype, disabling authentication for all subsequent build API requests in the same worker processnode-serialize; IIFE gadget achieves RCE at aggregation time, reachable from any user viewing the skill build status badgeDESER74-001 — yaml.load RCE via CI pipeline onBuildSuccess callback
The CI/CD pipeline worker retrieves pipeline configuration from Redis using yaml.load(config, { schema: yaml.DEFAULT_FULL_SCHEMA }). The DEFAULT_FULL_SCHEMA permits the !!js/function tag, which constructs a live JavaScript Function object during deserialization. An attacker who can write to the Redis key (via a compromised pipeline secret, Redis AUTH bypass, or a prior SSRF reaching the Redis endpoint) injects a !!js/function gadget in the pipelineConfig.onBuildSuccess field. The injected function executes in the Node.js process context at every successful build event — meaning every commit push from every publisher triggers the payload on the CI worker.
// DESER74-001 — VULNERABLE
const yaml = require('js-yaml');
const redis = require('./redis');
async function loadPipelineConfig(skillId) {
const raw = await redis.get(`pipeline:config:${skillId}`);
// VULNERABLE: DEFAULT_FULL_SCHEMA enables !!js/function deserialization → RCE
return yaml.load(raw, { schema: yaml.DEFAULT_FULL_SCHEMA });
}
async function onBuildSuccess(skillId, buildResult) {
const config = await loadPipelineConfig(skillId);
// config.onBuildSuccess is attacker-controlled !!js/function — executes here
if (config.onBuildSuccess) {
await config.onBuildSuccess(buildResult);
}
}
Persistent RCE triggered by every publisher commit: Every successful CI build calls onBuildSuccess. An attacker who injects the payload once receives code execution on the CI worker on every subsequent build — from every publisher — until the Redis key is cleaned. The worker process has access to registry secrets, database credentials, and artifact signing keys.
// DESER74-001 — FIXED
const yaml = require('js-yaml');
async function loadPipelineConfig(skillId) {
const raw = await redis.get(`pipeline:config:${skillId}`);
// FIXED: JSON_SCHEMA (or CORE_SCHEMA) — no !!js/function, !!js/regexp, or !!js/undefined
const config = yaml.load(raw, { schema: yaml.JSON_SCHEMA });
// FIXED: allowlist-validate — only plain-data fields accepted
return validatePipelineConfig(config); // throws if unexpected keys present
}
function validatePipelineConfig(config) {
const allowed = ['notifyUrl', 'artifactBucket', 'retryCount', 'timeoutSeconds'];
const keys = Object.keys(config ?? {});
const unexpected = keys.filter(k => !allowed.includes(k));
if (unexpected.length) throw new Error(`Unexpected config keys: ${unexpected}`);
return config;
}
DESER74-002 — BSON Code eval on build artifact validator field
The build artifact model is stored in MongoDB. When the artifact document is retrieved, Mongoose deserializes it using the native BSON driver. If the artifactValidatorFn field was stored as a BSON Code type (MongoDB's $code), the BSON driver reconstructs it as a JavaScript Code object. The validation step then calls eval(doc.artifactValidatorFn.code) to execute the validator. An attacker who can write to the MongoDB collection (via a compromised DB credential or a secondary NoSQL injection in the artifact creation path) stores a malicious $code payload in artifactValidatorFn. The payload executes in the Node.js worker context at every build completion for the targeted skill.
// DESER74-002 — VULNERABLE
const { BSON } = require('bson');
async function validateArtifact(skillId, artifactId) {
const doc = await db.collection('buildArtifacts').findOne({ _id: artifactId });
if (doc.artifactValidatorFn) {
// VULNERABLE: if artifactValidatorFn is BSON Code type, eval() executes attacker code
const result = eval(doc.artifactValidatorFn.code ?? doc.artifactValidatorFn);
if (!result) throw new Error('Artifact validation failed');
}
return doc;
}
// DESER74-002 — FIXED
async function validateArtifact(skillId, artifactId) {
const doc = await db.collection('buildArtifacts').findOne({ _id: artifactId });
// FIXED: reject documents where artifactValidatorFn is not a plain string enum
if (doc.artifactValidatorFn !== undefined) {
const allowed = ['checksum_sha256', 'checksum_sha512', 'size_limit_50mb'];
if (!allowed.includes(doc.artifactValidatorFn)) {
throw new Error(`Invalid artifactValidatorFn: ${doc.artifactValidatorFn}`);
}
// Dispatch to hardcoded validator logic — no dynamic code execution
return validators[doc.artifactValidatorFn](doc);
}
return doc;
}
DESER74-003 — MessagePack prototype pollution disabling build authentication
Build events are queued in Redis serialized as MessagePack. The consumer uses msgpack.decode(payload) without a custom key filter. MessagePack permits encoding an object with the key string "__proto__"; when decoded, the resulting object is merged via standard object spreading into the event record, polluting Object.prototype. An attacker who injects a build event containing {"__proto__": {"skipBuildAuth": true}} causes all subsequent requests in the same worker process to skip build authentication checks — because every plain object created after pollution inherits skipBuildAuth: true from the polluted prototype.
// DESER74-003 — VULNERABLE
const msgpack = require('@msgpack/msgpack');
async function processBuildEvent(rawPayload) {
// VULNERABLE: msgpack.decode without key sanitization — __proto__ pollution possible
const event = msgpack.decode(rawPayload);
const merged = { ...defaultEventShape, ...event }; // spreads __proto__ into prototype
// After pollution: merged.skipBuildAuth === true (from Object.prototype)
if (!merged.skipBuildAuth) {
await requireBuildAuth(merged.publisherId, merged.skillId);
}
await processBuild(merged);
}
// DESER74-003 — FIXED
const msgpack = require('@msgpack/msgpack');
async function processBuildEvent(rawPayload) {
const raw = msgpack.decode(rawPayload);
// FIXED: use Object.create(null) base and allowlist-copy known keys only
const event = Object.create(null);
const allowed = ['publisherId', 'skillId', 'commitSha', 'buildType', 'timestamp'];
for (const key of allowed) {
if (key in raw) event[key] = raw[key];
}
// FIXED: __proto__ never reaches Object.prototype — skipBuildAuth always false
await requireBuildAuth(event.publisherId, event.skillId);
await processBuild(event);
}
DESER74-004 — node-serialize IIFE RCE on build result aggregation
The build result aggregation service reads accumulated build results from a Redis queue serialized with node-serialize. The node-serialize library supports an IIFE gadget: any value wrapped in {"rce":"_$$ND_FUNC$$_function(){...}()"} executes immediately on deserialization. An attacker who can write to the Redis aggregation queue (via SSRF to Redis, a compromised aggregation worker token, or a NoSQL injection in the build result submission path) injects an IIFE payload. The payload executes when the aggregation worker reads the queue — triggered every time any user views the build status badge for the targeted skill, since the badge rendering path calls the aggregation endpoint.
// DESER74-004 — VULNERABLE
const serialize = require('node-serialize');
const redis = require('./redis');
async function aggregateBuildResults(skillId) {
const items = await redis.lrange(`build:results:${skillId}`, 0, -1);
return items.map(item => {
// VULNERABLE: node-serialize IIFE gadget executes at deserialization time
return serialize.unserialize(item);
});
}
// Called on every build badge render request — attacker payload fires for every viewer
router.get('/skills/:skillId/badge/build', async (req, res) => {
const results = await aggregateBuildResults(req.params.skillId);
res.json({ status: results.at(-1)?.status ?? 'unknown' });
});
RCE triggered by public badge renders: The build status badge endpoint is public and unauthenticated. Any visitor to a page embedding the badge triggers the aggregation path and fires the IIFE payload. High-traffic skills with widely-embedded badges deliver the attacker payload hundreds of times per hour across all aggregation worker processes.
// DESER74-004 — FIXED
// Replace node-serialize with JSON — no dynamic code execution on deserialization
async function aggregateBuildResults(skillId) {
const items = await redis.lrange(`build:results:${skillId}`, 0, -1);
return items.map(item => {
// FIXED: JSON.parse — no IIFE, no function reconstruction
const parsed = JSON.parse(item);
// FIXED: allowlist-validate result shape before use
return validateBuildResult(parsed);
});
}
function validateBuildResult(result) {
const allowed = ['status', 'commitSha', 'duration', 'timestamp'];
return Object.fromEntries(
Object.entries(result).filter(([k]) => allowed.includes(k))
);
}
Scan your MCP skill registry for SA-SKL-DESER74
SkillAudit detects unsafe deserialization paths in CI/CD pipelines, BSON Code eval patterns, prototype pollution vectors, and node-serialize IIFE gadgets in under 60 seconds.
Run a free audit