Skip to content

safeFile named the resolved/attempted path in security-sensitive error messages #610

Closed

Description

@jimhoyd

Runtime revision and environment

main at 645239b..c17deec (#607); found while merging #602 onto main and running its MCP test suite.

Minimal reproduction

packages/core/src/config.ts's safeFile (used by functionFile for every function/middleware source reference) names the referenced path in its three error messages (Referenced project file is missing: "…", File reference escapes project: "…", Reference must point to a file: "…"), added as part of #607's authoring-error improvements. A pre-existing test, test/mcp.test.ts ('MCP fails closed on project source traversal without revealing source details'), asserts the opposite: a route declaring function: {source: '../private-credential.mjs'} must fail validation without the attempted path appearing in the MCP response text. Before #607, the message was bare (no path). After #607, the resolved/attempted path is included, so MCP's validate (whose text-only response includes it verbatim, since #582/#602 made MCP surface the CLI's real error) can be turned into a limited oracle for what exists outside the project directory.

Relevant output

node --conditions=development --test test/mcp.test.ts failed this test after merging #602 (which surfaces real errors over MCP, #582) onto post-#607 main; it passed on main and on #602's own pre-merge branch independently, only failing in combination — because #602 is what makes MCP's response include the raw message text at all.

Suggested fix

Fixed while merging #602 (#602): safeFile now only names the reference when it doesn't contain a .. path segment (an escape attempt); a plain in-project typo like functions/missing.mjs is still named (matches #607's own test/authoring-errors.test.ts expectation), but nothing shaped like a traversal attempt is. The structured file detail field is unchanged (CLI-only, never reaches an MCP text response). Flagging as a separate issue since the underlying message change shipped in #607, independent of #602's merge; the fix will land on main via #602.

Activity

  1. added
    bug
    on Sep 24, 2026
  2. added a commit that references this issue on Sep 24, 2026
  3. jimhoyd commented on Sep 24, 2026

    @jimhoyd
    CollaboratorAuthor

    Fixed in #602 (#602), already on main: safeFile only names the reference when it doesn't contain a .. segment. Verified present on origin/main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions