← Blog

Claude skill file upload path traversal and symlink attack in ZIP processing — SA-SKL-UPLOAD4

MCP skills that accept ZIP archives for skill package uploads are exposed to a class of archive extraction vulnerabilities that have been exploited in production systems for over a decade. SA-SKL-UPLOAD4 covers four ZIP processing attack patterns: ZIP slip path traversal via ../../../etc/passwd entry names that escape the extraction directory; symlinks inside ZIPs whose targets are not validated and can point outside the extraction root; ZIP bombs that use nested archives or high compression ratios to exhaust memory or disk; and execution permission bits that are preserved on extracted shell scripts, enabling code execution if the extracted path is served or executed.

By SkillAudit  |  7 Nov 2026

Why ZIP archive extraction is a high-risk operation in MCP skills

MCP skills that audit GitHub repositories or accept uploaded skill packages commonly need to extract ZIP archives — either downloaded from GitHub's archive API or uploaded directly by users. Node.js's built-in fs module and common ZIP libraries like unzipper, adm-zip, and jszip handle the extraction logic, but they do not provide path traversal or symlink validation out of the box. The developer must explicitly check that each extracted entry resolves within the intended extraction directory. Failing to do so allows an attacker who controls the ZIP archive contents to write arbitrary files anywhere the Node.js process has write access — which on a typical container deployment includes application source files, configuration, and in some cases system files.

The severity depends on what the extracted path overwrites. Writing to ../../../app/routes/admin.js could replace application code and introduce a backdoor. Writing to ../../../.env could overwrite environment variables including API keys and database credentials. Writing to ../../../.ssh/authorized_keys on a VM with an exposed SSH port could add an attacker's public key for persistent access.

SA-SKL-UPLOAD4 in scope: UPLOAD4-001 (ZIP slip — path traversal via ../../../etc/passwd entry name, path.join() without bounds check), UPLOAD4-002 (symlink in ZIP — symlink target not validated against extractDir, escapes extraction root), UPLOAD4-003 (ZIP bomb — high-compression nested archive causes OOM or disk exhaustion during extraction), UPLOAD4-004 (executable bit preserved on extracted files — uploaded .sh file retains +x permission after extraction). Each finding includes SkillAudit detection and correct Node.js fixes.

UPLOAD4-001 — ZIP slip path traversal via entry name containing ../

The ZIP slip vulnerability exploits the fact that ZIP archive entry names can contain directory separators and .. path components. A malicious archive contains an entry with a name like ../../../../etc/cron.d/backdoor. When the extraction code constructs the output path with path.join(extractDir, entry.path), the resulting path is /tmp/extract-abc123/../../../../etc/cron.d/backdoor which Node.js's fs module resolves to /etc/cron.d/backdoor. The file is written to the cron directory rather than the intended extraction directory. If the entry name contains a Windows-style path separator (\) instead of Unix-style (/), libraries that normalize separators will also traverse upward.

The fix requires using path.resolve() rather than path.join() (which does not normalize .. components when the base path itself contains them) and then verifying that the resolved path starts with the extraction directory path using a prefix check. The prefix must include a trailing slash to prevent /tmp/extract-abc123 from accepting /tmp/extract-abc123-other/evil.

// VULNERABLE — path.join() without bounds check allows ZIP slip
import unzipper from 'unzipper';
import path from 'path';
import fs from 'fs';

async function extractZip(zipPath: string, extractDir: string): Promise<void> {
  const zip = await unzipper.Open.file(zipPath);

  for (const entry of zip.files) {
    // VULNERABLE: path.join does NOT resolve '../' against an absolute base
    // path.join('/tmp/extract-abc123', '../../../../etc/cron.d/backdoor')
    // → '/etc/cron.d/backdoor'  (path traversal!)

    // On Windows, also vulnerable to backslash:
    // path.join('/tmp/extract', '..\\..\\windows\\system32\\evil')
    const outputPath = path.join(extractDir, entry.path);

    if (entry.type === 'Directory') {
      fs.mkdirSync(outputPath, { recursive: true });
    } else {
      const content = await entry.buffer();
      fs.mkdirSync(path.dirname(outputPath), { recursive: true });
      fs.writeFileSync(outputPath, content);
    }
  }
}
// FIXED — path.resolve() + startsWith() bounds check on every entry
import unzipper from 'unzipper';
import path from 'path';
import fs from 'fs';

