← Blog

Claude MCP skill path traversal and symlink attacks in skill asset and configuration file storage — SA-SKL-UPLOAD13

MCP skill platforms store developer-submitted content in multiple locations: uploaded asset files (images, scripts, documentation), extracted skill package archives (ZIP bundles of skill source code), and manifest-specified resource URLs that the platform resolves to local paths. Each storage pathway is a potential path traversal surface when the filename or path comes from attacker-controlled input. SA-SKL-UPLOAD13 covers four path traversal and symlink vulnerabilities: direct filename traversal via fs.createWriteStream(), symlink extraction from ZIP archives, manifest thumbnail path traversal via path.join(), and directory listing exposure via express.static() without index:false.

By SkillAudit  |  12 Nov 2026
SA-SKL-UPLOAD13 findings at a glance
CRITICALUPLOAD13-001 — Skill asset filename from form upload used in fs.createWriteStream(uploadDir + '/' + filename) without sanitization — attacker uploads file named ../config/admin.json; writes over application configuration, adding a new admin user or disabling auth
CRITICALUPLOAD13-002 — Symlink entries in skill ZIP package extracted without validation — attacker ZIP contains link.txt → /etc/passwd; subsequent request to serve link.txt from the extracted directory follows the symlink, returning /etc/passwd contents
HIGHUPLOAD13-003 — Skill thumbnail path from manifest resolved via path.join(skillAssetsDir, manifest.thumbnail) without further validation — "thumbnail": "../../static/admin.html" in manifest; path.join resolves to /app/static/admin.html; served from the static assets route
MEDIUMUPLOAD13-004 — Extracted skill package directory served via express.static(extractDir) without index: false — attacker ZIP contains no index.html; browser receives a full directory listing of extracted files; reveals internal file structure and aids further attacks

UPLOAD13-001 — Filename path traversal in fs.createWriteStream()

Skill asset upload endpoints receive a file and a filename from the developer's form or API request. The upload handler constructs the destination path by concatenating the upload directory with the filename: uploadDir + '/' + filename. When the filename contains ../ sequences, the resulting path escapes the upload directory. Node.js fs.createWriteStream() resolves path separators natively — a filename of ../config/admin.json with uploadDir = '/app/skill-assets/uploads' produces the path /app/skill-assets/config/admin.json and then with more ../ sequences reaches /app/config/admin.json. Overwriting the application configuration file can disable authentication, inject a new admin account, or redirect webhook endpoints to attacker-controlled infrastructure.

// VULNERABLE — filename from request used directly in write path
const multer = require('multer');
const storage = multer.diskStorage({
  destination: '/app/skill-assets/uploads',
  filename: (req, file, cb) => {
    cb(null, file.originalname);  // <-- attacker controls originalname
  }
});
const upload = multer({ storage });

app.post('/api/skills/:skillId/assets', upload.single('asset'), (req, res) => {
  res.json({ path: `/skill-assets/uploads/${req.file.filename}` });
});

// Attacker uploads file with:
// Content-Disposition: form-data; name="asset"; filename="../../../config/admin.json"
// Body: { "adminUsers": ["attacker@evil.com"], "authDisabled": true }

Double encoding bypass: Some implementations sanitize filenames by checking for literal ../ sequences, but accept URL-encoded variants: %2e%2e%2f, ..%2f, or %2e%2e/. Node.js's filesystem layer decodes percent sequences in some contexts. The fix must use path.basename() (which strips directory components regardless of encoding) or generate a UUID as the storage filename — never use the original filename for the storage path.

// FIXED — path.basename() strips directory components; UUID for storage name
const crypto = require('crypto');
const path = require('path');

const storage = multer.diskStorage({
  destination: '/app/skill-assets/uploads',
  filename: (req, file, cb) => {
    const ext = path.extname(path.basename(file.originalname));
    // UUID storage name — no user input in the filesystem path
    const storageName = `${crypto.randomUUID()}${ext}`;
    cb(null, storageName);
  }
});

// Validate ext against allowlist
const ALLOWED_ASSET_EXTENSIONS = new Set(['.png', '.jpg', '.svg', '.webp', '.md', '.json']);

app.post('/api/skills/:skillId/assets', upload.single('asset'), (req, res) => {
  const ext = path.extname(req.file.filename);
  if (!ALLOWED_ASSET_EXTENSIONS.has(ext.toLowerCase())) {
    fs.unlinkSync(req.file.path);  // remove already-written temp file
    return res.status(400).json({ error: 'File type not permitted' });
  }
  res.json({ assetId: req.file.filename });
});

UPLOAD13-002 — Symlink extraction from skill ZIP package

