Repository navigation
fix(api): refuse request endpoints that ids would reshape - #189
Open
Gabrielpanga wants to merge 2 commits into
Open
Gabrielpanga wants to merge 2 commits into
Gabrielpanga wants to merge 2 commits into
Conversation
Ids interpolated into request paths were sent as-is, so a value containing "?", "&", "/" or "#" could change the request that was actually made. Path values now go through a urlPath tagged template that applies encodeURIComponent to each interpolated segment, and fetchIdentityByItemId passes itemId as a query parameter instead of concatenating it into the path. Plain UUIDs are unchanged on the wire.
…ry path Replace the urlPath tagged template with one check in createGetRequest and createMutationRequest: an endpoint built from caller-provided ids must not contain a query or fragment delimiter, a percent sequence, a backslash, whitespace or control characters, a dot segment, or an empty, leading or trailing slash segment. Query parameters always go through params, so no legitimate endpoint has any of these; the request is refused instead of being sent with a different shape. Call sites are unchanged, and valid ids are sent exactly as before. fetchIdentityByItemId passes itemId as a query parameter.
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.
Summary
accounts/${id}, …). An id containing?,#,..or an empty value could change the request actually sent. Follow-up to fix(api): URL-encode query string values #184, which encoded query values.createGetRequestandcreateMutationRequest(assertSafeEndpoint): an endpoint must not contain a query/fragment delimiter, a%sequence, a backslash, whitespace/control characters, a dot segment, or an empty/leading/trailing slash segment. Query parameters always go throughparams, so no legitimate endpoint has these. Unsafe endpoints throw before any request is made.fetchIdentityByItemIdnow passesitemIdthroughparamsinstead of buildingidentity?itemId=…by hand./inside an id still reads as a path separator (can't be told apart from the template's own slashes at this point).Test plan