function safeExtractPath(extractDir: string, entryPath: string): string {
  // Normalize the extractDir to an absolute resolved path with trailing slash
  // The trailing slash prevents '/tmp/abc' from accepting '/tmp/abc-other/evil'
  const normalizedBase = path.resolve(extractDir) + path.sep;

  // Normalize separators: replace Windows backslash with forward slash
  const normalizedEntry = entryPath.replace(/\\/g, '/');

  // path.resolve() with the base and entry — resolves '../' components
  const resolvedPath = path.resolve(extractDir, normalizedEntry);

  // Check that the resolved path is within the extraction directory
  if (!resolvedPath.startsWith(normalizedBase)) {
    throw new Error(
      `ZIP slip detected: entry path '${entryPath}' resolves to '${resolvedPath}' ` +
      `which is outside the extraction directory '${extractDir}'`
    );
  }

  return resolvedPath;
}

const MAX_ENTRIES = 1000;
const MAX_UNCOMPRESSED_BYTES = 100 * 1024 * 1024;  // 100 MB

async function extractZipSafe(zipPath: string, extractDir: string): Promise<void> {
  fs.mkdirSync(extractDir, { recursive: true });

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

  // Check entry count before extracting
  if (zip.files.length > MAX_ENTRIES) {
    throw new Error(`ZIP archive has too many entries (${zip.files.length} > ${MAX_ENTRIES})`);
  }

  let totalUncompressedBytes = 0;

  for (const entry of zip.files) {
    // Validate path before extraction — throws on traversal attempt
    let outputPath: string;
    try {
      outputPath = safeExtractPath(extractDir, entry.path);
    } catch (err) {
      // Log the malicious entry and skip or abort
      console.error(`Rejected malicious ZIP entry: ${(err as Error).message}`);
      throw err;  // Abort the entire extraction — partial extraction may be inconsistent
    }

    // Check for symlinks before reading content (UPLOAD4-002)
    if (entry.type === 'SymbolicLink') {
      // Handled in UPLOAD4-002 fix below
      throw new Error(`ZIP entry '${entry.path}' is a symlink — symlinks not permitted in uploaded archives`);
    }

    if (entry.type === 'Directory') {
      fs.mkdirSync(outputPath, { recursive: true });
    } else {
      const content = await entry.buffer();

      // Check cumulative uncompressed size (ZIP bomb defense — UPLOAD4-003)
      totalUncompressedBytes += content.length;
      if (totalUncompressedBytes > MAX_UNCOMPRESSED_BYTES) {
        throw new Error(`ZIP bomb detected: total uncompressed size exceeds ${MAX_UNCOMPRESSED_BYTES} bytes`);
      }

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

      // Write file — force permissions 0o644 (UPLOAD4-004 fix)
      fs.writeFileSync(outputPath, content, { mode: 0o644 });
    }
  }
}
CRITICAL
SA-SKL-UPLOAD4-001 — An MCP skill extracts ZIP archive entries using path.join(extractDir, entry.path) without validating that the resolved path remains within the extraction directory — an attacker whose ZIP contains an entry named ../../../../etc/cron.d/backdoor can write arbitrary files to any path writable by the Node.js process, potentially overwriting application code, .env credentials, or cron jobs; fix by using path.resolve(extractDir, entry.path) and asserting that the result starts with path.resolve(extractDir) + path.sep before writing any file. Detection: SkillAudit flags ZIP extraction code that calls path.join() with an archive entry path without a subsequent startsWith() bounds check on the resolved output path.

