Skip to content

Item 7.16: opaque-response blocking for scripts, sheets and no-cors fetch(), proven (theorem_orb) - #307

Merged
atiernan merged 4 commits into
mainfrom
claude/kernel-7-16-cors
Nov 25, 2026
Merged

atiernan merged 4 commits into
mainfrom
claude/kernel-7-16-cors

Conversation

@atiernan

@atiernan atiernan commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Item 7.16's script-fetch rule (7.0(c) S1): opaque-response blocking on every "no-cors" response, proven (theorem_orb), with ORB itself transcribed and proven in clazel-fetch.

Inventory: what main (035eb42) already had for 7.16

Piece State on main Where
Fetch IPC message (fetch() and XHR), FetchResponse/FetchBody/FetchEnd/FetchFailed built, codec proven clazel-ipc tag 20, 119-122 (#29x, commits 5a326d1, 9b5fd88)
Forbidden request headers removed proven: theorem_forbidden_headers; clazel-fetch's req_ok refuses any request still carrying one api_theorems.rs, clazel-fetch request spec
Origin set by the kernel yes, from the lock, on every mode "cors" request (and on POST) clazel-fetch request spec
Referer set by the kernel no: no Referer is ever sent (a page cannot set one; the kernel sends none, as policy "no-referrer" would) listed below
CORS check proven: cors_check and theorem_cors_read (credentials mode "same-origin" only) spec.rs, api_theorems.rs
CORS preflight (§4.8) not built: a request that would need one is refused listed below
Redirects re-checked at every hop yes: credentials decided per hop (credentialed on the transducer's current URL, theorem_subfetch_credentials), page headers dropped on a cross-origin redirect, redirect-taint makes the CORS origin null; redirect mode (follow/error/manual) is not in the message spec.rs
ORB on no-cors responses missing: FetchScript and FetchStyle handed cross-origin bodies over whole this PR
theorem_script_fetch_shape proven subfetch_theorems.rs
theorem_url_update_same_origin proven url_rel.rs
theorem_popup_needs_input, javascript: URLs proven (#301) popup_theorems.rs
theorem_cookie_noninterference, theorem_address_bar_integrity restated over the new messages proven (noninterference re-proven with FetchScript, Fetch, UpdateUrl, OpenTab; the address bar names the document URL) ni_theorem.rs, display_theorems.rs, url_rel.rs, popup_rel.rs
S1: cross-origin credentials: "include" goes without cookies holds trivially: the Fetch message has no credentials field, every request is "same-origin" credentials, so cross-origin hops never carry cookies. "omit" and "include"'s stricter CORS check are not expressible listed below

What this PR adds

clazel-fetch: orb (spec, contract, exec, lemmas, examples, tests, 10 certified mutations).

  • ORB is not in the Fetch Standard at the commit the transducer pins (59afe349). The WHATWG text is whatwg/fetch pull request #1442 (open, unmerged); orb/spec.rs pins its head commit c58393bf0b9e2a86abee916c3cef3361f2741567 and transcribes §2.11.1 "The opaque-response-safelist check" (steps 1 to 15) and §2.11.2's three MIME type sets, with Fetch §3.5 "extract a MIME type", §3.6 "determine nosniff", §2.2.2 "get, decode, and split" and §2.2.3 "ok status" at the pinned commit. Section numbers were read at those commits (no †).
  • Modelling choices (in the spec header): the result is Allowed / Blocked / JavaScriptCheck (step 15, "determine if response is JavaScript and not JSON", is left to the caller); no-cors media request state is always "N/A" (no media elements); every 206 counts as an invalid partial response (no request carries Range; stricter than the standard); the first 1024 bytes are never failure (the body is complete); "extract a MIME type" omits its charset bookkeeping (ORB reads only type, subtype and essence).
  • Lemmas: safelisted types are allowed; never-sniffed types are blocked; with nosniff an HTML/JSON/XML type is blocked even with image bytes; a 206 is blocked unless safelisted; media bytes are blocked; untyped image bytes are allowed; untyped ok responses are allowed (step 13); a typed, non-safelisted response that does not sniff as an image is never Allowed.
  • tests/orb.rs: every step that can decide, all 35 never-sniffed essences (typed independently of the hex literals), header-name case, multiple values, quoted commas.

clazel-kernel: ORB on every "no-cors" sub-fetch.

  • Style sheets and scripts: a response that is not basic (final URL not of the lock's origin, or redirect-tainted) and that ORB does not allow is StyleFailed / ScriptFailed (orb_end, through api_finish).
  • Fetch in mode "no-cors": the opaque response now needs ORB; otherwise FetchFailed (api_end).
  • Kernel choices (listed in src/spec.rs and the README): ORB's step 15 is not run and a response reaching it is blocked (a cross-origin script served as text/plain or application/octet-stream fails to load); the check is also applied to a final 3xx without Location, which Fetch exempts.
  • theorem_orb (new, in Cargo.toml's list): for every SubNet on a "no-cors" sub-fetch (style, script, or Fetch mode 2), every frame to a renderer is the sub-fetch's failure frame unless the transducer ended with a response that is basic or that ORB allows.
  • Citations corrected to the pinned commit: the CORS check is §4.10 and HTTP fetch §4.4 there (the kernel said §4.9 and §4.3, and phase-7.md's †§4.9 is off by one too; the preflight is §4.8 as the plan says).
  • Solver hygiene (no change in meaning): orb_allows is a closed function in its own module (src/orb.rs, with lemma_orb_allows stating its definition), because carrying MIME parsing and sniffing in every step proof's context made lemma_d_subnet run for many minutes at 10+ GB; orb_end is #[verifier::opaque]; api_finish calls orb_end only when the fetch ended. lemma_d_subnet hides api_end and uses two new by-ending-action lemmas; lemma_run_acts hides the sub-fetch functions. The full kernel now verifies in under 4 minutes locally (1083 verified, 0 errors).
  • 3 new certified kernel mutations (ORB skipped for sheets and scripts; no-cors opaque response without ORB; redirect-taint ignored for basic), and no-cors-gives-body re-anchored (its find names the new api_end line; its certificate's lemma now fixes the response it speaks of, since the old one held for every response and no longer does; expect unchanged). The certificates that evaluate ORB live in src/orb.rs, where the closed body is visible.

Not done (still open for 7.16)

  • CORS preflight (§4.8). Needs an OPTIONS request with Access-Control-Request-* (headers req_ok forbids an author to send, so a separate field in clazel-fetch's Req), a non-redirecting transducer run, a second phase in SubFetch, and the noninterference relation over it. Until then every request that would need one is refused (as before).
  • Credentials mode in Fetch ("omit", and "include" with the include-mode CORS check and S1's no-cookies deviation). The message has no field for it; S1's cookie rule holds because every request is credentials "same-origin".
  • Redirect mode (follow / error / manual) in Fetch.
  • Referer: never sent.
  • ORB's step 15 (a JavaScript parse in the kernel) — blocked instead.
  • Fetch's "should response to request be blocked due to nosniff" / "due to MIME type" for script and style destinations (separate from ORB; also applies same-origin).
  • ORB's WPT tests (fetch/orb/) need script; hand-written tests only.
  • No independent transcription of ORB yet (the README at annevk/orb 61c1be7 differs in its never-sniffed list and in step 15, so it is not a second transcription of the same text).

Verification

Local cargo xtask verify --changed (58 min; kernel Verus 1083 verified, 0 errors; kernel 105/105 and fetch 97/97 mutations certified kills), last line verbatim:

RESULT: CHANGED CRATES PASSED (4 of 65 crates' proofs and tests run, against 035eb429ccef9dcdccc5be6ceea46a8c4be16317; CI's full `cargo xtask verify` is the gate)

This is not ALL CHECKS PASSED.

CI has not run on this branch; the proof jobs need a full-verification approval. Nothing here is done until Full verification is green.

🤖 Generated with Claude Code

atiernan and others added 4 commits November 25, 2026 00:42
clazel-fetch gains orb::spec, a transcription of the opaque-response-safelist
check of whatwg/fetch pull request #1442 (head c58393bf), with Fetch's
"extract a MIME type" and "determine nosniff" at the pinned commit, and
orb::contract for the executable check.

clazel-kernel spec: a style sheet or script fetch whose response is not basic
fails unless ORB allows it (orb_end, through api_finish), and a no-cors
Fetch's opaque response needs ORB too (api_end). theorem_orb's statement is
in statements.rs. The CORS check and HTTP fetch section numbers are corrected
to the pinned commit (§4.10, §4.4).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
orb::check is the executable opaque-response-safelist check, with extract a
MIME type and determine nosniff, proven equal to orb::spec. orb::lemmas states
what the check's design rests on (safelisted types allowed, never-sniffed
types blocked, HTML/JSON/XML never allowed unless they sniff as an image and
blocked outright with nosniff, 206 and media bytes blocked, untyped image
bytes and untyped ok responses allowed); orb::examples evaluates the check on
concrete responses. Ten mutations of the spec are certified kills.
tests/orb.rs runs the exec check on hand-written responses, every
never-sniffed essence among them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tem 7.16)

The exec kernel runs clazel_fetch's ORB check where the spec does
(orb_blocks_exec in the SubNet step, orb_allows_exec in api_end_exec), and
theorem_orb is proven over SubNet: a no-cors sub-fetch's renderer gets its
failure frame unless the response is basic or ORB allows it.

Meaning-preserving changes to the spec since its contract commit, for the
solver: orb_allows is a closed function in its own module (src/orb.rs), with
lemma_orb_allows for the proofs that read it, because carrying MIME parsing
and sniffing in the noninterference proofs' context ran them out of time;
orb_end is opaque; api_finish calls orb_end only when the fetch ended.
lemma_d_subnet hides api_end and uses two by-ending-action lemmas;
lemma_run_acts hides the sub-fetch functions.

Tests: ORB through the kernel in tests/fetch_api.rs (scripts, sheets and
no-cors fetch(); the support decoder now groups Script* frames).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three new kills: ORB skipped for style sheets and scripts (ml_orb_blocks_sheet),
a no-cors Fetch's opaque response without ORB (ml_no_cors_orb_blocks), and a
redirect-tainted response counted as basic (ml_orb_checks_tainted). The
certificates that evaluate ORB sit in src/orb.rs, where orb_allows's body is
visible. no-cors-gives-body is re-anchored on the new api_end line, and its
lemma now names the response it is about (ORB allows it), since the old
lemma held for every response; its expect is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@atiernan
atiernan temporarily deployed to full-verification November 25, 2026 03:02 — with GitHub Actions Inactive
@atiernan
atiernan added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit 8b39b38 Nov 25, 2026
19 checks passed

This branch was previously deployed

1 inactive deployment
full-verification — 71ab5e39 Deployed Nov 25, 2026 by atiernan via Approve the proofs #826
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.

1 participant