ZIP archives support two entry types relevant to symlinks: entries with the external file attributes field set to indicate a symbolic link (Unix mode 0120000), and entries with the entry data containing the link target path as a string. Many Node.js ZIP extraction libraries do not check the external attributes or entry type before writing extracted files. When a ZIP entry that is actually a symlink is extracted, the library creates a real symlink in the filesystem. If the symlink target points to a sensitive file (/etc/passwd, /app/.env, /var/run/secrets/kubernetes.io/serviceaccount/token), subsequent requests that read or serve the extracted directory will follow the symlink and return the linked file's contents.

// VULNERABLE — extraction without symlink check (using unzipper)
const unzipper = require('unzipper');
const fs = require('fs');
const path = require('path');

async function extractSkillPackage(zipPath, extractDir) {
  await fs.createReadStream(zipPath)
    .pipe(unzipper.Extract({ path: extractDir }))
    .promise();
  // unzipper.Extract() follows ZIP entry type including symlinks
}

// Attacker ZIP structure:
// link.txt → /etc/passwd  (symlink entry in ZIP)
// After extraction: /app/skill-assets/{skillId}/link.txt → /etc/passwd
// GET /skill-assets/{skillId}/link.txt → returns /etc/passwd contents

Target paths for symlink attacks: Common high-value symlink targets in containerized Node.js environments: /etc/passwd (user enumeration), /etc/hostname (container identity), /var/run/secrets/kubernetes.io/serviceaccount/token (k8s service account JWT for API access), /proc/self/environ (process environment variables including secrets), and /app/.env or /app/config/production.json (application secrets). The attacker doesn't need to know the exact path — a ZIP with 10–20 symlinks targeting common paths will find at least one that exists in most deployments.

// FIXED — lstat() each entry before extraction; reject symlinks
const yauzl = require('yauzl');  // lower-level, allows entry inspection

async function extractSkillPackageSafe(zipPath, extractDir) {
  return new Promise((resolve, reject) => {
    yauzl.open(zipPath, { lazyEntries: true }, (err, zipfile) => {
      if (err) return reject(err);
      zipfile.readEntry();
      zipfile.on('entry', async (entry) => {
        // Check Unix mode in external file attributes
        const unixMode = (entry.externalFileAttributes >> 16) & 0xFFFF;
        const isSymlink = (unixMode & 0xF000) === 0xA000;  // S_IFLNK = 0xA000

        if (isSymlink) {
          // Skip symlink entries entirely
          zipfile.readEntry();
          return;
        }

        // Check for path traversal in the entry name
        const targetPath = path.join(extractDir, entry.fileName);
        if (!targetPath.startsWith(path.resolve(extractDir) + path.sep)) {
          reject(new Error(`ZIP slip attempt: ${entry.fileName}`));
          return;
        }

        // Extract safe entry
        zipfile.openReadStream(entry, (streamErr, readStream) => {
          if (streamErr) return reject(streamErr);
          const writeStream = fs.createWriteStream(targetPath);
          readStream.pipe(writeStream);
          writeStream.on('finish', () => zipfile.readEntry());
        });
      });
      zipfile.on('end', resolve);
    });
  });
}

UPLOAD13-003 — Manifest thumbnail path traversal via path.join()

Skill manifests specify a thumbnail path — a relative path within the skill's extracted asset directory — to identify which file should be shown as the skill's icon in the registry listing. The platform serves this file via its static assets route. When the manifest's thumbnail value is passed to path.join(skillAssetsDir, manifest.thumbnail) without further validation, a value like ../../static/admin.html resolves to a path outside the skill's directory. The path.join() function does not reject directory traversal sequences — it normalizes the path, with ../ components moving up the directory tree. The resolved path is then served from the static assets route, returning the target file to the requesting browser.

// VULNERABLE — manifest thumbnail served via path.join without boundary check
app.get('/skill-assets/:skillId/thumbnail', async (req, res) => {
  const skill = await db.skills.findOne({ id: req.params.skillId });
  const thumbnailPath = path.join(
    `/app/skill-assets/${req.params.skillId}`,
    skill.manifest.thumbnail  // <-- "../../static/admin.html" from manifest
  );
  // path.join resolves to /app/static/admin.html — served outside skill directory
  res.sendFile(thumbnailPath);
});

// Manifest thumbnail values that exploit this:
// "../../static/admin.html"           → /app/static/admin.html
// "../../../etc/passwd"               → /etc/passwd (if traversal reaches root)
// "../../../app/config/secrets.json"  → application secrets