UPLOAD4-002 — Symlink inside ZIP escapes extraction directory

ZIP archives can contain symbolic link entries — entries where the entry data is the symlink target path rather than file content. When an extraction library creates a symlink from the entry data, the symlink target is not validated against the extraction directory by default. An attacker crafts a ZIP where entry skill/data is a symlink pointing to /etc. After extraction, {extractDir}/skill/data is a symlink to /etc. Any subsequent operation that reads {extractDir}/skill/data/passwd is actually reading /etc/passwd. If the skill's audit logic reads all files within {extractDir}/skill/ recursively — for example, to scan for security patterns — it will follow the symlink and read arbitrary filesystem paths outside the extraction directory.

The simplest fix is to reject all symlinks in uploaded archives. Symlinks are almost never needed for skill packages — the archive should contain regular files. If symlinks must be supported, the symlink target must itself be validated: resolve the symlink target relative to the directory containing the symlink entry and verify that the resulting absolute path falls within the extraction root.

// VULNERABLE — symlinks extracted without target validation
import unzipper from 'unzipper';
import path from 'path';
import fs from 'fs';

async function extractZipVulnerable(zipPath: string, extractDir: string): Promise<void> {
  const zip = await unzipper.Open.file(zipPath);

  for (const entry of zip.files) {
    const outputPath = path.join(extractDir, entry.path); // Also ZIP slip vulnerable

    if (entry.type === 'SymbolicLink') {
      // VULNERABLE: reads symlink target from ZIP entry data
      // attacker ZIP entry: { path: 'skill/data', type: 'SymbolicLink', data: '/etc' }
      // fs.symlinkSync creates: {extractDir}/skill/data → /etc
      // Then: fs.readFileSync('{extractDir}/skill/data/passwd') === /etc/passwd content
      const symlinkTarget = (await entry.buffer()).toString();
      fs.mkdirSync(path.dirname(outputPath), { recursive: true });
      fs.symlinkSync(symlinkTarget, outputPath);  // Unvalidated target!
    } else if (entry.type === 'Directory') {
      fs.mkdirSync(outputPath, { recursive: true });
    } else {
      const content = await entry.buffer();
      fs.writeFileSync(outputPath, content);
    }
  }

  // After extraction, recursive scan follows the symlink:
  // {extractDir}/skill/data/passwd → /etc/passwd (attacker reads system files)
  scanDirectory(extractDir);  // Follows symlinks by default
}
// FIXED — symlinks rejected entirely; if needed, validate target within extractDir
import unzipper from 'unzipper';
import path from 'path';
import fs from 'fs';

async function extractZipSafe(zipPath: string, extractDir: string): Promise<void> {
  const resolvedExtractDir = path.resolve(extractDir);
  const extractDirPrefix = resolvedExtractDir + path.sep;

  fs.mkdirSync(extractDir, { recursive: true });

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

  for (const entry of zip.files) {
    // Bounds-check entry path (UPLOAD4-001 fix)
    const resolvedOutput = path.resolve(extractDir, entry.path.replace(/\\/g, '/'));
    if (!resolvedOutput.startsWith(extractDirPrefix)) {
      throw new Error(`ZIP slip: ${entry.path} escapes extraction directory`);
    }

    if (entry.type === 'SymbolicLink') {
      // Option A: Reject all symlinks — simple and safe for skill packages
      throw new Error(
        `ZIP entry '${entry.path}' is a symbolic link. ` +
        'Symlinks are not permitted in uploaded skill archives. ' +
        'Replace symlinks with hard copies of the target files.'
      );

      // Option B (if symlinks must be supported): validate target within extractDir
      // const symlinkTarget = (await entry.buffer()).toString().trim();
      // const symlinkDir = path.dirname(resolvedOutput);
      // const resolvedTarget = path.resolve(symlinkDir, symlinkTarget);
      // if (!resolvedTarget.startsWith(extractDirPrefix)) {
      //   throw new Error(
      //     `Symlink '${entry.path}' target '${symlinkTarget}' resolves to '${resolvedTarget}' ` +
      //     `outside extraction directory '${extractDir}'`
      //   );
      // }
      // fs.mkdirSync(path.dirname(resolvedOutput), { recursive: true });
      // fs.symlinkSync(symlinkTarget, resolvedOutput);
    } else if (entry.type === 'Directory') {
      fs.mkdirSync(resolvedOutput, { recursive: true });
    } else {
      const content = await entry.buffer();
      fs.mkdirSync(path.dirname(resolvedOutput), { recursive: true });
      fs.writeFileSync(resolvedOutput, content, { mode: 0o644 });  // UPLOAD4-004 fix
    }
  }

  // When scanning extracted files, never follow symlinks
  // Use fs.lstatSync() (not fs.statSync()) to avoid following symlinks
  // Use { withFileTypes: true } and check dirent.isSymbolicLink()
  scanDirectoryNoFollowLinks(resolvedExtractDir);
}

