← Blog

Claude skill information disclosure security — SA-SKL-INFODISCLOSURE

Information disclosure vulnerabilities do not directly compromise user data, but they hand attackers the reconnaissance they need to target more damaging attacks precisely. INFODISCLOSURE-001 covers Express's default X-Powered-By header which broadcasts the framework and version to every HTTP client. INFODISCLOSURE-002 covers the common pattern of including e.stack in JSON error responses, which exposes file paths, line numbers, and internal module structure. INFODISCLOSURE-003 covers Express.static() without directory listing disabled, which turns any upload folder into a browsable file index. INFODISCLOSURE-004 covers differentiated error messages at login — returning "Invalid password" vs "User not found" — which allow automated account enumeration.

By SkillAudit  |  5 Nov 2026

Why information disclosure is a force multiplier for attackers

An attacker who knows you run Express 4.18.2 can look up all known CVEs for that version and target the most exploitable ones. An attacker who sees a stack trace with at /app/src/services/auth/jwt.ts:47:19 knows your directory structure, language, and ORM — they can probe adjacent files. An attacker who can browse /uploads/ and see all uploaded filenames can target specific files for download or find naming patterns for the collision attack in SA-SKL-UPLOAD2. An attacker who can enumerate accounts can build a credential-stuffing list. None of these disclosures are exploits on their own. Each one reduces the cost of the subsequent attack by an order of magnitude.

SA-SKL-INFODISCLOSURE in scope: INFODISCLOSURE-001 (X-Powered-By framework fingerprinting), INFODISCLOSURE-002 (stack trace in error response), INFODISCLOSURE-003 (Express.static directory listing), INFODISCLOSURE-004 (user enumeration via error message). Each includes SkillAudit detection rules and helmet / structured error / uniform response fixes.

INFODISCLOSURE-001 — Server fingerprinting via X-Powered-By header

Express sets the X-Powered-By: Express response header on every HTTP response by default. This tells every client, proxy, and WAF exactly what framework your skill runs on. Combined with the Express version visible in package.json (often exposed in error pages or public npm dependency graphs), attackers can narrow their attack surface to CVEs specific to that version. Helmet removes this header (along with several other information-disclosing headers) with a single middleware call. The only reason not to use Helmet is if you have already audited every header it sets and confirmed they conflict with a specific requirement — which is rare.

// VULNERABLE: Express default sends X-Powered-By: Express on every response
const express = require('express');
const app = express();

// No Helmet or header suppression — every response includes:
// X-Powered-By: Express
// This tells attackers the framework; version is often deducible from public package.json

app.get('/api/skill/ping', (req, res) => {
  res.json({ status: 'ok' });
  // Response headers:
  // X-Powered-By: Express         ← framework fingerprint
  // X-Content-Type-Options: (not set)   ← MIME sniffing allowed
  // X-Frame-Options: (not set)    ← clickjacking allowed
});
// FIXED: Helmet removes X-Powered-By and sets safe defaults for all security headers
const express = require('express');
const helmet = require('helmet');
const app = express();

// helmet() removes X-Powered-By and sets:
// X-Content-Type-Options: nosniff
// X-Frame-Options: SAMEORIGIN
// X-XSS-Protection: 0 (disables legacy IE XSS filter that could be bypassed)
// Strict-Transport-Security: max-age=15552000; includeSubDomains
// Content-Security-Policy: (default-src 'self'; customize for your needs)
app.use(helmet());

// If you only want to remove X-Powered-By without all helmet defaults:
// app.disable('x-powered-by');  // Minimal option — but helmet is preferred

app.get('/api/skill/ping', (req, res) => {
  res.json({ status: 'ok' });
  // X-Powered-By header is gone
  // Framework identity is not disclosed to clients
});
MEDIUM
SA-SKL-INFODISCLOSURE-001 — Skill HTTP server sends the default X-Powered-By: Express response header; combined with public npm dependency graphs or package.json exposure, attackers identify the exact framework version and target version-specific CVEs. Fix: add helmet() middleware as the first app-level middleware; it removes X-Powered-By and sets safe defaults for all OWASP-recommended security headers. Detection: SkillAudit flags Express applications that do not call app.use(helmet()) or app.disable('x-powered-by') before any route handler.

INFODISCLOSURE-002 — Stack trace in error response

When an unhandled error occurs, Express's default error handler sends the stack trace in the response body in development mode. Many MCP skills replicate this pattern explicitly: catching errors and including e.stack or e.message in the JSON response "for debugging." A stack trace exposes absolute file paths (/app/src/services/audit/runner.ts:142), internal function names, the ORM in use (at SequelizeConnectionError), database query fragments (SELECT * FROM audit_jobs WHERE), and npm package names and versions (at Object.<anonymous> (/app/node_modules/pg/lib/connection.js:72)). This is a complete internal architecture disclosure. Stack traces belong in server-side logs with a request ID; clients should receive only the request ID to correlate with logs.

