Repository navigation
fix: catch dot segments hidden behind backslashes and whitespace - #1168
Merged
dielduarte merged 3 commits intoOct 30, 2026
Merged
dielduarte merged 3 commits into
dielduarte merged 3 commits into
Conversation
The URL parser treats a backslash as a path separator in http(s) URLs, drops tabs and newlines, and trims trailing control characters before resolving dot segments, so ids like "..\api-keys" or ".\t." slipped past hasDotSegment and reached another endpoint.
Abhishek-B-R
requested review from
felipefreitag
and removed request for
a team
October 18, 2026 07:32
Author
|
@felipefreitag friendly bump on this follow-up to #1139: hasDotSegment now also catches ids like |
commit: |
dielduarte
self-requested a review
October 30, 2026 21:17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
follow up to #1139. the dot segment check splits the path on
/only, but the URL parser thatfetchuses does a bit more before it resolves..:\is a path separator, same as/so an id like
..\api-keys\key-idor.\t.passeshasDotSegmentand still gets resolved into a different endpoint.repro
built the sdk from main, swapped
fetchfor one that logsnew Request(url, init).url(what fetch actually sends):domains.remove('..\\api-keys\\key-id')DELETE /api-keys/key-idinvalid_parameteremails.cancel('.\t.')POST /cancelinvalid_parameteremails.get('..\n')GET /invalid_parametersame idea as #1139: if an app passes user input as an id, these get out of the endpoint the call was meant for.
fix
hasDotSegmentnow strips tabs and newlines, trims trailing control characters and spaces, and splits segments on both/and\. the rest is unchanged. a space in the middle of a path is still percent encoded by the parser rather than dropped, so/emails/.. /cancelis still allowed, and there's a test for that.tests
has-dot-segment.spec.ts: backslash separated.., tab and newline inside the dots, trailing\r, space and NULresend.spec.ts:domains.remove('..\\api-keys\\key-id')andemails.cancel('.\t.')returninvalid_parameterand nothing is sentboth new specs fail on main and pass here.
pnpm test(772 passed, 4 todo),pnpm typecheck,pnpm lintandpnpm buildall pass.Summary by cubic
Fixes
hasDotSegmentto catch dot segments hidden behind backslashes and whitespace that the URL parser strips before resolving.., so ids like..\api-keys\key-idor.\t.no longer reach a different endpoint./and\, and strips tabs, newlines, and trailing control characters before checking.invalid_parameterwithout sending.6.36.1.Written for commit 4927ba3. Summary will update on new commits.