path.join() vs path.resolve(): Both functions normalize ../ components, but path.resolve() returns an absolute path, making it possible to check whether the result is a child of the allowed base directory. The pattern path.resolve(base, userInput) followed by resolvedPath.startsWith(path.resolve(base) + '/') is the standard path traversal guard. path.join() alone provides no containment guarantee — always follow it with a startsWith() check on the resolved result.

// FIXED — path.resolve() + startsWith() boundary check
app.get('/skill-assets/:skillId/thumbnail', async (req, res) => {
  const skillId = req.params.skillId;
  if (!/^[0-9a-f-]{36}$/.test(skillId)) {  // UUID format validation
    return res.status(400).json({ error: 'Invalid skill ID' });
  }

  const skill = await db.skills.findOne({ id: skillId });
  const skillBase = path.resolve(`/app/skill-assets/${skillId}`);
  const thumbnailPath = path.resolve(skillBase, skill.manifest.thumbnail);

  if (!thumbnailPath.startsWith(skillBase + '/')) {
    return res.status(400).json({ error: 'Invalid thumbnail path' });
  }

  // Also validate the file exists (prevent 404-based path enumeration)
  if (!fs.existsSync(thumbnailPath)) {
    return res.status(404).json({ error: 'Thumbnail not found' });
  }

  res.sendFile(thumbnailPath);
});

UPLOAD13-004 — Directory listing via express.static() without index:false

When express.static() serves a directory and no index.html file exists in that directory, the default behavior depends on the index option. With index: true (the default), Express generates and returns an HTML directory listing when a directory URL is requested. MCP skill packages that don't include an index.html at their root — common for backend skills that have no web interface — trigger this directory listing when the extracted directory is requested. The listing reveals all extracted file paths: source JavaScript files, configuration files, any .env or credential files included in the package, and internal implementation details. This is an information disclosure vulnerability that aids follow-on attacks.

// VULNERABLE — express.static serves extracted skill packages with default options
app.use('/skill-preview/:skillId',
  (req, res, next) => {
    req.skillPath = `/app/skill-assets/${req.params.skillId}`;
    next();
  },
  (req, res, next) => {
    express.static(req.skillPath)(req, res, next);
    // Default options: index: 'index.html', dotfiles: 'ignore'
    // If no index.html: returns directory listing of all files
  }
);

// Attacker requests GET /skill-preview/{skillId}/
// Response: HTML listing of all files in the extracted directory
// Reveals: main.js, config.json, .npmrc (with registry auth token), etc.

Dotfiles in skill packages: Developers occasionally include .env, .npmrc (with npm auth tokens for private packages), or .git/config files in their skill packages by accident. The default express.static() configuration uses dotfiles: 'ignore' which does not serve dotfiles, but it also does not prevent the directory listing from mentioning their existence. With a directory listing, the attacker knows the dotfile is present and can attempt to fetch it via other means. Set dotfiles: 'deny' to return 403 for dotfile requests, and always disable directory listing for untrusted-content directories.

// FIXED — disable directory listing and deny dotfiles
app.use('/skill-preview/:skillId',
  (req, res, next) => {
    const skillId = req.params.skillId;
    if (!/^[0-9a-f-]{36}$/.test(skillId)) {
      return res.status(400).end();
    }
    const skillPath = path.resolve('/app/skill-assets', skillId);
    // Confirm the resolved path is within the skill-assets directory
    if (!skillPath.startsWith('/app/skill-assets/')) {
      return res.status(400).end();
    }
    express.static(skillPath, {
      index: false,        // never serve directory listings
      dotfiles: 'deny',    // 403 for .env, .npmrc, etc.
      redirect: false,     // don't redirect /dir to /dir/
    })(req, res, next);
  }
);

Detection summary

Finding Severity Attack surface Fix
UPLOAD13-001 CRITICAL Form upload filename path.basename() + UUID storage name
UPLOAD13-002 CRITICAL ZIP symlink extraction lstat() each entry, reject SymbolicLink
UPLOAD13-003 HIGH Manifest thumbnail path path.resolve() + startsWith(skillBase)
UPLOAD13-004 MEDIUM Static file directory listing { index: false, dotfiles: 'deny' }

SkillAudit's static analysis scans for all four UPLOAD13 patterns. File write operations using string concatenation or path.join() with user-supplied filenames trigger UPLOAD13-001; ZIP extraction code that does not check entry type via lstat() or external file attributes triggers UPLOAD13-002; path.join(basePath, manifestField) without a startsWith() check triggers UPLOAD13-003; express.static() calls without index: false on directories containing user-submitted content trigger UPLOAD13-004. See also SA-SKL-UPLOAD12 for command injection via archive member filenames during ZIP/TAR extraction, and SA-SKL-SSRF18 for SSRF via manifest URL fetching.