Allow sending Fetcher (service bindings) over RPC#5693
Merged
Conversation
33c33e0 to
c898b53
Compare
jasnell
reviewed
Dec 15, 2025
jasnell
reviewed
Dec 15, 2025
jasnell
reviewed
Dec 15, 2025
jasnell
reviewed
Dec 15, 2025
jasnell
reviewed
Dec 15, 2025
jasnell
reviewed
Dec 15, 2025
jasnell
reviewed
Dec 15, 2025
harrishancock
approved these changes
Dec 18, 2025
fb38fb0 to
c8019f4
Compare
c8019f4 to
17c8456
Compare
Fetchers, aka SerivceStubs, aka SubrequestChannels, point at a stateless entrypoint of some other Worker. DurableObjectClass stubs, aka ActarClassChannels, point at a DO class exported by some other Worker. Note: This is not the same thing as a Durable Object stub. A DurableObjectClass stub points at the class itself, independent of storage or any particular instances. It is used as part of Facets. We want to make both of these serializable. This commit defines a core format to do so (but doesn't hook it up yet). The serialization uses a byte string called a "channel token" (because it's a token obtained off a SubrequestChannel or ActorClassChannel, which can later be redeemed from IoChannelFactory for a new instance of the given channel type). A channel token encodes a (service name, entrypoint name, props) triplet. Note that it would be very bad if an attacker were able to specify such a triplet directly, particularly as `props` usually contains authorization details that we don't want an attacker to be able to forge! To that end, the channel token format is conservatively-designed at present: For RPC, the token is encrypted and MAC'd using an AES key which is generated uniquely for each process. This means that tokens are only valid within the same process where they were created, and there's no way to forge such a token unless you can see into the process's memory. In the future, we may loosen things to allow sending tokens between processes somehow. For now, though, this format has the nice side property that there is no backwards-compatibility expectation at all, so we're free to change it later. This commit also defines a format for tokens intended for long-term storage, e.g. to store in DO KV storage. Such tokens obviously cannot be signed by a per-process key since we want them to survive through process reloads. For the time being, we don't enrypt such tokens at all, but the feature will be hidden behind a new compat flag (defined in later commits) which will remain strictly experimental. This feature will eventually be replaced with a system that actually stores information about known "grants" in some separate storage, so that they can be audited and revoked.
(And also DurableObjectClass stubs.) For now, serialization for RPC is guarded by the common `experimental` compat flag, and serialization for storage is guarded by the extra flag `allow_irrevocable_stub_storage`.
If an RPC returns a Fetcher (newly allowed by previous commit), it should also accept pipelined calls to the Fetcher's methods.
Adds a test for this bug.
17c8456 to
d8f9149
Compare
Member
Author
|
Missed the daily release by 29 minutes. 😠 Oh well. |
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.
Fetchers, aka SerivceStubs, aka SubrequestChannels, point at a stateless entrypoint of some other Worker.
DurableObjectClass stubs, aka ActarClassChannels, point at a DO class exported by some other Worker. Note: This is not the same thing as a Durable Object stub. A DurableObjectClass stub points at the class itself, independent of storage or any particular instances. It is used as part of Facets.
We want to make both of these serializable.
The serialization uses a byte string called a "channel token" (because it's a token obtained off a SubrequestChannel or ActorClassChannel, which can later be redeemed from IoChannelFactory for a new instance of the given channel type).
A channel token encodes a (service name, entrypoint name, props) triplet. Note that it would be very bad if an attacker were able to specify such a triplet directly, particularly as
propsusually contains authorization details that we don't want an attacker to be able to forge!To that end, the channel token format is conservatively-designed at present:
For RPC, the token is encrypted and MAC'd using an AES key which is generated uniquely for each process. This means that tokens are only valid within the same process where they were created, and there's no way to forge such a token unless you can see into the process's memory. In the future, we may loosen things to allow sending tokens between processes somehow. For now, though, this format has the nice side property that there is no backwards-compatibility expectation at all, so we're free to change it later.
This PR also defines a format for tokens intended for long-term storage, e.g. to store in DO KV storage. Such tokens obviously cannot be signed by a per-process key since we want them to survive through process reloads. For the time being, we don't enrypt such tokens at all, but the feature will be hidden behind a new compat flag which will remain strictly experimental. This feature will eventually be replaced with a system that actually stores information about known "grants" in some separate storage, so that they can be audited and revoked.
For now, serialization for RPC is guarded by the common
experimentalcompat flag, and serialization for storage is guarded by the extra flagallow_irrevocable_stub_storage.