Skip to content

fix(core): reject dot segments in API request paths - #470

Merged
BryanFRD merged 3 commits into
mainfrom
fix/463-reject-dot-segments
Oct 25, 2026
Merged

BryanFRD merged 3 commits into
mainfrom
fix/463-reject-dot-segments

Conversation

@BryanFRD

Copy link
Copy Markdown
Contributor

encodeURIComponent leaves . and .. untouched, so an id argument of .. retargets the request to a parent route once fetch normalizes the URL.

apiRequest now throws InvalidApiPathError for any . or .. path segment before fetching. The check lives in mcp-core, so every tool and product server built on it is covered without touching each schema.

Tests cover rejected paths (including with a query string) and allowed dots inside a segment or the query.

Closes #463

@ferrfleet-interne ferrfleet-interne Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking: percent-encoded (%2e%2e) and backslash dot segments get past assertNoDotSegments, and fetch still normalises them away. Fix inline. The rest looks right: the error class, the export, and where the check runs (before assertCredentialTarget).

Comment thread packages/mcp-core/src/api-client.ts Outdated

@ferrfleet-interne ferrfleet-interne Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The earlier finding is fixed in 1860687: %2e and backslash segments are now rejected and tested. Blocking: tabs and newlines inside a segment still get past the check (see inline).

Comment thread packages/mcp-core/src/api-client.ts Outdated

@ferrfleet-interne ferrfleet-interne Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tab/newline bypass is fixed in 6172fc0: tab, LF and CR are stripped before splitting, %2e is decoded afterwards, and both cases are in the test table. No blocking findings left. I couldn't run node here, so this rests on reading the URL spec, not on running the tests.

@BryanFRD
BryanFRD merged commit 4fbb97b into main Oct 25, 2026
16 checks passed
@BryanFRD
BryanFRD deleted the fix/463-reject-dot-segments branch October 25, 2026 10:40
ferrflow Bot added a commit that referenced this pull request Oct 25, 2026
## [10.14.2] - 2026-10-25

### Bug Fixes

- fix(core): reject dot segments in API request paths (#470)
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.

fix(tools): validate id and slug arguments so dot segments cannot retarget the request path

1 participant