// VULNERABLE: stack trace included in API error response
app.use((err: Error, req: Request, res: Response, next: NextFunction) => {
  console.error('[ERROR]', err);

  // VULNERABLE: err.stack sent to client — exposes file paths, module names, line numbers
  res.status(500).json({
    error: err.message,       // May contain SQL fragments, internal values
    stack: err.stack,         // Full stack trace with absolute file paths
    code: (err as any).code,  // DB error codes, constraint names
  });
});
// FIXED: log stack server-side; return only requestId to client
const crypto = require('crypto');

app.use((err: Error, req: Request, res: Response, next: NextFunction) => {
  // Generate a request ID for correlation between client report and server log
  const requestId = crypto.randomUUID();

  // Full stack trace logged server-side only
  console.error({
    requestId,
    message: err.message,
    stack: err.stack,
    code: (err as any).code,
    path: req.path,
    method: req.method,
    userId: (req as any).user?.id,
  });

  // Client receives only the requestId — no internal details
  // User can report the requestId; engineer can grep logs for it
  const statusCode = (err as any).statusCode || (err as any).status || 500;
  res.status(statusCode).json({
    error: 'An unexpected error occurred',
    requestId,  // Safe to return — correlates with server log, discloses nothing
  });
});
HIGH
SA-SKL-INFODISCLOSURE-002 — Skill error handler includes err.stack, err.message, or raw database error codes in the JSON response body; stack traces expose absolute file paths, internal function names, ORM library versions, and partial database query text; attackers use this to map internal architecture and identify secondary attack targets. Fix: generate a crypto.randomUUID() request ID per error; log the full stack trace server-side keyed by request ID; return only { error: 'An unexpected error occurred', requestId } to the client. Detection: SkillAudit flags error handler middleware that references err.stack, err.message, or error .code properties in the response object passed to res.json() or res.send().

INFODISCLOSURE-003 — Directory listing via Express.static()

When Express serves a directory with express.static('/uploads') without disabling directory listing, any client that requests a directory URL (e.g., GET /uploads/) receives an HTML index of all files in that directory. This turns every upload folder into a browsable file catalog. For MCP skills that store user-submitted audit packages, private configuration files, or generated reports, this exposes every uploaded file to any unauthenticated visitor. The fix is either to disable directory listing in the static middleware options, or — better — to never serve upload directories with Express.static at all, instead serving files only through a streaming endpoint that enforces authentication and authorization per file.

// VULNERABLE: express.static serves /uploads with directory listing enabled by default
const express = require('express');
const app = express();

// VULNERABLE: any visitor can GET /uploads/ and see a list of all uploaded files
// Includes private audit packages, generated reports, user-submitted configuration
app.use('/uploads', express.static('/var/data/uploads'));
// GET /uploads/ → HTML index of all files: audit-abc123.zip, config-user1.json, ...

// Even if files have randomized names, the directory listing reveals them all
// Combined with SA-SKL-UPLOAD2-004: if originalnames were used, disclosure is worse
// FIXED option A: disable directory listing in static middleware
app.use('/uploads', express.static('/var/data/uploads', {
  index: false,         // Don't serve index.html for directories
  dotfiles: 'deny',     // Block requests to dotfiles (.env, .git, etc.)
  // Note: this prevents listing but files are still accessible by direct URL
  // Any file at /var/data/uploads/known-uuid.png is accessible to anyone who knows the URL
  // If files should be access-controlled, use option B instead
}));

// FIXED option B (preferred): serve files through an authenticated streaming endpoint
// No Express.static at all for sensitive upload directories
app.get('/api/uploads/:key', authMiddleware, async (req, res) => {
  const { key } = req.params;

  // Validate key format (UUID + extension)
  if (!/^[0-9a-f-]{36}\.[a-z]{2,4}$/.test(key)) {
    return res.status(400).json({ error: 'Invalid file key' });
  }

  // Authorize: verify this user owns the upload
  const upload = await db.uploads.findByKey(key, req.user.id);
  if (!upload) return res.status(404).json({ error: 'Not found' });

  // Stream the file with explicit Content-Type (not derived from extension)
  res.setHeader('Content-Type', upload.mimeType);
  res.setHeader('Content-Disposition', `attachment; filename="${upload.originalName}"`);
  fs.createReadStream(path.join('/var/data/uploads/', key)).pipe(res);
});
HIGH
SA-SKL-INFODISCLOSURE-003 — Skill serves an upload or asset directory with express.static(dir) without { index: false }; any client that requests the directory URL receives an HTML index of all files in the directory, including private audit packages, user-submitted configurations, and generated reports; file enumeration is trivial for any unauthenticated visitor. Fix: set { index: false, dotfiles: 'deny' } on the static middleware options; or better, replace Express.static for sensitive directories with an authenticated streaming endpoint that enforces per-user authorization before serving any file. Detection: SkillAudit flags express.static() calls without an explicit { index: false } option on paths that contain user-uploaded or generated files.