function scanDirectoryNoFollowLinks(dir: string): string[] {
  const files: string[] = [];
  for (const dirent of fs.readdirSync(dir, { withFileTypes: true })) {
    const fullPath = path.join(dir, dirent.name);
    if (dirent.isSymbolicLink()) {
      // Skip symlinks — they should not exist after UPLOAD4-002 fix,
      // but defense-in-depth: never follow unexpected symlinks
      continue;
    }
    if (dirent.isDirectory()) {
      files.push(...scanDirectoryNoFollowLinks(fullPath));
    } else {
      files.push(fullPath);
    }
  }
  return files;
}
HIGH
SA-SKL-UPLOAD4-002 — An MCP skill creates symbolic links from ZIP archive entries without validating that the symlink target, resolved relative to the symlink's directory, remains within the extraction root — an attacker whose ZIP contains a symlink from skill/data to /etc causes the extraction to create a symlink that points outside the sandbox, allowing the skill's subsequent recursive directory scan to follow the symlink and read arbitrary system files; fix by rejecting all symlink entries in uploaded archives, or if symlinks are required, validating the resolved target path with path.resolve(symlinkDir, target).startsWith(extractDirPrefix). Detection: SkillAudit flags ZIP extraction code that handles SymbolicLink entry types with fs.symlinkSync() without first verifying the target resolves within the extraction directory.

UPLOAD4-003 — ZIP bomb causes OOM or disk exhaustion during extraction

A ZIP bomb is an archive designed to consume disproportionate resources during extraction. The classic variant uses the deflate compression algorithm's ability to represent long runs of repeated bytes at a 1032:1 compression ratio. A ZIP archive of 1 MB can contain files totaling 1 GB of uncompressed data. A nested ZIP bomb contains a ZIP within a ZIP, recursively — each level multiplying the decompression factor. For MCP skills that extract user-uploaded archives into a temporary directory on the same filesystem as the application, a 1 GB extraction can fill the disk and cause the Node.js process and all co-located services to crash. For skills that buffer the full uncompressed content in memory (via entry.buffer()), a large entry can cause an OOM kill.

The fix requires three limits applied during streaming extraction: an entry count limit (reject archives with more than 1000 entries), a per-entry uncompressed size limit (check the uncompressedSize header field before reading), and a cumulative uncompressed size limit (track bytes written across all entries and abort if the total exceeds a threshold like 100 MB). Note that the uncompressedSize in the ZIP header can be spoofed in some ZIP variants; the cumulative byte count must be tracked during actual extraction, not just from the header.

// VULNERABLE — no entry count or size limits; full buffer in memory
import unzipper from 'unzipper';
import path from 'path';
import fs from 'fs';

