Bug: workerdDebugPort fetcher fails requireAllowsTransfer() when used inside Proxy-based WorkerEntrypoint#6074
Closed
Bug: workerdDebugPort fetcher fails requireAllowsTransfer() when used inside Proxy-based WorkerEntrypoint#6074
Conversation
…zing the Fetcher JsRpcProperty has JSG_WILDCARD_PROPERTY, so fetcher.ping.apply creates another JsRpcProperty for path 'ping.apply'. Calling that serializes the fetcher argument, hitting requireAllowsTransfer(). Fix: use fetcher[methodName](...args) instead of method.apply(fetcher, args).
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.
Bug Report:
.apply()on JsRpcProperty silently chains through wildcard propertySummary
JsRpcProperty(returned by wildcard property access onFetcher, e.g.fetcher.ping) hasJSG_CALLABLE+JSG_WILDCARD_PROPERTY. Because it's a callable object (viaSetCallAsFunctionHandler) rather than av8::Function, it does not inheritFunction.prototype.apply/call/bind.Accessing
.applyon aJsRpcPropertyhits the wildcard handler instead, creating a newJsRpcPropertyfor the pathping.apply. Calling that makes an RPC call, serializing all arguments — including anyFetcherpassed asthis.This is a footgun:
typeof method === 'function'returnstrue, butmethod.apply(...)does something completely different from what you'd expect.Reproduction
samples/debug-port-rpc-repro/— a Proxy-basedWorkerEntrypointthat forwards arbitrary RPC methods via a debug port fetcher.The broken pattern:
The fix:
Impact
Any code that does
typeof x === 'function'and then uses.apply()or.call()will silently do the wrong thing onJsRpcProperty. This is particularly likely in proxy/forwarding patterns (miniflare'sExternalServiceProxy, generic RPC forwarders).Possible improvements
JsRpcProperty/ RPC stubs are callable objects, not Functions.apply/.call/.bindon JsRpcProperty — intercept these names in the wildcard handler and either throw a clear error or delegate toFunction.prototypeinstanceof Functionand.apply()work as expected