Skip to content

Validate exposedTo before registering AbortSignal algorithm - #240

Merged
domfarolino merged 2 commits into
webmachinelearning:mainfrom
beaufortfrancois:move-abort-signal
Aug 14, 2026
Merged

Validate exposedTo before registering AbortSignal algorithm#240
domfarolino merged 2 commits into
webmachinelearning:mainfrom
beaufortfrancois:move-abort-signal

Conversation

@beaufortfrancois

@beaufortfrancois beaufortfrancois commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Move the validation of options.exposedTo origins before attaching the unregister algorithm to options.signal in registerTool().

Previously, the abort algorithm was attached to the signal before origin validation. If exposedTo contained an invalid or untrustworthy origin, the promise was rejected with a SecurityError, but the abort algorithm remained attached to the signal and could inadvertently unregister a subsequently registered tool of the same name upon aborting.

Also reorder ModelContextRegisterToolOptions dictionary members and domintro definitions to match the processing order of options.

Fixed in Chromium: https://chromium-review.googlesource.com/c/chromium/src/+/8236351


Preview | Diff

Move the validation of `options.exposedTo` origins before attaching the
unregister algorithm to `options.signal` in `registerTool()`.

Previously, the abort algorithm was attached to the signal before origin
validation. If `exposedTo` contained an invalid or untrustworthy origin,
the promise was rejected with a `SecurityError`, but the abort algorithm
remained attached to the signal and could inadvertently unregister a
subsequently registered tool of the same name upon aborting.

Also reorder `ModelContextRegisterToolOptions` dictionary members and
domintro definitions to match the processing order of options.
@domfarolino

Copy link
Copy Markdown
Collaborator

So the only observable with this change is the buggy ability to unregister a later-registered, valid tool by the abort algorithm hanging around, right?

(I think this will be fixed regardless, once we end up with a UUID-keyed tool registry and Tool interface, but this is probably fine in the meantime).

@beaufortfrancois

Copy link
Copy Markdown
Collaborator Author

So the only observable with this change is the buggy ability to unregister a later-registered, valid tool by the abort algorithm hanging around, right?

Yes.

Comment thread index.bs
@domfarolino
domfarolino merged commit 7aa8235 into webmachinelearning:main Aug 14, 2026
2 checks passed
github-actions Bot added a commit that referenced this pull request Aug 14, 2026
SHA: 7aa8235
Reason: push, by domfarolino

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants