fix(app-shell): close the remaining paths out of the application page

Review of the renderer policy found loads it did not see or judged
wrongly:

- Loads Servo does not attribute to the webview, such as
  navigator.sendBeacon(), reached the network. They are all refused.
- On a redirect Servo reports the first URL again, so every redirect
  is refused.
- A symbolic link inside the UI directory led anywhere on disk; file
  loads are checked again after resolving links.
- Only about:blank is allowed among about: URLs.

The Servo pin moves to 5d90f51, which keeps compiled classic scripts
rooted until they run (a parser-blocking script waiting for a failed
stylesheet import crashed the content process) and withholds
navigator.servo from about:blank and about:srcdoc documents.

The confinement check gains probes for links, workers, beacons,
imports, fonts and srcdoc frames, and its WebSocket server completes
the handshake. The slow stylesheet's delay now starts when the host
first tries to open it.
This commit is contained in:
Marco Allegretti 2026-10-09 10:03:30 +00:00
parent d60152f443
commit 16a184ad9e
No known key found for this signature in database
12 changed files with 269 additions and 140 deletions

110
Cargo.lock generated
View file

@ -6590,7 +6590,7 @@ dependencies = [
[[package]]
name = "servo"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"accesskit",
"bitflags 2.11.0",
@ -6651,7 +6651,7 @@ dependencies = [
[[package]]
name = "servo-allocator"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"libc",
"tikv-jemalloc-sys",
@ -6662,7 +6662,7 @@ dependencies = [
[[package]]
name = "servo-background-hang-monitor"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"backtrace",
"crossbeam-channel",
@ -6677,7 +6677,7 @@ dependencies = [
[[package]]
name = "servo-background-hang-monitor-api"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"serde",
"servo-base",
@ -6686,7 +6686,7 @@ dependencies = [
[[package]]
name = "servo-base"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"accesskit",
"crossbeam-channel",
@ -6711,7 +6711,7 @@ dependencies = [
[[package]]
name = "servo-canvas"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"bytemuck",
"crossbeam-channel",
@ -6736,7 +6736,7 @@ dependencies = [
[[package]]
name = "servo-canvas-traits"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"crossbeam-channel",
"euclid",
@ -6758,7 +6758,7 @@ dependencies = [
[[package]]
name = "servo-config"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"serde",
"serde_json",
@ -6770,7 +6770,7 @@ dependencies = [
[[package]]
name = "servo-config-macro"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"proc-macro2",
"quote",
@ -6781,7 +6781,7 @@ dependencies = [
[[package]]
name = "servo-constellation"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"backtrace",
"content-security-policy",
@ -6828,7 +6828,7 @@ dependencies = [
[[package]]
name = "servo-constellation-traits"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"content-security-policy",
"encoding_rs",
@ -6863,7 +6863,7 @@ dependencies = [
[[package]]
name = "servo-deny-public-fields"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"syn",
"synstructure",
@ -6872,7 +6872,7 @@ dependencies = [
[[package]]
name = "servo-devtools"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"atomic_refcell",
"base64 0.22.1",
@ -6901,7 +6901,7 @@ dependencies = [
[[package]]
name = "servo-devtools-traits"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"bitflags 2.11.0",
"http 1.4.0",
@ -6920,7 +6920,7 @@ dependencies = [
[[package]]
name = "servo-dom-struct"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"proc-macro2",
"quote",
@ -6930,7 +6930,7 @@ dependencies = [
[[package]]
name = "servo-embedder-traits"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"accesskit",
"bitflags 2.11.0",
@ -6963,7 +6963,7 @@ dependencies = [
[[package]]
name = "servo-fonts"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"app_units",
"bitflags 2.11.0",
@ -7016,7 +7016,7 @@ dependencies = [
[[package]]
name = "servo-fonts-traits"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"atomic_refcell",
"dwrote",
@ -7039,7 +7039,7 @@ dependencies = [
[[package]]
name = "servo-geometry"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"app_units",
"euclid",
@ -7052,7 +7052,7 @@ dependencies = [
[[package]]
name = "servo-hyper-serde"
version = "0.13.2"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"cookie 0.18.1",
"headers 0.4.1",
@ -7066,7 +7066,7 @@ dependencies = [
[[package]]
name = "servo-jstraceable-derive"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"proc-macro2",
"syn",
@ -7076,7 +7076,7 @@ dependencies = [
[[package]]
name = "servo-layout"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"accesskit",
"app_units",
@ -7130,7 +7130,7 @@ dependencies = [
[[package]]
name = "servo-layout-api"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"app_units",
"atomic_refcell",
@ -7164,7 +7164,7 @@ dependencies = [
[[package]]
name = "servo-malloc-size-of"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"accountable-refcell",
"app_units",
@ -7204,7 +7204,7 @@ dependencies = [
[[package]]
name = "servo-media"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"once_cell",
"servo-media-audio",
@ -7217,7 +7217,7 @@ dependencies = [
[[package]]
name = "servo-media-audio"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"byte-slice-cast",
"euclid",
@ -7240,7 +7240,7 @@ dependencies = [
[[package]]
name = "servo-media-derive"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"proc-macro2",
"quote",
@ -7250,7 +7250,7 @@ dependencies = [
[[package]]
name = "servo-media-dummy"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"ipc-channel",
"servo-media",
@ -7264,7 +7264,7 @@ dependencies = [
[[package]]
name = "servo-media-player"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"ipc-channel",
"malloc_size_of_derive",
@ -7278,7 +7278,7 @@ dependencies = [
[[package]]
name = "servo-media-streams"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"malloc_size_of_derive",
"servo-malloc-size-of",
@ -7288,7 +7288,7 @@ dependencies = [
[[package]]
name = "servo-media-thread"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"euclid",
"ipc-channel",
@ -7306,7 +7306,7 @@ dependencies = [
[[package]]
name = "servo-media-traits"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"malloc_size_of_derive",
"servo-malloc-size-of",
@ -7315,7 +7315,7 @@ dependencies = [
[[package]]
name = "servo-media-webrtc"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"log",
"servo-media-streams",
@ -7325,7 +7325,7 @@ dependencies = [
[[package]]
name = "servo-metrics"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"malloc_size_of_derive",
"servo-base",
@ -7340,7 +7340,7 @@ dependencies = [
[[package]]
name = "servo-net"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"async-compression",
"async-recursion",
@ -7409,7 +7409,7 @@ dependencies = [
[[package]]
name = "servo-net-traits"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"content-security-policy",
"cookie 0.18.1",
@ -7449,7 +7449,7 @@ dependencies = [
[[package]]
name = "servo-paint"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"bitflags 2.11.0",
"crossbeam-channel",
@ -7486,7 +7486,7 @@ dependencies = [
[[package]]
name = "servo-paint-api"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"bitflags 2.11.0",
"crossbeam-channel",
@ -7522,7 +7522,7 @@ dependencies = [
[[package]]
name = "servo-pixels"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"euclid",
"image",
@ -7537,7 +7537,7 @@ dependencies = [
[[package]]
name = "servo-profile"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"libc",
"log",
@ -7556,7 +7556,7 @@ dependencies = [
[[package]]
name = "servo-profile-traits"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"crossbeam-channel",
"ipc-channel",
@ -7573,7 +7573,7 @@ dependencies = [
[[package]]
name = "servo-script"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"aes",
"aes-gcm",
@ -7712,7 +7712,7 @@ dependencies = [
[[package]]
name = "servo-script-bindings"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"bitflags 2.11.0",
"crossbeam-channel",
@ -7750,7 +7750,7 @@ dependencies = [
[[package]]
name = "servo-script-traits"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"accesskit",
"content-security-policy",
@ -7787,7 +7787,7 @@ dependencies = [
[[package]]
name = "servo-storage"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"libc",
"log",
@ -7817,7 +7817,7 @@ dependencies = [
[[package]]
name = "servo-storage-traits"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"malloc_size_of_derive",
"serde",
@ -7831,7 +7831,7 @@ dependencies = [
[[package]]
name = "servo-timers"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"crossbeam-channel",
"malloc_size_of_derive",
@ -7841,7 +7841,7 @@ dependencies = [
[[package]]
name = "servo-tracing"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"proc-macro2",
"quote",
@ -7851,7 +7851,7 @@ dependencies = [
[[package]]
name = "servo-url"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"encoding_rs",
"malloc_size_of_derive",
@ -7865,7 +7865,7 @@ dependencies = [
[[package]]
name = "servo-webgl"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"bitflags 2.11.0",
"byteorder",
@ -7889,7 +7889,7 @@ dependencies = [
[[package]]
name = "servo-webgpu"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"arrayvec",
"euclid",
@ -7908,7 +7908,7 @@ dependencies = [
[[package]]
name = "servo-webgpu-traits"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"arrayvec",
"malloc_size_of_derive",
@ -7924,7 +7924,7 @@ dependencies = [
[[package]]
name = "servo-webxr"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"crossbeam-channel",
"euclid",
@ -7943,7 +7943,7 @@ dependencies = [
[[package]]
name = "servo-webxr-api"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"euclid",
"ipc-channel",
@ -7959,7 +7959,7 @@ dependencies = [
[[package]]
name = "servo-xpath"
version = "0.0.1"
source = "git+https://github.com/marcoallegretti/servo?rev=f0bb1aaf981b65c8dddc848bb647045d4c777d11#f0bb1aaf981b65c8dddc848bb647045d4c777d11"
source = "git+https://github.com/marcoallegretti/servo?rev=5d90f51cf8156cd7f244a42e15f199c531116c21#5d90f51cf8156cd7f244a42e15f199c531116c21"
dependencies = [
"log",
"malloc_size_of_derive",

View file

@ -95,7 +95,7 @@ See `docs/security.md`. Key points:
## Servo fork
- Servo: `https://github.com/marcoallegretti/servo` at `f0bb1aaf`, pinned by revision
- Servo: `https://github.com/marcoallegretti/servo` at `5d90f51c`, pinned by revision
- Stylo: `https://github.com/marcoallegretti/stylo` at `f1ba4969`, through the root `[patch]`
- Patches: `backdrop-filter` parsing (Stylo) and rendering (Servo)
- Patches: `backdrop-filter` parsing (Stylo) and rendering (Servo), rooting of compiled classic scripts and `navigator.servo` exposure (Servo)
- See `crates/weft-servo-shell/SERVO_PIN.md` for Servo integration status and known limitations

View file

@ -27,7 +27,7 @@ toml = { version = "0.8", optional = true }
[dependencies.servo]
git = "https://github.com/marcoallegretti/servo"
rev = "f0bb1aaf981b65c8dddc848bb647045d4c777d11"
rev = "5d90f51cf8156cd7f244a42e15f199c531116c21"
optional = true
default-features = false

View file

@ -48,6 +48,16 @@ impl ServoDelegate for WeftServoDelegate {
fn notify_error(&self, error: servo::ServoError) {
tracing::error!(?error, "Servo error");
}
/// Loads not tied to the webview, such as `navigator.sendBeacon()`,
/// worklets and notification icons, also come from the application page,
/// and none of them is needed: all are refused.
fn load_web_resource(&self, load: servo::WebResourceLoad) {
let url = load.request().url.clone();
tracing::warn!(%url, "resource load outside the webview denied");
load.intercept(servo::WebResourceResponse::new(url))
.cancel();
}
}
/// Frame and load progress reported by Servo, shared with the event loop.
@ -65,6 +75,8 @@ struct WeftWebViewDelegate {
signals: Arc<FrameSignals>,
/// URL prefix of the application's UI directory; see `ui_scope`.
scope: String,
/// The UI directory with symbolic links resolved, if it exists.
ui_dir: Option<std::path::PathBuf>,
/// The bridge's WebSocket handshake URL, as the network layer requests it
/// (`ws:` becomes `http:`).
bridge: String,
@ -87,14 +99,18 @@ impl WebViewDelegate for WeftWebViewDelegate {
}
}
/// Every resource the page loads passes through here, including
/// `fetch()`, XHR, subresources, redirects and WebSocket handshakes. The
/// page may read its own UI files and open the session bridge; any other
/// local file or network destination is refused with a network error.
/// Network access belongs to the component, under its fetch grants.
/// Every resource the webview loads passes through here, including
/// `fetch()`, XHR, subresources and WebSocket handshakes. The page may
/// read its own UI files and open the session bridge; any other local
/// file or network destination is refused with a network error. Network
/// access belongs to the component, under its fetch grants.
///
/// On a redirect Servo reports the first URL of the chain again, not the
/// target, so every redirect is refused.
fn load_web_resource(&self, _webview: servo::WebView, load: servo::WebResourceLoad) {
let url = load.request().url.clone();
if resource_allowed(url.as_str(), &self.scope, &self.bridge) {
let request = load.request();
let url = request.url.clone();
if !request.is_redirect && self.allows(&ServoUrl::from_url(url.clone())) {
return;
}
tracing::warn!(%url, "resource outside the application denied");
@ -160,15 +176,37 @@ fn in_scope(url: &str, scope: &str) -> bool {
})
}
/// Whether an application page may load `url`: a file inside its UI
/// directory, an inline (`data:`, `blob:`, `about:`) resource, or the session
/// bridge.
fn resource_allowed(url: &str, scope: &str, bridge: &str) -> bool {
in_scope(url, scope)
|| url == bridge
|| ["data:", "blob:", "about:"]
.iter()
.any(|scheme| url.starts_with(scheme))
impl WeftWebViewDelegate {
/// Whether an application page may load `url`: a file inside its UI
/// directory, also after resolving symbolic links, an inline (`data:`,
/// `blob:`) resource, `about:blank`, or the session bridge.
fn allows(&self, url: &ServoUrl) -> bool {
match url.scheme() {
"file" => {
in_scope(url.as_str(), &self.scope)
&& self.ui_dir.as_deref().is_some_and(|dir| {
url.to_file_path()
.ok()
.and_then(|path| path.canonicalize().ok())
.is_some_and(|path| path.starts_with(dir))
})
}
"data" | "blob" => true,
"about" => url.as_str() == "about:blank",
_ => url.as_str() == self.bridge,
}
}
}
/// The UI directory behind the URL prefix `scope`, with symbolic links
/// resolved.
fn ui_dir(scope: &str) -> Option<std::path::PathBuf> {
ServoUrl::parse(scope)
.ok()?
.to_file_path()
.ok()?
.canonicalize()
.ok()
}
/// `value` as a single-quoted JavaScript string literal.
@ -457,6 +495,7 @@ impl ApplicationHandler<ServoWake> for App {
.delegate(Rc::new(WeftWebViewDelegate {
signals: Arc::clone(&self.signals),
scope: ui_scope(&self.url),
ui_dir: ui_dir(&ui_scope(&self.url)),
bridge: format!("http://127.0.0.1:{}/app", self.ws_port),
}))
.user_content_manager(ucm)

View file

@ -27,7 +27,7 @@ tungstenite = "0.24"
[dependencies.servo]
git = "https://github.com/marcoallegretti/servo"
rev = "f0bb1aaf981b65c8dddc848bb647045d4c777d11"
rev = "5d90f51cf8156cd7f244a42e15f199c531116c21"
optional = true
default-features = false

View file

@ -6,13 +6,17 @@ The selected revisions are the ones recorded in the workspace `Cargo.lock`.
| Dependency | Source | Revision | Selected by |
|------------|--------|----------|-------------|
| Servo (`servo` crate) | <https://github.com/marcoallegretti/servo> | `f0bb1aaf981b65c8dddc848bb647045d4c777d11` | `rev` in both shell crates' `Cargo.toml` |
| Servo (`servo` crate) | <https://github.com/marcoallegretti/servo> | `5d90f51cf8156cd7f244a42e15f199c531116c21` | `rev` in both shell crates' `Cargo.toml` |
| Stylo (`stylo`, `selectors`, `servo_arc`, ...) | <https://github.com/marcoallegretti/stylo> | `f1ba4969536d63f2e319a561e466c03e78b4a076` | `[patch."https://github.com/servo/stylo"]` in the root `Cargo.toml` |
The Servo revision is `servo-weft` commit `8e7dc40` (backdrop-filter rendering)
plus `f0bb1aa`, which fixes that commit's `servo-layout` build errors. It lives
on the fork branch `fix/backdrop-filter-build-errors` until it is merged into
`servo-weft`; keep that branch until then so the revision stays fetchable.
The Servo revision is `servo-weft` commit `8e7dc40` (backdrop-filter rendering),
plus `f0bb1aa`, which fixes that commit's `servo-layout` build errors, plus
`b87e5a6`, which keeps compiled classic scripts rooted until they run, and
`5d90f51`, which withholds `navigator.servo` from `about:blank` and
`about:srcdoc` documents. It lives
on the fork branch `fix/root-pending-classic-scripts`, which is based on
`fix/backdrop-filter-build-errors`, until both are merged into `servo-weft`;
keep those branches until then so the revisions stay fetchable.
Servo's own `[patch]` table for Stylo does not apply to WEFT, because Cargo
only honours patches in the root workspace. Without the root override, WEFT
@ -37,7 +41,7 @@ servo-embed = ["dep:servo", "dep:winit", "dep:softbuffer"]
[dependencies.servo]
git = "https://github.com/marcoallegretti/servo"
rev = "f0bb1aaf981b65c8dddc848bb647045d4c777d11"
rev = "5d90f51cf8156cd7f244a42e15f199c531116c21"
optional = true
default-features = false
@ -155,7 +159,7 @@ exercised is listed as unverified.
rather than tracking a branch, so a rebuild selects the same code. A pinned
revision must stay reachable from a published branch: never force-push,
rebase or delete a branch that contains a revision a WEFT lockfile selects.
Today Servo `f0bb1aa` is reachable only from `fix/backdrop-filter-build-errors`
Today Servo `5d90f51` is reachable only from `fix/root-pending-classic-scripts`
and Stylo `f1ba496` only from Stylo's `servo-weft`.
To move to new revisions:
@ -182,3 +186,5 @@ Each fork patch keeps its purpose, upstream status and removal condition here.
| Stylo: parse `backdrop-filter` for Servo | stylo `f1ba496` | Remove the `layout.unimplemented` gate | Not submitted | Upstream Stylo parses it for Servo |
| Servo: render `backdrop-filter` | servo `8e7dc40` | Stacking context and display list support | servo/servo issue [#41567](https://github.com/servo/servo/issues/41567) | Equivalent upstream support |
| Servo: fix `build_backdrop_filter` types | servo `f0bb1aa` | Make `servo-layout` compile | Part of the patch above | Same as above |
| Servo: root compiled classic scripts | servo `b87e5a6` | A parser-blocking script waiting for a stylesheet was freed by a garbage collection and crashed the content process when it ran | Not submitted | Upstream roots or traces `ClassicScript::record` |
| Servo: no `navigator.servo` for blank and srcdoc documents | servo `5d90f51` | An application's `about:srcdoc` frame could change engine preferences | Not submitted | Upstream limits `ServoInternals` exposure the same way |

View file

@ -16,7 +16,7 @@ System UI host. Renders one WebView pointing at `system-ui.html` using the embed
### weft-app-shell
Per-application Servo host. Spawned by `weft-appd` after the Wasm runtime signals READY. Takes `<app_id>` and `<session_id>` as arguments. Resolves `weft-app://<app_id>/ui/index.html` and injects the `weftIpc` WebSocket bridge into the page. The bridge authenticates with the per-session token from `WEFT_BRIDGE_TOKEN` and can only exchange messages with its own session. It is installed only in top-level documents inside the application's UI directory, and top-level navigation outside that directory is denied; framed documents never receive the bridge. Every resource the page loads (subresources, `fetch()`, XHR, redirects and WebSocket handshakes) is checked by the shell: the page may load files inside its UI directory, inline `data:`, `blob:` and `about:` resources, and the session bridge; any other local file or network destination fails with a network error. Network access belongs to the Wasm component, under its fetch grants. Registers with the compositor as window type `application`. Exits when the appd session ends.
Per-application Servo host. Spawned by `weft-appd` after the Wasm runtime signals READY. Takes `<app_id>` and `<session_id>` as arguments. Resolves `weft-app://<app_id>/ui/index.html` and injects the `weftIpc` WebSocket bridge into the page. The bridge authenticates with the per-session token from `WEFT_BRIDGE_TOKEN` and can only exchange messages with its own session. It is installed only in top-level documents inside the application's UI directory, and top-level navigation outside that directory is denied; framed documents never receive the bridge. Every resource the page loads (subresources, `fetch()`, XHR, workers and WebSocket handshakes) is checked by the shell: the page may load files inside its UI directory, also after symbolic links are resolved, inline `data:` and `blob:` resources, `about:blank` and the session bridge; any other local file or network destination, and every redirect, fails with a network error. Loads Servo does not attribute to the webview, such as `navigator.sendBeacon()`, are all refused. Network access belongs to the Wasm component, under its fetch grants. Servo's privileged `navigator.servo` interface, which can change engine preferences, is not exposed to `about:blank` or `about:srcdoc` documents (a fork patch; see `crates/weft-servo-shell/SERVO_PIN.md`). Registers with the compositor as window type `application`. Exits when the appd session ends.
### weft-appd

View file

@ -13,7 +13,7 @@ let
# One hash per git source in Cargo.lock: the Servo fork and the Stylo fork
# (keyed by its `selectors` crate). Every package vendors both, so both must
# match the pinned revisions. Recompute them whenever a revision changes.
# The Servo hash is not yet known for f0bb1aa; a Nix build reports it.
# The Servo hash is not yet known for 5d90f51; a Nix build reports it.
outputHashes = {
"servo-0.0.1" = pkgs.lib.fakeHash;
"selectors-0.36.0" = "13y6pa19j4w2zsxfhv6mrl03wsa0frazlsssbqkzpwci8k9gzl4i";

View file

@ -9,21 +9,29 @@ The page probes, and paints one band per probe:
- the session bridge reaches the component, which answers;
- an image just outside its UI directory (../outside.png) fails to load;
- an image elsewhere on disk (a file: URL) fails to load;
- an image reached through a symbolic link in the UI directory fails to load;
- an image from a local HTTP server fails to load;
- a no-cors fetch from that server is rejected;
- a WebSocket to a local listener fails.
- a WebSocket to a local server that completes the handshake fails;
- a no-cors fetch from a worker is rejected;
- an about:srcdoc frame has no navigator.servo, which could change engine
preferences.
The page also imports a stylesheet, loads a font and sends a beacon to the
HTTP server, and frames an about:srcdoc document showing an image from it.
Each refused probe would succeed without the policy: the images are valid,
the fetch accepts an opaque response and the listener accepts connections.
Every band must be green, and the HTTP server and the TCP listener must see
no connection at all, so the refusals happen in the renderer, not after a
request left it.
the fetches accept an opaque response and the WebSocket server accepts the
upgrade. Every band must be green, and the HTTP server and the WebSocket
server must see no connection at all, so the refusals happen in the
renderer, not after a request left it.
Requires Xvfb, xwd and ImageMagick's convert.
"""
import argparse
import base64
import hashlib
import http.server
import shutil
import socket
@ -40,8 +48,8 @@ from check_counter import AppdClient, free_port, read_endpoint # noqa: E402
from session import ROOT, Desktop, SessionError, missing_tools, parse_ppm, pixel # noqa: E402
APP_ID = "org.weft.test.confinement"
PROBES = ["own-image", "bridge", "outside-image", "other-image", "http-image", "http-fetch",
"websocket"]
PROBES = ["own-image", "bridge", "outside-image", "other-image", "linked-image", "http-image",
"http-fetch", "websocket", "worker-fetch", "srcdoc-internals"]
GREEN = (0, 192, 0)
# The app window's page area on the 1024x768 nested desktop.
PAGE_TOP, PAGE_HEIGHT, PAGE_X = 35, 600, 400
@ -59,10 +67,10 @@ def png():
class Counting(http.server.BaseHTTPRequestHandler):
requests = 0
requests = []
def do_GET(self):
Counting.requests += 1
Counting.requests.append(f"{self.command} {self.path}")
body = png()
self.send_response(200)
self.send_header("Content-Type", "image/png")
@ -71,49 +79,79 @@ class Counting(http.server.BaseHTTPRequestHandler):
self.end_headers()
self.wfile.write(body)
do_POST = do_GET
def log_message(self, *args):
pass
def make_package(store, http_port, tcp_port, other):
package = store / APP_ID
(package / "ui").mkdir(parents=True)
(package / "wapp.toml").write_text(
f'[package]\nid = "{APP_ID}"\nname = "Confinement"\nversion = "0.1.0"\n'
'[runtime]\nmodule = "app.wasm"\n[ui]\nentry = "ui/index.html"\n')
shutil.copy(ROOT / "examples/org.weft.demo.counter/app.wasm", package / "app.wasm")
page = (Path(__file__).parent / "confinement/index.html").read_text()
page = (page.replace("@HTTP_PORT@", str(http_port)).replace("@TCP_PORT@", str(tcp_port))
.replace("@OTHER_URL@", other.as_uri()))
(package / "ui/index.html").write_text(page)
(package / "ui/own.png").write_bytes(png())
(package / "outside.png").write_bytes(png())
other.write_bytes(png())
def run(args, desktop, store):
server = http.server.ThreadingHTTPServer(("127.0.0.1", 0), Counting)
threading.Thread(target=server.serve_forever, daemon=True).start()
def websocket_server(connections, stop):
"""A listener that completes WebSocket handshakes, so a WebSocket that
reaches it opens. Returns its port."""
listener = socket.socket()
listener.bind(("127.0.0.1", 0))
listener.listen()
listener.settimeout(0.2)
connections = []
def accept():
def serve():
while not stop.is_set():
try:
connection = listener.accept()[0]
except OSError:
continue
connections.append(connection)
connection.close()
stop = threading.Event()
threading.Thread(target=accept, daemon=True).start()
connection.settimeout(5)
try:
make_package(store, server.server_port, listener.getsockname()[1],
store.parent / f"{store.name}-other.png")
request = b""
while b"\r\n\r\n" not in request:
chunk = connection.recv(4096)
if not chunk:
break
request += chunk
key = next((line.split(b":", 1)[1].strip() for line in request.split(b"\r\n")
if line.lower().startswith(b"sec-websocket-key:")), b"")
accept = base64.b64encode(hashlib.sha1(
key + b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest())
connection.sendall(b"HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\n"
b"Connection: Upgrade\r\nSec-WebSocket-Accept: " + accept
+ b"\r\n\r\n")
except OSError:
pass
listener.close()
threading.Thread(target=serve, daemon=True).start()
return listener.getsockname()[1]
def make_package(store, http_port, ws_port, other_dir):
package = store / APP_ID
(package / "ui").mkdir(parents=True)
(package / "wapp.toml").write_text(
f'[package]\nid = "{APP_ID}"\nname = "Confinement"\nversion = "0.1.0"\n'
'[runtime]\nmodule = "app.wasm"\n[ui]\nentry = "ui/index.html"\n')
shutil.copy(ROOT / "examples/org.weft.demo.counter/app.wasm", package / "app.wasm")
fixture = Path(__file__).parent / "confinement"
other = other_dir / "other.png"
page = (fixture / "index.html").read_text()
page = (page.replace("@HTTP@", f"http://127.0.0.1:{http_port}/")
.replace("@WS@", f"ws://127.0.0.1:{ws_port}/")
.replace("@OTHER_URL@", other.as_uri()))
(package / "ui/index.html").write_text(page)
shutil.copy(fixture / "worker.js", package / "ui/worker.js")
(package / "ui/own.png").write_bytes(png())
(package / "outside.png").write_bytes(png())
other.write_bytes(png())
(package / "ui/linked").symlink_to(other_dir)
def run(args, desktop, store, other_dir):
server = http.server.ThreadingHTTPServer(("127.0.0.1", 0), Counting)
threading.Thread(target=server.serve_forever, daemon=True).start()
stop = threading.Event()
connections = []
ws_port = websocket_server(connections, stop)
try:
make_package(store, server.server_port, ws_port, other_dir)
t = Path(args.target)
desktop.launch_client("appd", [t / "weft-appd"], {
"WEFT_RUNTIME_BIN": str(t / "weft-runtime"),
@ -143,12 +181,11 @@ def run(args, desktop, store):
if failed:
raise AssertionError(f"probes not as required: {failed} ({colours})")
if Counting.requests or connections:
raise AssertionError(f"requests left the renderer: {Counting.requests} HTTP, "
f"{len(connections)} TCP")
raise AssertionError(f"requests left the renderer: HTTP {Counting.requests}, "
f"{len(connections)} WebSocket")
finally:
stop.set()
server.shutdown()
listener.close()
def main(argv=None):
@ -168,11 +205,12 @@ def main(argv=None):
print("missing: " + ", ".join(missing), file=sys.stderr)
return 2
store = Path(tempfile.mkdtemp(prefix="weft-store-"))
other_dir = Path(tempfile.mkdtemp(prefix="weft-other-"))
try:
with Desktop(args.compositor, args.output, outputs=["appd.log", "confinement.ppm"]) \
as desktop:
try:
run(args, desktop, store)
run(args, desktop, store, other_dir)
except AssertionError:
(args.output / "confinement.ppm").write_bytes(desktop.capture())
raise
@ -182,7 +220,7 @@ def main(argv=None):
return 1
finally:
shutil.rmtree(store, ignore_errors=True)
(store.parent / f"{store.name}-other.png").unlink(missing_ok=True)
shutil.rmtree(other_dir, ignore_errors=True)
print("confinement check passed")
return 0

View file

@ -106,23 +106,33 @@ def install_app(store, page):
def slow_style(directory, delay):
"""Create `directory/reveal.css`, a stylesheet revealing the page, that
cannot be opened until `delay` seconds have passed. A write lease makes
any other process's open() wait until the lease is released. The
stylesheet is a local file next to the page, so an application host
confined to its UI directory may load it."""
cannot be opened until `delay` seconds after the host first tries to. A
write lease makes another process's open() wait until the lease is
released, and the kernel signals the holder when an open() starts
waiting. The stylesheet is a local file next to the page, so an
application host confined to its UI directory may load it."""
sheet = directory / "reveal.css"
sheet.write_text("body { visibility: visible; }", encoding="utf-8")
# The kernel signals the lease holder when another open() waits on it.
signal.signal(signal.SIGIO, signal.SIG_IGN)
lease = os.open(sheet, os.O_WRONLY)
fcntl.fcntl(lease, fcntl.F_SETLEASE, fcntl.F_WRLCK)
held = threading.Event()
def release():
time.sleep(delay)
fcntl.fcntl(lease, fcntl.F_SETLEASE, fcntl.F_UNLCK)
os.close(lease)
threading.Thread(target=release, daemon=True).start()
def opening(_signal, _frame):
if not held.is_set():
held.set()
timer = threading.Timer(delay, release)
timer.daemon = True
timer.start()
signal.signal(signal.SIGIO, opening)
try:
fcntl.fcntl(lease, fcntl.F_SETLEASE, fcntl.F_WRLCK)
except OSError as error:
os.close(lease)
raise SessionError(f"cannot hold back {sheet} with a file lease: {error}") from error
def hidden_until_styled(page, destination):

View file

@ -4,9 +4,12 @@
<meta charset="utf-8">
<title>confinement</title>
<style>
@import url('@HTTP@style.css');
@font-face { font-family: probe; src: url('@HTTP@font.woff'); }
html, body { margin: 0; height: 100%; }
body { display: flex; flex-direction: column; }
body { display: flex; flex-direction: column; font-family: probe; }
div { flex: 1; background: #808080; }
iframe { position: absolute; width: 1px; height: 1px; border: 0; }
</style>
</head>
<body>
@ -14,17 +17,24 @@
<div id="bridge"></div>
<div id="outside-image"></div>
<div id="other-image"></div>
<div id="linked-image"></div>
<div id="http-image"></div>
<div id="http-fetch"></div>
<div id="websocket"></div>
<div id="worker-fetch"></div>
<div id="srcdoc-internals"></div>
<span>probe</span>
<iframe srcdoc="<img src='@HTTP@srcdoc.png'><script>parent.postMessage('servo:' + typeof navigator.servo, '*');</script>"></iframe>
<script>
// One band per probe: green when the outcome matches the policy, red when it
// does not. Every refused probe would succeed without the policy: the images
// are valid PNG files, the fetch uses no-cors, so an opaque response would
// resolve it, and the WebSocket listener accepts connections. The harness
// substitutes the ports and the path of a file outside the package.
var HTTP = 'http://127.0.0.1:@HTTP_PORT@/';
var TCP = 'ws://127.0.0.1:@TCP_PORT@/';
// are valid PNG files, the fetches use no-cors, so an opaque response would
// resolve them, and the WebSocket listener completes the handshake. The
// stylesheet import, the font, the frame's image and the beacon have no band;
// the harness requires that none of them reaches its server. The harness
// substitutes the server URLs and the path of a file outside the package.
var HTTP = '@HTTP@';
var WS = '@WS@';
var OTHER = '@OTHER_URL@';
function mark(id, ok) {
@ -40,19 +50,39 @@ function image(id, src, shouldLoad) {
image('own-image', 'own.png', true);
image('outside-image', '../outside.png', false);
image('other-image', OTHER, false);
image('linked-image', 'linked/other.png', false);
image('http-image', HTTP + 'image.png', false);
fetch(HTTP + 'probe', { mode: 'no-cors' }).then(
function () { mark('http-fetch', false); },
function () { mark('http-fetch', true); });
try {
var ws = new WebSocket(TCP);
var ws = new WebSocket(WS);
ws.onopen = function () { mark('websocket', false); };
ws.onerror = function () { mark('websocket', true); };
} catch (e) {
mark('websocket', true);
}
try {
var worker = new Worker('worker.js');
worker.onmessage = function (event) { mark('worker-fetch', event.data === 'refused'); };
worker.onerror = function () { mark('worker-fetch', false); };
worker.postMessage(HTTP + 'worker');
} catch (e) {
mark('worker-fetch', false);
}
// A srcdoc frame holds this page's content and must not reach the engine's
// privileged navigator.servo interface.
addEventListener('message', function (event) {
if (typeof event.data === 'string' && event.data.indexOf('servo:') === 0) {
mark('srcdoc-internals', event.data === 'servo:undefined');
}
});
try { navigator.sendBeacon(HTTP + 'beacon', 'probe'); } catch (e) {}
(function bridge() {
if (!window.weftIpc) { setTimeout(bridge, 50); return; }
window.weftIpc.onmessage = function (raw) {

View file

@ -0,0 +1,6 @@
// Reports whether a fetch to the URL it is sent leaves the worker.
onmessage = function (event) {
fetch(event.data, { mode: 'no-cors' }).then(
function () { postMessage('fetched'); },
function () { postMessage('refused'); });
};