async function extractZipVulnerable(zipPath: string, extractDir: string): Promise<void> {
  const zip = await unzipper.Open.file(zipPath);
  // No entry count check — a ZIP with 1,000,000 empty directories passes
  // No uncompressed size check — a 1MB ZIP with 1GB of content passes

  for (const entry of zip.files) {
    const outputPath = path.join(extractDir, entry.path);

    if (entry.type === 'Directory') {
      fs.mkdirSync(outputPath, { recursive: true });
    } else {
      // entry.buffer() reads entire uncompressed content into Node.js heap
      // If entry is 2GB, this OOMs the process
      const content = await entry.buffer();
      fs.writeFileSync(outputPath, content);
    }
  }
}
// FIXED — entry count + per-entry size + cumulative size limits; streaming extraction
import unzipper from 'unzipper';
import path from 'path';
import fs from 'fs';
import { pipeline } from 'stream/promises';
import { Transform } from 'stream';

const LIMITS = {
  maxEntries: 1000,
  maxUncompressedBytesPerEntry: 50 * 1024 * 1024,  // 50 MB per entry
  maxTotalUncompressedBytes: 100 * 1024 * 1024,     // 100 MB total
  maxNestingDepth: 5,                                // No ZIP-within-ZIP deeper than 5
  maxEntryNameLength: 255,                           // Prevent excessively long paths
};

async function extractZipSafe(
  zipPath: string,
  extractDir: string,
  currentDepth: number = 0
): Promise<void> {
  if (currentDepth > LIMITS.maxNestingDepth) {
    throw new Error(`ZIP nesting depth exceeds limit of ${LIMITS.maxNestingDepth}`);
  }

  const resolvedExtractDir = path.resolve(extractDir) + path.sep;
  fs.mkdirSync(extractDir, { recursive: true });

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

  // Check total entry count before beginning extraction
  if (zip.files.length > LIMITS.maxEntries) {
    throw new Error(
      `ZIP archive contains ${zip.files.length} entries, ` +
      `exceeding the limit of ${LIMITS.maxEntries}`
    );
  }

  let totalExtractedBytes = 0;

  for (const entry of zip.files) {
    // Entry name length check — prevents excessively long path creation
    if (entry.path.length > LIMITS.maxEntryNameLength) {
      throw new Error(`Entry name too long: ${entry.path.length} chars`);
    }

    // Path traversal check
    const resolvedOutput = path.resolve(extractDir, entry.path.replace(/\\/g, '/'));
    if (!resolvedOutput.startsWith(resolvedExtractDir)) {
      throw new Error(`ZIP slip: '${entry.path}' escapes extraction directory`);
    }

    if (entry.type === 'SymbolicLink') {
      throw new Error(`Symlinks not permitted in uploaded archives: '${entry.path}'`);
    }

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

    // Check declared uncompressed size (from ZIP header — may be spoofed, so we also
    // track actual bytes written below as the authoritative check)
    if (entry.vars?.uncompressedSize > LIMITS.maxUncompressedBytesPerEntry) {
      throw new Error(
        `Entry '${entry.path}' declares ${entry.vars.uncompressedSize} uncompressed bytes, ` +
        `exceeding per-entry limit of ${LIMITS.maxUncompressedBytesPerEntry}`
      );
    }

    // Stream extraction with live byte counting — catches spoofed size headers
    fs.mkdirSync(path.dirname(resolvedOutput), { recursive: true });

    let entryBytesWritten = 0;
    const countingTransform = new Transform({
      transform(chunk, _encoding, callback) {
        entryBytesWritten += chunk.length;
        totalExtractedBytes += chunk.length;

        if (entryBytesWritten > LIMITS.maxUncompressedBytesPerEntry) {
          callback(new Error(
            `Entry '${entry.path}' exceeds per-entry size limit during extraction`
          ));
          return;
        }

        if (totalExtractedBytes > LIMITS.maxTotalUncompressedBytes) {
          callback(new Error(
            `ZIP bomb: total extracted bytes ${totalExtractedBytes} exceeds ` +
            `limit of ${LIMITS.maxTotalUncompressedBytes}`
          ));
          return;
        }

        this.push(chunk);
        callback();
      },
    });

    const writeStream = fs.createWriteStream(resolvedOutput, { mode: 0o644 });
    await pipeline(entry.stream(), countingTransform, writeStream);
  }
}
HIGH
SA-SKL-UPLOAD4-003 — An MCP skill extracts ZIP archives without entry-count, per-entry size, or cumulative size limits — a ZIP bomb with a 1032:1 compression ratio in a 1 MB uploaded file expands to >1 GB during extraction, filling the application filesystem or exhausting Node.js heap via entry.buffer(); fix with three streaming limits: reject archives with more than 1000 entries, track actual bytes written per entry during streaming extraction and abort at 50 MB per entry, and abort the entire extraction when cumulative extracted bytes exceed 100 MB. Detection: SkillAudit flags ZIP extraction code that calls entry.buffer() or pipes to a write stream without a byte counter that enforces an upper bound on extracted content size.

