Repository navigation
fix(url): reject "." and ".." path parameters so URL resolution can't change the route - #1390
Closed
alexb-openrouter wants to merge 1 commit into
Closed
alexb-openrouter wants to merge 1 commit into
alexb-openrouter wants to merge 1 commit into
Conversation
… change the route
Contributor
|
I'll fix CI failures and address comments from users with write access that start with 'Devin'.
|
mattapperson
added a commit
that referenced
this pull request
Nov 11, 2026
…hange the route Generated operations percent-encode path parameters, which leaves "." and ".." unchanged, and ClientSDK._createRequest resolves the path with new URL(path, baseURL), which collapses dot segments. A path parameter of exactly ".." or "." sent the request, with the client's API key, to a different route. pathToFunc now throws before any request is built. src/lib/url.ts is added to .genignore and hand-maintained, because persistent edits are off and neither a hook, an overlay nor gen.yaml can express the check. gen.lock drops the file's tracking entry, as the generator does for ignored files. Supersedes #1390.
Contributor
|
Closing in favour of #1372, which carries this fix. #1372 turns Speakeasy persistent edits off, so a hand edit to the generated |
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.
Summary
Risk: code that passes an untrusted value as a path parameter (for example
containerIdfrom an end user or a tool call) could set it to exactly..or..encodeURIComponentleaves those values unchanged, andnew URL(path, baseURL)inClientSDK._createRequestthen resolves them as dot segments, so the request goes to a different/api/v1route with the app's API key attached. Example:The request still carries only the app's own key and can reach only what that key can already reach. The problem is that it bypasses any container-only restriction the app relies on.
Fix:
pathToFunc(src/lib/url.ts), which every operation uses to fill path templates, now throws when an encoded parameter is exactly.or... No request is sent. All other values are left alone....,.envanda..bare not dot segments and still pass.%2e%2ewas already double-encoded to%252e%252e. Errors for missing or non-string parameters already work this way.src/lib/url.tsis a Speakeasy-generated file.persistentEditsis enabled in.speakeasy/gen.yaml, so this edit should survive regeneration. Worth checking on the next generate run.Tests:
tests/unit/path-param-dot-segments.test.tsruns the SDK against a mock server on127.0.0.1. It checks that a normal container download hits the container route, and thatcontainerId../.andfileId..throw without sending any request. It also checks thepathToFuncedge cases directly. These tests fail onmainand pass with this change.pnpm run test,pnpm run lintandpnpm run typecheckpass.