Repository navigation
Conversation
🧪 Code Coverage
Generated by coverage-comment.yml |
This was referenced Aug 20, 2026
This was referenced Aug 27, 2026
bartek-gralewicz
added a commit
that referenced
this pull request
Sep 17, 2026
…ize (#685) # Description - [x] Follow the CONTRIBUTING Guide - [x] Conventional Commits title - [x] Tests and linter pass - [x] Docs updated if necessary Fixes #679 ## Summary `RestTransportHandler.listTasks` used truthy `Number()` on query strings. `historyLength=0` became undefined, so listTasks returned full history instead of omitting it. `getTask` already keeps 0 via `parseHistoryLength`. The JS REST client sends `historyLength=0`, so a same-SDK call was wrong. `pageSize=abc` became NaN. The range check `pageSize < 1 || pageSize > 100` is false for NaN, so the store did `slice(0, NaN)` and returned an empty page with HTTP 200. Closed unmerged PR #625 called out the REST Number() hole. Open PR #639 caps historyLength at 1000 and does not fix the 0 drop or NaN pageSize. listTasks now reuses `parseHistoryLength` and adds `parsePageSize` (integer 1..100). DefaultRequestHandler.listTasks also rejects non-integer pageSize so JSON-RPC/gRPC cannot slip NaN through. ## Testing ``` npx --no-install vitest run test/server/rest_transport_handler.spec.ts test/server/default_request_handler.spec.ts ``` 130 passed. Signed-off-by: Anas Khan <[email protected]> Co-authored-by: bartek-gralewicz <[email protected]>
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.
What changed
1. Validate push notification URLs before sending
Problem: Webhook URLs from client-supplied
TaskPushNotificationConfigwere POSTed as-is to whatever target the config named — loopback, private-network, link-local or cloud-metadata endpoints included — and HTTP redirects were followed with no re-checking, so a config pointing at a public URL could be redirected onto an internal endpoint in a second hop.Fix (
DefaultPushNotificationSender):http/httpsand must not target loopback, private (RFC 1918 / ULA / CGNAT), link-local, unspecified or multicast literal addresses (IPv4 and IPv6, including IPv4-mapped::ffff:forms),localhost, or well-known cloud metadata hostnames (metadata.google.internal,metadata.azure.com,metadata.goog).redirect: 'manual') with every hop re-validated against the same checks (max 10 hops); the notification token /Authorizationheader is dropped when a hop crosses to a different host.allowPrivateNetworksoption (defaultfalse, guard enabled) lets trusted internal deployments opt out — e.g. a webhook hosted on the same host or private network.Behavior change: senders now refuse private targets by default; deployments that intentionally push to same-host or private webhooks must pass
allowPrivateNetworks: true. Validation is static (literal address + hostname checks); DNS resolution happens insidefetchat connection time, so hostname-based DNS-rebinding is not covered.2. Strict parsing of
pageSize/historyLengthin RESTlistTasksProblem:
listTasksparsedpageSizeandhistoryLengthwith bareNumber(). Non-numeric query values becameNaN, which slips through the1..100range check (NaN < 1isfalse) and makesslice(-NaN)behave likeslice(0)—historyLength=abcreturned the full task history andpageSize=abcreturned an empty page, instead of a malformed-request error.Fix (
RestTransportHandler.listTasks):pageSizeis parsed withparseIntand validated as an integer in1..100.historyLengthnow reuses the existingparseHistoryLength(same asgetTask), rejecting non-integers and negative values.RequestMalformedError.Testing
allowPrivateNetworksopt-out), 4 forlistTasksparsing.allowPrivateNetworks: true.tsc(source + test configs),npm run build(tsup), andnpm run test-build(workers-safe / grpc / express bundles) all pass.