UPLOAD4-004 — Executable bit preserved on extracted files

POSIX ZIP archives store file permission bits in the external attributes field of each entry. A ZIP archive created on a Unix-like system preserves the executable bit (0o755 or 0o777) on files marked executable in the source filesystem. When an extraction library respects these permission bits (as many do by default on Linux/macOS), an attacker who creates a ZIP containing a shell script backdoor.sh with chmod +x will find that after extraction, {extractDir}/backdoor.sh has the executable bit set. If the MCP skill subsequently executes any file from the extraction directory (for example, to run a build script included in the skill package), the attacker's script will execute. Even without explicit execution, some CI/CD systems auto-execute files named in certain patterns, or the +x file is a signal to developers to execute it manually.

The fix is straightforward: always write extracted files with explicit permissions of 0o644 (owner read-write, group and world read-only), never preserving the permission bits from the ZIP archive. This applies to fs.writeFileSync(), fs.createWriteStream(), and any other file-writing call in the extraction code.

// VULNERABLE — extracted files inherit permission bits from ZIP archive
import unzipper from 'unzipper';
import path from 'path';
import fs from 'fs';

async function extractZipVulnerable(zipPath: string, extractDir: string): Promise<void> {
  const zip = await unzipper.Open.file(zipPath);

  for (const entry of zip.files) {
    const outputPath = path.join(extractDir, entry.path);

    if (entry.type === 'Directory') {
      fs.mkdirSync(outputPath, { recursive: true });
    } else {
      const content = await entry.buffer();
      // VULNERABLE: fs.writeFileSync without mode — inherits umask, possibly +x
      // On many Linux systems default umask is 022:
      //   if entry has mode 0o755 (executable) → extracted as 0o755 (still executable)
      // Some unzip implementations explicitly apply the ZIP's permission bits:
      //   externalAttributes from ZIP → chmod(outputPath, externalAttributes >> 16)
      //   this explicitly sets +x on executable entries
      fs.writeFileSync(outputPath, content);

      // Even worse: some extraction code explicitly restores permissions:
      const externalAttributes = entry.vars?.externalFileAttributes;
      if (externalAttributes) {
        const unixMode = externalAttributes >> 16;
        if (unixMode !== 0) {
          fs.chmodSync(outputPath, unixMode & 0o7777); // Sets +x if archive had it
        }
      }
    }
  }
  // Now: backdoor.sh in the ZIP is extractDir/backdoor.sh with mode 0o755
  // If anything runs files from extractDir, the shell script executes
// FIXED — always write with 0o644; never apply ZIP archive permission bits
import unzipper from 'unzipper';
import path from 'path';
import fs from 'fs';
import { pipeline } from 'stream/promises';
import { Transform } from 'stream';

async function extractZipSafe(zipPath: string, extractDir: string): Promise<void> {
  const resolvedExtractDir = path.resolve(extractDir) + path.sep;
  fs.mkdirSync(extractDir, { recursive: true });

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

  for (const entry of zip.files) {
    // Bounds check (UPLOAD4-001)
    const resolvedOutput = path.resolve(extractDir, entry.path.replace(/\\/g, '/'));
    if (!resolvedOutput.startsWith(resolvedExtractDir)) {
      throw new Error(`ZIP slip: '${entry.path}' escapes extraction directory`);
    }

    if (entry.type === 'SymbolicLink') {
      throw new Error(`Symlinks not permitted: '${entry.path}'`);
    }

    if (entry.type === 'Directory') {
      // Directories: 0o755 (executable bit needed for directory traversal)
      // This is safe — the executable bit on a directory means "can list/enter"
      fs.mkdirSync(resolvedOutput, { recursive: true, mode: 0o755 });
      continue;
    }

    // Regular files: ALWAYS 0o644 — never preserve ZIP archive permission bits
    // 0o644 = owner read+write, group read, world read — no execute for anyone
    fs.mkdirSync(path.dirname(resolvedOutput), { recursive: true, mode: 0o755 });
    const writeStream = fs.createWriteStream(resolvedOutput, { mode: 0o644 });

    await pipeline(entry.stream(), writeStream);

    // Double-check: explicitly chmod after write to override any umask behavior
    fs.chmodSync(resolvedOutput, 0o644);

    // NEVER call fs.chmodSync with bits derived from the ZIP archive entry:
    // const mode = entry.vars?.externalFileAttributes >> 16;
    // fs.chmodSync(resolvedOutput, mode);  ← DO NOT DO THIS
  }
}
HIGH
SA-SKL-UPLOAD4-004 — An MCP skill extracts ZIP archive entries without specifying file permissions, allowing the Node.js process's umask (or explicit permission restoration code) to preserve the executable bit from the ZIP's external attributes — an attacker whose ZIP contains backdoor.sh with mode 0o755 produces an extracted file with +x that executes if the skill runs any file from the extraction directory; fix by always passing { mode: 0o644 } to fs.writeFileSync() and fs.createWriteStream(), calling fs.chmodSync(outputPath, 0o644) after each write, and never reading permission bits from the ZIP's externalFileAttributes field. Detection: SkillAudit flags ZIP extraction code that calls fs.chmodSync() with bits derived from the archive's externalFileAttributes, or that calls fs.writeFileSync()/fs.createWriteStream() without an explicit mode: 0o644 option in a path that handles user-uploaded files.

Detection summary

ID Severity Pattern Fix
UPLOAD4-001 CRITICAL ZIP slip — path.join(extractDir, entry.path) without bounds check; entry name ../../../../etc/cron.d/backdoor writes outside extraction directory path.resolve() + .startsWith(resolvedBase + sep) on every entry
UPLOAD4-002 HIGH Symlink in ZIP with target /etc escapes extraction root; subsequent recursive scan follows symlink and reads system files Reject all symlink entries, or validate resolved target stays within extractDirPrefix
UPLOAD4-003 HIGH No entry-count or size limit — 1 MB ZIP with 1 GB content exhausts disk or OOMs via entry.buffer() Max 1000 entries; streaming extraction with live byte counter; abort at 50 MB/entry and 100 MB total
UPLOAD4-004 HIGH Executable bit preserved from ZIP's externalFileAttributes — uploaded .sh file with +x remains executable after extraction Always { mode: 0o644 } on all extracted regular files; never apply ZIP permission bits

Related patterns: SA-SKL-UPLOAD3 covers MIME type confusion and polyglot file attacks including magic bytes bypass and SVG XSS for single-file uploads. SA-SKL-MULTIPART4 covers multipart upload security in CI/CD pipelines including null byte filename injection and streaming size limits. SA-SKL-SSRF6 covers SSRF via cloud metadata endpoints that can be reached when processing URLs extracted from malicious ZIP archives.