Repository navigation
fix: reject dot-segment path parameters - #1440
Open
ankita10119 wants to merge 1 commit into
Open
ankita10119 wants to merge 1 commit into
ankita10119 wants to merge 1 commit into
Conversation
Path parameters that are exactly "." or ".." now throw InvalidPathParameterError before any request is sent, matching the behaviour added in v7.6.0.
This branch has not been deployed
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.
Changes
Path parameters are encoded with
encodeURIComponent, which leaves.unchanged. When a path parameter is exactly.or.., URL parsing infetchremoves it as a dot segment, so the request (with the Management API token attached) is sent to a different path than the one the method targets. For example,users.getRoles({ id: '..' })was sent asGET /api/v2/rolesinstead ofGET /api/v2/users/../roles.src/lib/runtime.ts:BaseAPI.createFetchParamsnow validates the request path before building the URL. Any path segment equal to.or..throws. Since every path parameter is encoded (so it can't contain/) and no static path template contains a dot segment, this one check covers every method onManagementClient,AuthenticationClientandUserInfoClientwithout changing generated code.src/lib/errors.ts: addsInvalidPathParameterError, exported from the package root....,a.b,auth0|abc.defand%2e%2eare unaffected (%2e%2eis encoded as%252e%252e). Query-string values are not checked.No endpoints were added, removed or deprecated. The only behaviour change: a call whose path parameter is exactly
.or..now throwsInvalidPathParameterErrorinstead of being sent to a different endpoint.This release also fixes the
auth0/legacyentrypoint in 5.x–7.x, which depends onauth0@^4.37.1. Users get it by refreshing their lockfile (for example,npm update auth0-legacy).Alternative considered: percent-encoding
.as%2E. That doesn't work, because WHATWG URL parsing also treats%2e%2e,.%2eand%2e.as.., so these values are rejected instead. This matches the fix in v7.6.0.References
src/management/core/url/encodePathParam.ts)Testing
New tests in
test/lib/runtime.test.ts:..and.throwInvalidPathParameterError, and no request is sent/oauth/tokenrequest is made when the path parameter is rejected...anda.bare still sent normallyWithout the
runtime.tschange, the three rejection tests fail.Verified locally:
npm run lint,npm run buildandnpm run lint:packagepassnpm run test:ci: 52/52 suites, 1809/1809 tests on Node 18.20.8, 22.19.0 and 24.0.1fetch(Node 18 and 24):.and..send nothing; normal IDs are unchangedusers.getRoles({ id: '..' })toGET /api/v2/rolesand gets a 200; the patched build throws and sends nothing. Normal calls (users.getAll,users.get,users.getRoles,roles.getAll,clients.getAll) return the same results on both builds.Checklist