Skip to content

Comments

fix(filesystem): sanitize error messages to prevent path info disclosure#3371

Closed
aptsalt wants to merge 1 commit intomodelcontextprotocol:mainfrom
aptsalt:fix/filesystem-error-path-leak
Closed

fix(filesystem): sanitize error messages to prevent path info disclosure#3371
aptsalt wants to merge 1 commit intomodelcontextprotocol:mainfrom
aptsalt:fix/filesystem-error-path-leak

Conversation

@aptsalt
Copy link

@aptsalt aptsalt commented Feb 22, 2026

Summary

  • Sanitize validatePath() error messages in src/filesystem/lib.ts to stop exposing absolute paths and allowed directory lists in error output
  • Pin npx examples in src/filesystem/README.md to @0.6.3 to mitigate supply chain risk from unpinned package resolution
  • Add 3 tests that explicitly verify error messages don't contain filesystem paths

Context

Addresses the 2 low-severity findings from the AgentAudit security report in #3317:

  1. Error messages expose internal path informationvalidatePath() included the full requested path and the complete allowed directory list in thrown errors. In shared or multi-tenant environments, this could leak directory structure to unauthorized callers.

  2. NPX usage without version pinning — Documentation examples used npx -y @modelcontextprotocol/server-filesystem without a version specifier, creating a supply chain risk if a malicious version were published.

Changes

src/filesystem/lib.ts

  • Lines 110, 119, 131, 135: Removed interpolated paths from error messages while preserving the descriptive denial reason (e.g. "Access denied - path outside allowed directories")

src/filesystem/README.md

  • Pinned both NPX examples to @modelcontextprotocol/server-filesystem@0.6.3

src/filesystem/__tests__/lib.test.ts

  • does not leak filesystem paths in access denied errors — verifies error message contains no path or directory info
  • does not leak filesystem paths in parent directory errors — verifies parent path is not leaked
  • does not leak filesystem paths in symlink denied errors — verifies symlink target path is not leaked

Test plan

  • All 48 lib tests pass (npx vitest run __tests__/lib.test.ts)
  • Full test suite: 144/145 pass (1 pre-existing Windows-specific failure unrelated to this change)
  • tsc --noEmit passes with no type errors
  • Verify error messages are still useful for debugging in development

Closes #3317

…disclosure

Remove internal filesystem paths from validatePath() error messages to
prevent leaking directory structure in shared environments. Pin npx
examples in README to @0.6.3 to mitigate supply chain risk.

Closes #3317
@aptsalt aptsalt closed this by deleting the head repository Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security Audit: 2 finding(s) in mcp-server-filesystem

1 participant