You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: prevent path traversal in style and tileset tool URL construction (#103)
* fix: prevent path traversal in style and tileset tool URL construction
Five tools (RetrieveStyle, DeleteStyle, UpdateStyle, PreviewStyle,
TilequeryTool) concatenated user-supplied path parameters directly
into Mapbox API URLs without validation or encoding. Because Node.js
fetch uses the WHATWG URL parser, `../` sequences were normalized
before sending, allowing requests to reach unintended API endpoints.
Changes:
- Add shared `styleIdSchema` with allowlist regex that rejects path
separators, dots, percent-encoded sequences, and null bytes
- Apply `styleIdSchema` to all four style tools via a shared module
(src/tools/shared/styleId.schema.ts)
- Add format validation to TilequeryTool tilesetId (owner.name format)
- Wrap both username and styleId/tilesetId in `encodeURIComponent`
at every URL construction site (defense-in-depth)
- Replace silent fallback in output schema validation with explicit
`isError: true` responses across all API tools, preventing
unintended API responses from being forwarded to callers
- Remove now-unused BaseTool.validateOutput() method
- Add test/security/path-traversal.test.ts with 52 tests covering
schema rejection, valid ID acceptance, URL encoding, and response
schema mismatch behavior
* fix: update tests for Prettier, Zod v4, and @mcp-ui/server v6.1.0 upgrades
- Reformat dynamic imports to match Prettier 3.8.x style
- Update Zod v4 error code assertions (invalid_value, too_big)
- Update mimeType assertions for @mcp-ui/server v6.1.0 (text/html;profile=mcp-app)
- Fix PreviewStyleTool test mimeType expectation
* fix: reject cross-origin Link headers and redact tokens from logs
- Validate that pagination next-page URLs from Link response headers
share the same origin as the configured API endpoint; cross-origin
URLs are rejected to prevent access token exfiltration
- Add redactToken() utility that strips access_token query parameter
values from strings before they reach log output or MCP client error
responses (network errors include the full request URL in their
message which would otherwise expose the token)
- Remove full URL from info/debug level pagination log messages
* refactor: extract handleValidationError helper and include error details in validation failures
* test: assert validation error details are included in error response
* test: add validation error response tests for TilequeryTool and RetrieveStyleTool
0 commit comments