← Blog

Claude MCP skill zip slip, archive extraction path traversal, and zip bomb security — SA-SKL-UPLOAD7

Archive extraction in MCP skill deployments is a high-impact attack surface that is easy to get wrong. SA-SKL-UPLOAD7 covers four critical and high severity patterns: the classic zip-slip path traversal where a crafted zip entry uses ../ sequences to write files outside the extraction directory, potentially overwriting cron jobs or system configuration; the tar symlink attack where the archive first creates a symlink pointing to a sensitive target and then writes a file through it; the zip bomb that expands a tiny compressed file to tens of gigabytes to exhaust available disk space; and the null-byte filename injection that lets an attacker store a PHP web shell as an entry named shell.php\0.tar which the filesystem truncates to shell.php, bypassing any suffix-based extension filter. All four patterns have been exploited in real-world deployments; all four are detectable with static analysis and fixable with straightforward path validation and streaming size enforcement.

By SkillAudit  |  8 Nov 2026

Why archive extraction is a critical attack surface in MCP skills

MCP skills that accept archive uploads — ZIP, tar.gz, .tar.bz2, or similar — do so for legitimate reasons: batch processing of multiple files, delivery of compiled assets, transfer of project directories. The attack surface is large because a single archive upload can contain thousands of entries, any of which may carry a malicious filename, an unexpected entry type (symlink, device node, hardlink), or a compressed payload whose uncompressed size bears no relation to the uploaded file size. Node.js extraction libraries such as unzipper and the npm tar package do not validate entry paths by default; they extract whatever the archive describes. The developer's responsibility is to validate every entry before writing it to disk. SA-SKL-UPLOAD7 targets four of the most common gaps in that validation.

In a Claude MCP skill context, archive extraction vulnerabilities are especially severe because the skill often runs in an environment with elevated filesystem access — it may be processing uploads to serve as context for LLM analysis, writing outputs to shared storage, or extracting plugin code that the runtime will subsequently load. An arbitrary write primitive in this context can escalate to code execution (by writing to a cron directory, a Node module cache, or an SSH authorized_keys file), to data exfiltration (by writing a symlink to a sensitive path and then requesting the skill read it back), or to denial of service (by exhausting disk space with a decompression bomb).

SA-SKL-UPLOAD7 findings at a glance
CRITICALUPLOAD7-001 — unzipper extraction without path.resolve() validation; entry path ../../../../etc/cron.d/evil writes outside the extraction directory; fix: assert resolved path starts with outDir + path.sep
CRITICALUPLOAD7-002 — tar extraction follows symlinks; archive creates symlink pointing to /etc/passwd then second entry writes through it; fix: filter callback rejects all SymbolicLink entries before extraction
HIGHUPLOAD7-003 — Archive extraction does not limit total uncompressed size; 1 KB zip bomb expands to 10 GB filling disk; fix: stream with cumulative byte counter; abort and delete partial output on exceeding 50 MB limit
HIGHUPLOAD7-004 — Archive entry filename contains null byte (shell.php\0.tar); filesystem truncates to shell.php; extension filter sees .tar and allows it; fix: reject filenames containing null bytes or non-printable ASCII before extraction

UPLOAD7-001 — zip-slip path traversal via unzipper without path.resolve() validation

The zip-slip vulnerability was documented publicly in 2018 and affects a large number of archive libraries across all languages. In Node.js, the unzipper package exposes each entry's filename as entry.path without canonicalizing it. If the extraction code constructs the output path with simple string concatenation (e.g., path.join(outDir, entry.path)), an entry with path ../../../../etc/cron.d/evil will resolve to /etc/cron.d/evil on a standard Linux filesystem after the ../ sequences are resolved by the OS. The attacker controls the name and content of this file and can use it to write an executable cron job, overwrite an SSH configuration, or replace a Node.js module. The fix requires two lines: path.resolve(outDir, entry.path) to get the canonical absolute path after resolving all ../ components, followed by an assertion that the resolved path begins with outDir + path.sep. The path.sep suffix prevents a path like /var/uploads_evil from passing validation when outDir is /var/uploads.

// VULNERABLE — unzipper extraction with path.join; ../../../../ traversal not blocked
import unzipper from 'unzipper';
import path from 'path';
import fs from 'fs';

async function extractZip(zipPath, outDir) {
  const directory = await unzipper.Open.file(zipPath);
  for (const entry of directory.files) {
    // VULNERABLE: path.join normalises slashes but does NOT resolve ../ components
    // entry.path = '../../../../etc/cron.d/evil' becomes /etc/cron.d/evil on Linux
    const outputPath = path.join(outDir, entry.path);

    if (entry.type === 'Directory') {
      fs.mkdirSync(outputPath, { recursive: true });
    } else {
      // VULNERABLE: writes to outputPath which may be outside outDir
      entry.stream().pipe(fs.createWriteStream(outputPath));
    }
  }
}
// FIXED — path.resolve + startsWith check; directory traversal blocked before write
import unzipper from 'unzipper';
import path from 'path';
import fs from 'fs';
import stream from 'stream';
import { promisify } from 'util';

const pipeline = promisify(stream.pipeline);

// Maximum total uncompressed bytes (defence-in-depth; see UPLOAD7-003)
const MAX_UNCOMPRESSED_BYTES = 50 * 1024 * 1024;  // 50 MB

async function extractZip(zipPath, outDir) {
  // Canonicalize outDir itself — it may contain symlinks or ../ components
  const canonicalOutDir = fs.realpathSync(outDir);

  const directory = await unzipper.Open.file(zipPath);
  let totalBytes = 0;

  for (const entry of directory.files) {
    // FIXED: path.resolve resolves all ../ components absolutely
    const resolved = path.resolve(canonicalOutDir, entry.path);

    // FIXED: assert resolved path is inside outDir
    // path.sep suffix prevents /var/uploads matching /var/uploads_evil
    if (!resolved.startsWith(canonicalOutDir + path.sep) && resolved !== canonicalOutDir) {
      // Abort the entire extraction — a malicious archive should not be partially extracted
      throw new Error(\`Path traversal detected: "\${entry.path}" resolves outside extraction directory\`);
    }

    // Reject suspicious filename characters beyond path traversal
    if (/[\x00-\x1f]/.test(entry.path)) {
      throw new Error(\`Entry filename contains control characters: "\${entry.path}"\`);
    }

    if (entry.type === 'Directory') {
      fs.mkdirSync(resolved, { recursive: true });
    } else {
      fs.mkdirSync(path.dirname(resolved), { recursive: true });

      // Track uncompressed bytes as the stream flows; abort on bomb
      let entryBytes = 0;
      const countingTransform = new stream.Transform({
        transform(chunk, _enc, cb) {
          entryBytes += chunk.length;
          totalBytes += chunk.length;
          if (totalBytes > MAX_UNCOMPRESSED_BYTES) {
            cb(new Error(\`Archive exceeds maximum uncompressed size of \${MAX_UNCOMPRESSED_BYTES} bytes\`));
          } else {
            cb(null, chunk);
          }
        },
      });

      await pipeline(
        entry.stream(),
        countingTransform,
        fs.createWriteStream(resolved)
      );
    }
  }
}

Why path.join is not enough: path.join('/var/uploads', '../../../../etc/cron.d/evil') returns '/etc/cron.d/evil' on POSIX systems — it resolves the ../ components. path.resolve does the same but is explicit about working from an absolute base. The critical additional step is the startsWith check after resolution; without it you have the canonical path but no enforcement that it is inside the allowed directory.

UPLOAD7-002 — tar extraction follows symlinks enabling write-through attack

A tar archive can contain entries of several types: regular files, directories, symbolic links, hard links, and device nodes. The npm tar package extracts all of these by default. The symlink write-through attack works in two steps: the first entry in the archive creates a symbolic link at a path inside the extraction directory (e.g., extract/link pointing to /etc/passwd); the second entry in the archive writes a regular file to extract/link. Because the filesystem resolves the symlink when writing, the regular file's content is written to /etc/passwd. The process writing the archive must have write permission to the target, which is not always the case — but on many containerized skill deployments the process runs as root or as a user with broad filesystem access, making this a realistic privilege escalation path. The fix is a filter callback on the tar.extract call that checks the entry type and rejects all entries whose type is SymbolicLink (and optionally Link and CharacterDevice/BlockDevice/FIFO as well). The filter also performs path validation equivalent to UPLOAD7-001.

// VULNERABLE — tar.extract with no filter; symlink entries extracted and followed
import tar from 'tar';
import path from 'path';

async function extractTarGz(tarPath, outDir) {
  // VULNERABLE: no filter callback — symlinks, hardlinks, device nodes all extracted
  // Attack sequence:
  //   entry 1: type=SymbolicLink, path='extract/link', linkpath='/etc/passwd'
  //             → creates /outDir/extract/link → /etc/passwd
  //   entry 2: type=File, path='extract/link', data='attacker:x:0:0:...\n...'
  //             → writes through symlink to /etc/passwd
  await tar.extract({
    file: tarPath,
    cwd: outDir,
  });
}
// FIXED — filter rejects symlinks and device nodes; path traversal checked per entry
import tar from 'tar';
import path from 'path';
import fs from 'fs';

const MAX_UNCOMPRESSED_BYTES = 50 * 1024 * 1024;  // 50 MB
let totalExtractedBytes = 0;

async function extractTarGz(tarPath, outDir) {
  const canonicalOutDir = fs.realpathSync(outDir);
  totalExtractedBytes = 0;

  await tar.extract({
    file: tarPath,
    cwd: canonicalOutDir,

    // filter is called for each entry before extraction begins
    // Returning false causes the entry to be skipped entirely
    filter: (entryPath, stat) => {
      // FIXED: reject symbolic links unconditionally
      if (stat.type === 'SymbolicLink') {
        console.warn(\`[UPLOAD7-002] Skipping symlink entry: "\${entryPath}"\`);
        return false;
      }

      // FIXED: reject hard links — can point outside outDir via inode sharing
      if (stat.type === 'Link') {
        console.warn(\`[UPLOAD7-002] Skipping hardlink entry: "\${entryPath}"\`);
        return false;
      }

      // FIXED: reject device nodes and FIFOs — no valid use case in archive uploads
      if (['CharacterDevice', 'BlockDevice', 'FIFO'].includes(stat.type)) {
        console.warn(\`[UPLOAD7-002] Skipping device/FIFO entry: "\${entryPath}"\`);
        return false;
      }

      // FIXED: path traversal check — resolve the full path and assert it is inside outDir
      const resolved = path.resolve(canonicalOutDir, entryPath);
      if (!resolved.startsWith(canonicalOutDir + path.sep) && resolved !== canonicalOutDir) {
        throw new Error(\`Path traversal in tar entry: "\${entryPath}" resolves to "\${resolved}"\`);
      }

      // FIXED: reject control characters in filenames (see UPLOAD7-004)
      if (/[\x00-\x1f]/.test(entryPath)) {
        throw new Error(\`Control character in tar entry filename: "\${entryPath}"\`);
      }

      return true;  // allow this entry
    },

    // onentry lets us track uncompressed bytes for zip-bomb defence (UPLOAD7-003)
    onentry: (entry) => {
      entry.on('data', (chunk) => {
        totalExtractedBytes += chunk.length;
        if (totalExtractedBytes > MAX_UNCOMPRESSED_BYTES) {
          entry.destroy(new Error(\`Archive exceeds maximum uncompressed size\`));
        }
      });
    },
  });
}

UPLOAD7-003 — Decompression bomb exhausts disk space

A decompression bomb (also called a zip bomb) exploits the fact that highly repetitive data compresses to a tiny fraction of its original size. A classic zip bomb consists of a single file containing billions of null bytes; the compressed representation of a file of all zeros can be under 1 KB while the uncompressed content is 10 GB or more. Nested zip bombs (archives within archives) multiply this effect further. When an MCP skill extracts an uploaded archive without enforcing a limit on the total uncompressed output size, an attacker can upload a 1 KB file and cause the skill's container to exhaust all available disk space. On shared infrastructure this triggers an out-of-disk condition for other tenants or services sharing the same volume. The correct fix is to instrument the extraction stream with a byte counter that accumulates across all entries and aborts extraction — cleaning up the partial output directory — if the total exceeds a reasonable limit. For most skill use cases, 50 MB is a generous limit that accommodates legitimate project archives while blocking practical decompression bombs. The limit should be configurable per plan tier so paying customers can upload larger archives up to a hard maximum.

// VULNERABLE — no byte counter; 1 KB bomb expands to 10 GB filling disk
import unzipper from 'unzipper';
import path from 'path';
import fs from 'fs';
import stream from 'stream';
import { promisify } from 'util';

const pipeline = promisify(stream.pipeline);

async function extractZip(zipPath, outDir) {
  const directory = await unzipper.Open.file(zipPath);
  for (const entry of directory.files) {
    const outputPath = path.resolve(outDir, entry.path);  // path traversal fixed
    if (entry.type === 'Directory') {
      fs.mkdirSync(outputPath, { recursive: true });
    } else {
      // VULNERABLE: stream flows unbounded — no size check
      // A 1 KB zip bomb expands to gigabytes; disk exhausted before loop ends
      await pipeline(entry.stream(), fs.createWriteStream(outputPath));
    }
  }
}
// FIXED — streaming byte counter; extraction aborted and partial output deleted on limit
import unzipper from 'unzipper';
import path from 'path';
import fs from 'fs';
import stream from 'stream';
import { promisify } from 'util';

const pipeline = promisify(stream.pipeline);

const DEFAULT_MAX_BYTES = 50 * 1024 * 1024;  // 50 MB default

async function extractZip(zipPath, outDir, maxUncompressedBytes = DEFAULT_MAX_BYTES) {
  const canonicalOutDir = fs.realpathSync(outDir);
  const directory = await unzipper.Open.file(zipPath);
  let totalBytes = 0;

  // Check zip64 header fields for declared uncompressed sizes before any extraction
  // This fast-path check catches naive bombs without streaming every byte
  const declaredTotal = directory.files.reduce((sum, e) => sum + (e.uncompressedSize ?? 0), 0);
  if (declaredTotal > maxUncompressedBytes) {
    throw new Error(
      \`Archive declares \${declaredTotal} uncompressed bytes, exceeding limit of \${maxUncompressedBytes}\`
    );
  }

  // Even if declared sizes look fine, enforce the limit during streaming
  // (a malicious archive can lie about declared sizes)
  for (const entry of directory.files) {
    const resolved = path.resolve(canonicalOutDir, entry.path);
    if (!resolved.startsWith(canonicalOutDir + path.sep) && resolved !== canonicalOutDir) {
      throw new Error(\`Path traversal: "\${entry.path}"\`);
    }
    if (/[\x00-\x1f]/.test(entry.path)) {
      throw new Error(\`Control character in filename: "\${entry.path}"\`);
    }

    if (entry.type === 'Directory') {
      fs.mkdirSync(resolved, { recursive: true });
      continue;
    }

    fs.mkdirSync(path.dirname(resolved), { recursive: true });

    // FIXED: counting transform accumulates bytes; throws if limit exceeded
    const countingTransform = new stream.Transform({
      transform(chunk, _enc, cb) {
        totalBytes += chunk.length;
        if (totalBytes > maxUncompressedBytes) {
          cb(new Error(
            \`Decompression bomb: extraction exceeded \${maxUncompressedBytes} bytes limit\`
          ));
        } else {
          cb(null, chunk);
        }
      },
    });

    try {
      await pipeline(entry.stream(), countingTransform, fs.createWriteStream(resolved));
    } catch (err) {
      // FIXED: clean up partial output so the bomb does not leave gigabytes on disk
      fs.rmSync(outDir, { recursive: true, force: true });
      throw err;
    }
  }
}

// Upload handler — apply limit based on account plan tier
app.post('/api/upload', authenticate, async (req, res) => {
  const plan = req.user?.plan ?? 'free';
  const maxBytes = plan === 'team' ? 500 * 1024 * 1024
                 : plan === 'pro'  ? 100 * 1024 * 1024
                 :                     50 * 1024 * 1024;  // free tier

  const outDir = path.join(UPLOAD_TMP_DIR, req.uploadId);
  fs.mkdirSync(outDir, { recursive: true });

  try {
    await extractZip(req.savedFilePath, outDir, maxBytes);
    res.json({ extracted: true, outDir });
  } catch (err) {
    res.status(400).json({ error: err.message });
  }
});

Declared vs actual sizes: Always check both the declared uncompressed size fields in the zip central directory header AND enforce a streaming byte limit during actual extraction. A malicious archive can set header fields to zero or to small values while containing highly compressible data. The header check is a cheap fast-path; the streaming check is the actual enforcement.

UPLOAD7-004 — Null-byte filename injection bypasses extension filter

Many archive extraction routines include an extension allowlist or blocklist to prevent execution of uploaded files. A common blocklist rejects entries whose filename ends in .php, .py, .sh, .exe, or similar extensions. The null-byte injection bypasses this by embedding a null byte in the filename: the archive entry is stored with path shell.php\x00.tar. The extension filter inspects the full string and sees the terminal extension .tar which is on the allowlist. When the filesystem call receives this path, the C standard library function used under the hood (such as open(2) on Linux) truncates the string at the first null byte, creating the file as shell.php. Node.js's fs.createWriteStream passes the path to the OS in a Buffer, and on Linux the null byte terminates the filename at the kernel level, leaving a PHP file on disk. The attacker can then trigger execution of this file if the extraction directory is served by a PHP-capable web server or if the file is subsequently loaded by the skill runtime. The fix is a single regular expression check applied to every entry filename before any path resolution or file creation: reject any filename containing ASCII control characters in the range \x00-\x1f. This blocks null bytes, carriage returns, newlines, and other control characters that have no legitimate place in an uploaded filename.

// VULNERABLE — extension blocklist checks suffix; null byte makes .php pass as .tar
import path from 'path';
import fs from 'fs';

const BLOCKED_EXTENSIONS = new Set(['.php', '.py', '.sh', '.exe', '.rb', '.pl']);

function isSafeEntry(entryPath) {
  const ext = path.extname(entryPath).toLowerCase();
  // VULNERABLE: ext = '.tar' because path.extname sees the full string including null byte
  // But the OS will truncate at the null byte and create shell.php on disk
  return !BLOCKED_EXTENSIONS.has(ext);
}

// entry.path = 'shell.php\x00.tar'  → isSafeEntry returns true → file created as shell.php
async function extractEntry(entry, outDir) {
  if (!isSafeEntry(entry.path)) {
    throw new Error(\`Blocked file extension: "\${entry.path}"\`);
  }
  const outputPath = path.resolve(outDir, entry.path);  // resolved to .../shell.php on disk
  await pipeline(entry.stream(), fs.createWriteStream(outputPath));
}
// FIXED — control character check applied before any path operations; null byte rejected
import path from 'path';
import fs from 'fs';
import stream from 'stream';
import { promisify } from 'util';

const pipeline = promisify(stream.pipeline);

const BLOCKED_EXTENSIONS = new Set(['.php', '.py', '.sh', '.exe', '.rb', '.pl', '.cgi']);

function validateEntryFilename(entryPath) {
  // FIXED: check for null bytes and all other ASCII control characters first,
  // before any other processing. Control characters have no valid use in archive filenames.
  if (/[\x00-\x1f\x7f]/.test(entryPath)) {
    throw new Error(
      \`Archive entry filename contains control character (possible null-byte injection): "\${
        JSON.stringify(entryPath)  // JSON stringify makes the null byte visible in logs
      }"\`
    );
  }

  // FIXED: also reject entries with backslash path separators (Windows-style traversal)
  if (entryPath.includes('\\\\')) {
    throw new Error(\`Archive entry filename contains backslash: "\${entryPath}"\`);
  }

  // Extension check runs AFTER the control character check so it operates on a clean string
  const ext = path.extname(entryPath).toLowerCase();
  if (BLOCKED_EXTENSIONS.has(ext)) {
    throw new Error(\`Archive entry has blocked extension "\${ext}": "\${entryPath}"\`);
  }

  // Additional check: reject double extensions like archive.php.tar which may confuse
  // some web servers into treating the file as PHP
  const parts = path.basename(entryPath).split('.');
  if (parts.length > 2) {
    for (const part of parts.slice(1, -1)) {
      if (BLOCKED_EXTENSIONS.has('.' + part.toLowerCase())) {
        throw new Error(
          \`Archive entry has embedded blocked extension ".\${part}": "\${entryPath}"\`
        );
      }
    }
  }
}

async function extractEntry(entry, outDir) {
  // FIXED: validate filename before any path.resolve or fs call
  validateEntryFilename(entry.path);

  const canonicalOutDir = fs.realpathSync(outDir);
  const resolved = path.resolve(canonicalOutDir, entry.path);

  if (!resolved.startsWith(canonicalOutDir + path.sep)) {
    throw new Error(\`Path traversal: "\${entry.path}"\`);
  }

  fs.mkdirSync(path.dirname(resolved), { recursive: true });
  await pipeline(entry.stream(), fs.createWriteStream(resolved));
}

How SkillAudit detects SA-SKL-UPLOAD7

SkillAudit's static analysis scans MCP skill repositories for all four UPLOAD7 patterns. For UPLOAD7-001, the scanner identifies unzipper usage and checks whether path.resolve is called on the entry path, followed by a startsWith assertion against the output directory; absence of either step is flagged. For UPLOAD7-002, the scanner detects tar.extract calls and checks for a filter callback that references stat.type with a comparison to SymbolicLink; calls without such a filter are flagged. For UPLOAD7-003, the scanner looks for extraction loops (iterating over directory.files or responding to tar entry events) and checks for a byte accumulator variable that is compared against a size constant; loops without an accumulator comparison are flagged. For UPLOAD7-004, the scanner checks whether entry path strings are tested against a control-character regex (/[\x00-\x1f]/ or equivalent) before being passed to path.resolve or fs.createWriteStream; absence is flagged.

FindingSeverityVulnerable patternFix
UPLOAD7-001Criticalunzipper extraction without path.resolve + startsWith check; ../../../../etc/cron.d/evil entry writes outside extraction directorypath.resolve(outDir, entry.path); assert resolved.startsWith(canonicalOutDir + path.sep); abort entire extraction on first violation
UPLOAD7-002Criticaltar.extract without filter callback; symlink entry creates /outDir/link -> /etc/passwd; second entry writes through itfilter: (p, stat) => stat.type !== 'SymbolicLink'; also reject Link, CharacterDevice, BlockDevice, FIFO; validate entry path in same callback
UPLOAD7-003HighNo uncompressed size limit; 1 KB zip bomb expands to 10 GB; partial extraction left on disk after abortCheck declared sizes in zip header; stream through byte-counting transform; abort + rmSync(outDir) on exceeding limit; configure per-plan limit (50 MB free, 100 MB pro, 500 MB team)
UPLOAD7-004HighNull byte in archive entry path shell.php\x00.tar; extension filter sees .tar; filesystem truncates to shell.phpReject any entry path containing /[\x00-\x1f\x7f]/ before path resolution or extension check; also reject double extensions with blocked inner suffixes

Run SA-SKL-UPLOAD7 on your skill: Paste your MCP skill's GitHub URL at skillaudit.dev to get a full scan alongside all other SkillAudit checks. The free tier covers public repositories and returns a shareable security badge for your README.