Repository navigation
Let a Leaf page frame another live Leaf page on the same machine - #5035
Merged
Merged
Conversation
Two pages on one machine run on two `leaf server` ports, and every served document carried `frame-ancestors 'self'`, so page a's `<iframe src="b's URL">` stayed empty with Chromium logging the refusal. A page's running server now adds to that policy the exact origin of every other Leaf server that holds its lease under the same state home (`PageEndpoint._frame_ancestors`, reading `presence.live_servers`). Those servers all serve with the state home's key (`server.host_key`), whose cookie already authorizes a bare link to each of them, so a framing page exposes nothing the key doesn't. The reading happens at each framed document, so a server started after the framed one is admitted; a server whose lease has ended is not, since its port may since belong to any process. A top-level navigation (`Sec-Fetch-Dest: document`) has no ancestors and skips the reading. A temporary server, with its own key and no record, and leaf.page keep `'self'` alone. `live_leaves` now reads the same `live_servers` walk, and `server.page_origin` is the one spelling of a page's origin, which `page_url` builds on. The sample child exemption moved from deleting the header afterwards to never setting it. validation.md's "Delivery policy" states the rule; it also said sample children carry the header, which they haven't since #2255. Cost, on a real persistent server beside 80 fake live neighbours (this Mac had 80 live servers): a top-level document answers in 1.9 ms against 1.8 ms with none; a framed one in 8.5 ms with an 1862-byte policy. Co-Authored-By: Claude Opus 5.5 <[email protected]>
live-samples.md said an ordinary served page appears in an `<iframe>` only inside a page of the same origin. A page this machine serves may now frame another, by the address `leaf page list` prints less its `?t=` key: the key in the framing page's own address already set the cookie the frame goes out under, and leaving it out keeps the key out of the page's source. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`page check --render` refused every page framing another live Leaf page: its
browser holds no key for the framed page, so the frame answered 401 and the
gate counted the console error against the framing page, whose author can't
fix it. The error's text also steered an agent toward putting the key in the
frame's `src`, which leaks the key and still fails, since the framed page's
server refuses the gate's origin as a framer.
The gate now answers each other live Leaf origin with a stand-in document
("Another Leaf page, checked on its own.") in each page and context it opens
(`render_gate.scheme.stand_in_other_leaves`, one route matching the origins
`presence.live_servers` names). A frame of any other address still loads and
fails as before. `test_a_frame_of_another_live_leaf_page_is_checked_on_its_own`
frames a live Leaf page and a temporary server's page: the gate reports only
the second, and with the stand-in disabled it also reports the first's 401.
`page check --render` on a framing page now passes, its screens showing the
stand-in.
A server at a bare IPv6 address is left out of `frame-ancestors`: CSP's source
grammar has no IPv6 literal, and Chromium logs such a source as an error on
every framed document. `TemporaryPageServer.origin` spells its origin through
`server.page_origin`. validation.md and live-samples.md say what the gate shows.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
leaf-agent
reviewed
Nov 2, 2026
leaf-agent
left a comment
Collaborator
There was a problem hiding this comment.
The render-check exemption currently reaches subresources as well as framed documents; the inline finding narrows it to the intended boundary.
`page check --render` answered every request under another live Leaf server's origin with the stand-in page, so a script, stylesheet, image or `fetch()` the framing page loaded from that server received HTML too. The stand-in now answers only a child frame's navigation; every other request falls back to its normal route and reaches the server, which refuses the gate's keyless browser as it would without the stand-in. The render gate test now also checks, on a page with the stand-in installed, that a `fetch()` to the live server gets that server's 401 while the frame beside it shows the stand-in. On the previous head the fetch received the stand-in's 200.
max-sixty
marked this pull request as ready for review
November 3, 2026 05:04
leaf-agent
approved these changes
Nov 3, 2026
leaf-agent
added a commit
that referenced
this pull request
Nov 3, 2026
…pages (#5216) The nightly guard `test_the_resources_a_fixture_owns_are_taken_from_that_fixture` failed because two tests closed a page they took from the `browser` fixture: the floating-box journey (added in #5054), and `test_a_frame_of_another_live_leaf_page_is_checked_on_its_own` in `tests/browser/test_render_gate.py` (added in #5035; it fails the guard on current main too). The fixture closes every context it lent at teardown, after `judge_watches` reads each page that is still open. Closing early skipped that reading for every Hypothesis example of the journey. Both tests now leave their pages for the fixture to close, and neither test's assertions change. Verified locally: the guard failed on main naming both files and passes now. The gate test passes. `tests/journeys/test_floating_box_motion.py` passes on Chromium and Firefox with every example's page left open until teardown (22 per engine, about 100 s, peak resident memory of the largest single process 1.9 GB). Closes #5172 — automated triage Co-authored-by: leaf-agent <[email protected]>
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.
A Leaf page can now show another Leaf page from the same machine in an
<iframe>. Before, pagea's frame of pagebstayed empty, because every served document carriedframe-ancestors 'self'and the two pages run on twoleaf serverports.Closes #5008
For Max
This moves a trust boundary, and you chose to land it. After this change, any live Leaf page's scripts can frame every other live page under the same state home and dress its decisions in a different interface. That includes third-party scripts a page loads, such as a charting library from a CDN. The key cookie already reached every port on the host, so such a script's requests to
balready carried it; what's new is that the script can showb's live controls inside its own page and cover them. Before, onlyb's own origin could do that. The case for it is that every page under the state home is the same user's, written by their agents, and already reachable with the same key. The cost is that a page's third-party scripts, trusted with that page, can now frame every live page.What changed
A page's running server now adds to
frame-ancestorsthe exact origin of every other Leaf server that holds its lease under the same state home (PageEndpoint._frame_ancestors, which readspresence.live_servers). Nothing is asked of page authors:a's source holds<iframe src="http://127.0.0.1:<b's port>/">, the bare address, and the key cookie from the user's arrival ataauthorizes it.bcan frame it. A server whose lease has ended is left out, since its port may since belong to any process.Sec-Fetch-Dest: document) has no ancestors to admit and skips the reading, so ordinary page loads pay nothing.--lifetime temporary), which has its own key and keeps no service record or row, and leaf.page still sendframe-ancestors 'self'alone.page check --renderanswers a frame of each other live Leaf page with a stand-in page ("Another Leaf page, checked on its own."), since its browser holds no key for that page and that page's server refuses the gate's origin as a framer (render_gate.scheme.stand_in_other_leaves). Without it, every framing page failed the check with a 401 console error its author couldn't fix, whose text pointed toward putting the key in thesrc. Only a child frame's navigation stands in: a script, stylesheet, image orfetch()the framing page loads from that server reaches the server as it would without the stand-in. A frame of any other address, a mistyped port included, still loads and fails.live_leaves(theothersmenu andpage list) now reads the samelive_serverswalk.server.page_originis the one spelling of a page's origin;page_urlandTemporaryPageServer.originbuild on it.validation.md's "Delivery policy" states the rule, and "Browser validation" the stand-in. "Delivery policy" also claimed sample children carry the header, which they haven't since Contain Leaf sample navigation while preserving native delivery #2255.live-samples.md, which told authors a served page frames only inside its own origin, now says a page may frame another live Leaf page by its address without the?t=key, and that the render check shows a stand-in there.browser/runtime/frame-visibility.jsthat said a framed Leaf document always has a same-origin parent now describes the cross-port case. That comment edit changes the runtime's source hash, sodist/kernel/kernel.jsonis rebuilt; no bundle changed.Security argument
SameSite=Strict,HttpOnly) is sent to every server on the page's host, Leaf or not, and a frame from another port is same-site. The browser test shows it: a frame request from another server's page at another port carries the key cookie.frame-ancestorsis the only defence against another local server framing a live page and dressing its decisions in a different interface.server.host_key). That key already authorizes a bare link to each of them, and theothersmenu links them. The framing ability itself is new, and "For Max" above says what it admits.service.json. Only a process running as the user can arrange that, and such a process can already read the key fromaccess.json.http://127.0.0.1:*would admit any local web server, such as a dev server on:3000, to frame a live page with the user's key cookie. The policy lists exact origins instead.server.running_server, which requires the server lease to be held and to name the recorded incarnation. A stale row orservice.jsonfor a stopped server admits nothing, so a foreign process that later binds a dead Leaf server's port can't frame. The list is read when each framed document is served; a back/forward cache restore could carry a list read before a framer stopped (an untested hypothesis).--host. A server started with--host NAMEis listed ashttp://NAME:<port>, the origin its URL names. Two pages served under the same name share a host, so the frame is same-site and the cookie flows into it as on loopback. The repro passes with both pages under--host localhost; a tailnet name wasn't tried.An independent review tried a missing or forged
Sec-Fetch-Dest(only ever yields the full list), a framer killed withkill -9('self'on the next request), a plainhttp.serveron the dead framer's port (refused although the cookie reachesb), temporary and other-state-home servers (excluded), and leaf.page (unchanged).Evidence
The issue's steps, scripted against a scratch
XDG_STATE_HOMEwith each page's server started byleaf server start --lifetime persistentandb's bare address ina's<iframe>:b's policy wasframe-ancestors 'self', the frame stayed empty, and Chromium loggedFraming 'http://127.0.0.1:59935/' violates the following Content Security Policy directive: "frame-ancestors 'self'".b's policy isframe-ancestors 'self' http://127.0.0.1:65327(a's origin). The frame showsb's heading, with no console messages.leaf page check --render apasses, and its screens show the stand-in in the frame.--lifetime temporary, as the issue's steps run, both before and after are refused. Each temporary server has a key of its own, so itssrcmust carry the key, and it keeps no record for another server to find. The fix applies toserver startandserver runwith the session or persistent lifetime, and toleaf-dev preview --user.Cost, on a real persistent server beside 80 fake live neighbours (this Mac's state home had 80 live servers at the time), 60 requests each:
Each live neighbour costs a framed document about 75 µs (a lease probe and two record reads).
A framed page, in Chromium and Firefox
Driven with Playwright,
aframingb(900×640) with anlf-optionsask inb:bpresents. Picking an option in the frame lands inb's log. A page comment typed inb's panel lands inb's log and opens its thread inb's panel, which sits inside the frame whilea's panel stays at the window's foot. Keys follow focus: after a click in the frame?opensb's keyboard reference, and after a click inait opensa's.localStorage, where drafts live, is shared between the framedbandbin a tab of its own.bcan't reada's frame element across origins, so it counts itself shown whenever its tab is, even scrolled out ofa's view (frameVisibility()is null on screen and scrolled away). A same-origin frame reads its frame element instead.breports the frame's viewport (900×640) as the user's window, so while that is its newest report,b'spage check --renderlaysbout at the frame's size.Tests
tests/process/test_interact_server.py::test_a_page_admits_frames_only_from_live_leaf_servers_under_its_key: a real persistent server's document names a live neighbour's origin exactly, and leaves out a neighbour whose server stopped. A mutation that read records without checking the leases failed it.tests/browser/startup/test_hosting.py::test_a_live_page_admits_only_leaf_parents_under_its_keyreplacestest_a_live_page_refuses_a_same_site_parent_at_another_port. One live child page is framed by another server's page at another port, which is refused although its frame request carries the key cookie, and by another live Leaf page, where it presents. That other server is a temporary Leaf server, standing in for any server on the host outside the live set. Onmain'shttp.pythe second frame is refused.tests/browser/test_render_gate.py::test_a_frame_of_another_live_leaf_page_is_checked_on_its_own: a page framing a live Leaf page and a temporary server's page fails the gate only for the second. With the stand-in disabled, it also fails for the first's 401. On a page with the stand-in installed, afetch()to the live server gets that server's 401 while the frame beside it shows the stand-in; when the stand-in answered every request to the origin (5d5a3b4), the fetch got its 200.page_url(neighbour discovery and rows, the served state schema, sample capabilities, the website's routes,page list, a network-facing bind, the IPv6 address); by node id, the two neighbour-row tests and the end-to-endpage check --rendertest that now live intests/journeys/; the two All pages browser tests intest_render_controls.pythat serve a live neighbour; the render gate test of a refused document and the hosting test of same-origin embedding;pnpm run test:runtime(750 passed),pnpm run check, and pre-commit on the changed files.tests/journeys/test_interact_server.py::test_server_round_trip, whose'self'assertion is on a temporary server and so unchanged; WebKit beyond a CSP grammar probe.