INFODISCLOSURE-004 — User enumeration via differentiated error messages

When a login endpoint returns different error messages for "wrong password for existing user" vs "no user with that email address," an attacker can enumerate which email addresses have accounts in the system. The classic pattern returns { error: 'Invalid password' } for a correct email with wrong password (after running bcrypt comparison), and { error: 'User not found' } for an email that doesn't exist in the database (which returns faster, without a bcrypt call). The attacker tries thousands of email addresses, categorizes responses by message text, and obtains a list of registered accounts. This list is used for spear-phishing, credential stuffing from breached password databases, and targeted social engineering. The fix is a uniform "Invalid credentials" message for all authentication failures, combined with a constant-time response to defeat timing-based enumeration.

// VULNERABLE: different messages reveal whether the email exists
app.post('/api/auth/login', async (req, res) => {
  const { email, password } = req.body;

  const user = await db.users.findByEmail(email);

  if (!user) {
    // VULNERABLE: 'User not found' tells attacker this email is not registered
    // Response also returns in ~2ms (no bcrypt) — timing confirms the difference
    return res.status(401).json({ error: 'User not found' });
  }

  const passwordMatch = await bcrypt.compare(password, user.passwordHash);

  if (!passwordMatch) {
    // VULNERABLE: 'Invalid password' tells attacker this email IS registered
    // Response returns in ~100ms (bcrypt ran) — timing also confirms registration
    return res.status(401).json({ error: 'Invalid password' });
  }

  const token = generateSessionToken(user.id);
  res.json({ token });
});
// FIXED: uniform error message + constant-time response (always run bcrypt)
const DUMMY_HASH = await bcrypt.hash('dummy-password-for-timing-parity', 12);

app.post('/api/auth/login', async (req, res) => {
  const { email, password } = req.body;

  const user = await db.users.findByEmail(email);

  if (!user) {
    // Run bcrypt against a dummy hash to match the timing of a successful user lookup
    // Without this, response time ~2ms vs ~100ms still reveals account existence
    await bcrypt.compare(password, DUMMY_HASH);
    // Uniform message — attacker cannot distinguish 'no account' from 'wrong password'
    return res.status(401).json({ error: 'Invalid credentials' });
  }

  const passwordMatch = await bcrypt.compare(password, user.passwordHash);

  if (!passwordMatch) {
    // Same message and same timing path as the 'no user' branch above
    return res.status(401).json({ error: 'Invalid credentials' });
  }

  const token = generateSessionToken(user.id);
  res.json({ token });
});

// Note: DUMMY_HASH must be computed at startup (before first request) to avoid
// lazy-evaluation timing attack. Use a module-level await in an async IIFE or
// initialize it in the app startup sequence.
MEDIUM
SA-SKL-INFODISCLOSURE-004 — Skill login or password-reset endpoint returns different error messages for "user does not exist" vs "wrong password"; the message difference (or response time difference — no bcrypt run vs 100ms bcrypt) allows automated enumeration of registered email addresses; enumerated account lists are used for credential stuffing and spear phishing. Fix: return a uniform "Invalid credentials" message for all authentication failures; always run a bcrypt comparison (against a dummy hash for non-existent users) to equalize response timing; also apply rate limiting and lockout on repeated failures. Detection: SkillAudit flags authentication handlers that return different error strings in the user-not-found vs wrong-password code paths, and handlers that return early (before bcrypt) on user-not-found.

SkillAudit detection summary — SA-SKL-INFODISCLOSURE

Pattern IDSeverityWhat SkillAudit flagsFix
INFODISCLOSURE-001MEDIUMNo helmet() or app.disable('x-powered-by') in app setupapp.use(helmet()) as first middleware
INFODISCLOSURE-002HIGHerr.stack or err.message in res.json() within error handlerLog server-side; return only requestId to client
INFODISCLOSURE-003HIGHexpress.static() without { index: false } on user-data paths{ index: false, dotfiles: 'deny' } or authenticated streaming endpoint
INFODISCLOSURE-004MEDIUMDifferent error strings or early return before bcrypt in login handlerUniform 'Invalid credentials' + dummy-hash bcrypt for timing parity

Related patterns: For timing-based side channels beyond user enumeration, see SA-SKL-TIMING2. For credential exposure via API error messages that include token values, see SA-SKL-APIABUSE. For output escaping and HTML injection in rendered error pages, see SA-SKL-ESCAPE.