Repository navigation
fix(browser): refuse agent calls into granted frames by origin, with inheritance, on every path - #451
Merged
Merged
Conversation
…inheritance, on every path
# Conflicts: # apps/browser-engine/src/engine.rs
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 READER-9 C3 on #411 (
notes/review-rd-engine.md, 21 Nov). An agent could act inside an embedded site that holds an inherited grant (clipboard-read, location, notifications), even though #411 refuses agent calls into granted frames.Cause:
target_frame_urlpicked one frame and decided by its URL. A blank orsrcdocchild of the granted frame reads asabout:blank, an opaque URL that holds no grant, so the call was let through. It also checked only the app's frame claim or the context, neverparams.frameIdor argument objects. It was never checked again at reply time, andInput.*was checked only against the main frame.Fix: decide by origin with inheritance, on every path.
EngineCdpLedger::reachlists every frame a call can act in: the app's frame claim,params.frameId, the frames ofcontextId/executionContextId,objectIdand eacharguments[*].objectId, and the session's own root. For an object the engine did not resolve, it reads the context from V8's<isolate>.<context>.<id>id. Some calls reach the whole tab:Input.*(input lands under the pointer or in the focused frame),uniqueContextId, and any context or object the engine cannot place.frame_originsgives the origins a frame can run as: thesecurityOriginChromium reports, its URL, and every ancestor's origin forabout:blank,about:srcdocand frames with nothing committed yet. A frame the engine does not know, or an overflowed frame table, fails closed.UploadFiles(its target session and frame, which feat(browser): complete OOPIF pointer/upload/drop coords, HTML5 drag interception, request postData fallback, and trace/cpu auto-stop timers #446 added) /DropFiles(whole tab).CdpPending::Raw.reachis checked again inrefuse_reply, so a grant or a navigation while the call is in flight refuses the reply. ADOM.getNodeForLocationhit is checked against the frame it lands in.Defaulttab while any of its frames runs as a granted origin. Key events go to the focused frame, so no narrower rule is safe. The person's own input is not affected.Proof: READER-9's nesting case (
C:\tmp\opencode\ws1\prove-c3-granted-frames.ts, Windows, scratch profile). Un-grantedlocalhostembeds the OOPIF127.0.0.1, which holdsnotificationsALLOW. That frame holds anabout:blankchild and asrcdocchild. A same-shaped OOPIF on127.0.0.2with no grant is the control.dev)Runtime.evaluatebycontextIdin the granted frame'sabout:blankchild["about:blank","granted"]srcdocchild["about:srcdoc","granted"]Accessibility.getFullAXTree { frameId: <granted> }with a different frame claimInput.dispatchMouseEventover the granted frameInput.dispatchMouseEventover the granted frameRuntime.evaluatein flight when its frame's origin gains a grantobjectIdarguments use the samereachpath. The proof could not reach them end to end: the typed path takes only engine-resolved objects, and the granted frame's child frame ids are never sent to the app. Regressions on the same build:prove-passkeys.ts,prove-404.tsand the C1/C2 proof all pass.Checked on
dev(merged in before merge): engine build +tools\cargo.ps1 check --locked -p opencode-desktop.ENGINE_REVISIONstays5(dev = 5, published = 4). Zero test edits, zero.github/edits.Also fixes the wrong-reason refusal while a tab's first page loads (found during the C1/C2 proof). Before a controlled tab's first document commits, Chromium reports its frame's
securityOriginas://.target_frame_urlfell back to that origin.has_inherited_default_grant("://")fails closed (unparseable), so typed calls got "Controlled browser actions are blocked on this site because it holds a profile permission" when no grant existed.frame_originsskips://andnulland walks to the URL or the parent instead. Probe:C:\tmp\opencode\ws1\probe-load-refusal.tssends 30 alternating typed and raw calls during a 1.5 s first load, in a profile with no grants. Wrong-reason refusals:dev8, 8, 9 (three runs); this branch 0, 0, 0.