Conversation
origin_allowed() only checked that a connecting page's Origin header was shaped like a Chrome extension origin (chrome-extension:// plus 32 lowercase a-p characters), never which specific extension it was. Every installed extension's origin has exactly this shape, so any other extension in the same browser profile was accepted identically to BrowserSkill's own extension, gaining full control of the daemon and, through it, of the user's real, already-logged-in browser. Adds ExtensionPinStore (mirroring the existing AuthorizationStore atomic-write pattern used for remote-mode device grants) and wires it into handle_connection: the first extension origin to complete a WS upgrade is pinned and persisted, and any other origin is rejected from then on. Includes a live end-to-end test against the real WS server.
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.
Fixes #273.
Adds
ExtensionPinStore(mirroring the existingAuthorizationStoreatomic-write pattern already used for remote-mode device grants indaemon/remote/authorization.rs) and wires it intohandle_connection: the first extension origin to complete a WS upgrade is pinned and persisted to~/.bsk/extension-pin.json, and any other origin is rejected from then on with a policy close.origin_allowed()itself is unchanged (it still validates the origin's shape, as before) since this fix layers identity pinning on top of it rather than replacing it.Includes a live end-to-end test (
crates/bsk-cli/tests/extension_pin_ws.rs) that binds a realWsServerto a real local port and performs real WebSocket handshakes with two distinct extension origins, confirming the first pins and the second is rejected while the first can still reconnect. All 151 pre-existingdaemon::unit tests, including the fiveorigin_allowlist_*tests covering the unchanged shape check, still pass.