Skip to content

fix(csp): enforce child image policies across redirects and cache reuse - #1790

Open
ldm0 wants to merge 3 commits into
mainfrom
fix/child-image-csp-inheritance-20261021
Open

ldm0 wants to merge 3 commits into
mainfrom
fix/child-image-csp-inheritance-20261021

Conversation

@ldm0

@ldm0 ldm0 commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Images in inherited about:blank/srcdoc Documents matched img-src 'self' against the local document URL and incorrectly rejected creator-origin resources. Capture the CSP matching URL in the policy container when a document is created or receives a navigation response, retain it through local-document snapshots, and update it on network document commits. Keep base-URL resolution, sandboxed Window origins, and violation report document URLs independent.

Retain the final response URL with cached image metadata and recheck it for each requesting Document before reuse. Recheck redirected image responses against the owning Document's img-src with FollowedRedirect semantics before publishing an image result. Cross-origin violations produce an image error and an owner-scoped violation event; Report-Only continues loading. This is a final-response check: automatic redirects have already issued their HTTP requests. Blocking each forbidden next-hop request is a separate transport integration step.

CSS image admission also checks the owning Document before shared-resource reuse or network dispatch. The image response check covers its redirected responses as well. This existing CSS gap is isolated in its own commit.

Regression coverage includes ordinary/sandboxed srcdoc, about:blank, nested local Documents, inherited response-header CSP, changed base URLs, network-navigation policy replacement, real same-origin/cross-origin redirects, redirect path matching, Report-Only, and CSS image admission. Tests observe load/error, owner violation reports, and real HTTP request logs.

The original inheritance fix addresses 5399724fb07a24935531b92c42621be1baa8c089 (#1714). No Cases snapshot or internal notes are included.

Validation on final head b0f0f85ab7e (rebased onto main baf87cfb248):

  • cargo fmt --all
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo nextest run --no-fail-fast: 20,893 passed, 19 skipped, no retries. All seven new regression tests passed.

Review follow-ups are separated into 01335b63551 (document policy sources, redirected image responses, cached response validation) and b0f0f85ab7e (CSS image admission and shared decoded-cache validation).

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Sequential Navigation Soak A/B

✅ HEAD completed the 200-navigation resilience and memory observation.

One browser process, one target, and one CDP session navigate CSDN → SegmentFault → Huaban → example.com repeatedly. This run issued 200 Page.navigate commands per binary.

Common ancestor baf87cfb24 → HEAD b0f0f85ab7; benchmark order: base-first; workflow: success.

Session resilience

Metric Base HEAD
Attempted / planned 200 / 200 200 / 200
Direct observable pass 199 / 200 199 / 200
Failures / recovered 1 / 1 1 / 1
Recovery failures 0 0
Lifecycle order violations 0 0
Network order violations 0 0
Wall time 410.1 s 417.5 s

A public-page failure is reported separately from an unrecoverable session. The soak requires all navigation attempts, zero failed recovery, zero lifecycle/network ordering violations, and complete resource evidence.

Process-tree memory

Metric Base HEAD Δ
Boundary samples 200 200 0
Boundary RSS samples 200 200 0
Boundary PSS samples 200 200 0
Periodic peak RSS 254.0 MiB 243.7 MiB -10.4 MiB
Periodic peak PSS 251.3 MiB 240.4 MiB -10.9 MiB
RSS · first 10 avg 174.0 MiB 144.5 MiB -29.4 MiB
RSS · last 10 avg 187.6 MiB 191.0 MiB +3.5 MiB
RSS · last − first window +13.6 MiB +46.5 MiB +32.9 MiB
RSS · warm slope / 100 nav +8.3 MiB +5.3 MiB -3.0 MiB
PSS · first 10 avg 170.3 MiB 140.8 MiB -29.4 MiB
PSS · last 10 avg 183.7 MiB 187.5 MiB +3.8 MiB
PSS · last − first window +13.5 MiB +46.7 MiB +33.2 MiB
PSS · warm slope / 100 nav +8.3 MiB +5.3 MiB -3.0 MiB
Peak file descriptors 58 59 1
Peak threads 29 29 0

HEAD memory by 50-navigation quarter

HEAD range Avg RSS Final RSS Peak RSS Avg PSS Final PSS Peak FD
1–50 171.1 MiB 162.7 MiB 224.2 MiB 167.6 MiB 159.1 MiB 52
51–100 179.8 MiB 198.5 MiB 223.4 MiB 176.4 MiB 195.1 MiB 53
101–150 187.7 MiB 156.0 MiB 218.4 MiB 184.4 MiB 152.6 MiB 53
151–200 185.5 MiB 199.5 MiB 226.7 MiB 182.1 MiB 196.2 MiB 53

Raw reports and per-navigation boundary samples: workflow run and full sequential-navigation-soak-results artifact.

Public-site timing and memory are observational. Use the A/B deltas and trend shape as evidence, not as a deterministic performance threshold.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Spider Bench A/B

✅ All benchmark browser service runs completed; results are informational.

Public HEAD: 184 / 240 rows; 38 / 48 sites produced rows; 10 unexpected empty sites.

✅ Deterministic fixture contract is clean.

Common ancestor baf87cfb248d → HEAD b0f0f85ab7e1; benchmark order: base-first; workflow: success.

Public 48-site run · informational

Metric Base HEAD Δ
Run status success success —
Extracted rows / contract 184 / 240 184 / 240 0 (0.00%)
Contract fill 76.67% 76.67% 0.00 pp (0.00%)
Sites with rows 38 / 48 38 / 48 0 (0.00%)
Sites meeting row contract 36 / 48 36 / 48 0 (0.00%)
Unexpected empty sites 10 10 0 (0.00%)
Partial-row sites 2 2 0 (0.00%)
Site outcomes extracted: 36; HTTP error + rows: 2; empty: 7; HTTP error + empty: 1; snapshot error + empty: 2 extracted: 37; HTTP error + rows: 1; empty: 7; HTTP error + empty: 1; snapshot error + empty: 2 —
Observed duration 54.07 s 42.72 s -11.35 s (-21.00%)
Estimated CPU 42.19 s 37.47 s -4.72 s (-11.20%)
Peak PSS 266.59 MiB 260.08 MiB -6.51 MiB (-2.44%)
Peak RSS 270.45 MiB 265.99 MiB -4.46 MiB (-1.65%)
Peak threads 26 26 0 (0.00%)
Mismatched sites 0 0 0
Timeout with items 0 0 0
Category rows Base HEAD Δ
news 35 / 40 35 / 40 0
stocks 20 / 40 20 / 40 0
tech 35 / 40 35 / 40 0
sports 27 / 40 27 / 40 0
games 37 / 40 37 / 40 0
life 30 / 40 30 / 40 0

Public-site content, timing, and memory are noisy. This single A/B run reports evidence only; site outcome counts explain missing rows without treating them as a deterministic regression.

CPU and memory timelines

These are bounded 40-point views of the same complete process-tree samples used by the HTML report. CPU uses 100% per occupied logical core; memory lines are RSS first and PSS second when complete PSS samples are available.

Base

xychart-beta
    title "Base CPU"
    x-axis "Elapsed seconds" [1.538, 3.04, 4.041, 4.541, 6.045, 7.546, 9.047, 10.55, 12.051, 13.553, 15.056, 16.558, 17.059, 18.06, 19.562, 21.062, 22.563, 24.065, 25.567, 27.07, 28.573, 30.075, 31.577, 33.079, 34.581, 36.083, 37.583, 39.086, 40.586, 42.087, 43.589, 45.09, 46.592, 48.095, 49.597, 51.099, 52.601, 53.603]
    y-axis "CPU percent" 0 --> 200
    line [83.78, 69.92, 115.83, 107.94, 113.74, 127.96, 91.8, 115.94, 75.97, 143.7, 23.97, 7.99, 0, 0, 137.93, 0, 59.97, 69.86, 125.96, 101.88, 135.79, 141.96, 59.85, 69.86, 55.95, 57.86, 87.99, 49.96, 76.07, 6, 0, 115.83, 99.87, 101.89, 131.87, 9.99, 125.89, 163.72]
Loading
xychart-beta
    title "Base memory: RSS then PSS"
    x-axis "Elapsed seconds" [0.035, 1.538, 3.04, 4.041, 4.541, 6.045, 7.546, 9.047, 10.55, 12.051, 13.553, 15.056, 16.558, 17.059, 18.06, 19.562, 21.062, 22.563, 24.065, 25.567, 27.07, 28.573, 30.075, 31.577, 33.079, 34.581, 36.083, 37.583, 39.086, 40.586, 42.087, 43.589, 45.09, 46.592, 48.095, 49.597, 51.099, 52.601, 53.603, 54.07]
    y-axis "Memory MiB" 0 --> 500
    line [12.98, 91.37, 93.77, 122.25, 120.36, 145.41, 148.23, 156.98, 132.49, 170.66, 134.52, 121.16, 117.56, 117.71, 117.45, 138.21, 117.41, 117.79, 125.8, 143.16, 270.45, 183.35, 211.7, 139.6, 152.54, 140.23, 133.55, 142.88, 137.63, 155.79, 125.2, 124.04, 150.71, 156.89, 156.92, 163.93, 123.96, 155.96, 171.8, 0]
    line [9.44, 87.59, 90.01, 118.45, 116.49, 141.65, 143.9, 153.13, 128.64, 166.81, 130.64, 117.28, 113.68, 113.83, 113.57, 134.34, 113.54, 113.91, 121.92, 139.27, 266.59, 180.7, 208.42, 135.74, 148.66, 136.47, 129.67, 139.04, 133.76, 151.98, 121.32, 120.21, 146.85, 152.84, 153.06, 160.05, 120.17, 151.35, 168.01, 0]
Loading

HEAD

xychart-beta
    title "HEAD CPU"
    x-axis "Elapsed seconds" [1.036, 2.537, 3.539, 5.042, 6.042, 7.044, 8.546, 9.547, 11.049, 12.049, 13.05, 14.553, 15.553, 16.053, 16.553, 18.056, 19.057, 20.559, 21.561, 22.061, 22.562, 24.064, 25.065, 26.567, 27.569, 28.57, 30.071, 31.071, 32.573, 33.574, 34.575, 36.076, 37.077, 38.079, 39.581, 40.081, 40.581, 42.083]
    y-axis "CPU percent" 0 --> 200
    line [3.99, 120.02, 123.78, 113.83, 127.97, 123.72, 115.94, 97.85, 97.98, 127.93, 49.98, 139.75, 115.98, 0, 32, 113.79, 23.99, 99.96, 91.78, 101.9, 107.9, 125.8, 117.9, 33.99, 109.8, 105.86, 31.98, 63.96, 109.95, 47.96, 107.97, 99.96, 6, 55.89, 99.71, 155.88, 14.02, 121.88]
Loading
xychart-beta
    title "HEAD memory: RSS then PSS"
    x-axis "Elapsed seconds" [0.035, 1.036, 2.537, 3.539, 5.042, 6.042, 7.044, 8.546, 9.547, 11.049, 12.049, 13.05, 14.553, 15.553, 16.053, 16.553, 18.056, 19.057, 20.559, 21.561, 22.061, 22.562, 24.064, 25.065, 26.567, 27.569, 28.57, 30.071, 31.071, 32.573, 33.574, 34.575, 36.076, 37.077, 38.079, 39.581, 40.081, 40.581, 42.083, 42.716]
    y-axis "Memory MiB" 0 --> 500
    line [13.01, 64.03, 105.28, 110.6, 134.95, 142.93, 138.21, 139.2, 130.74, 149.91, 160.64, 134.09, 132.86, 115.29, 115.29, 116.61, 156.75, 150.56, 140.89, 197.07, 265.99, 204.54, 186.86, 205.94, 146.37, 169.01, 141.85, 133.27, 135.79, 140.01, 142.27, 179.18, 146.39, 123.68, 137.39, 159.01, 138.89, 141.72, 154.89, 0]
    line [9.47, 60.32, 101.57, 106.8, 131.23, 139.16, 134.47, 135.41, 126.95, 146.1, 156.84, 130.26, 129.17, 111.52, 111.52, 113.03, 152.9, 146.82, 137.14, 193.34, 260.08, 200.25, 183.21, 202.18, 142.79, 165.21, 138.22, 129.44, 131.8, 136.23, 138.5, 175.74, 142.7, 119.91, 133.72, 155.29, 135.18, 137.95, 151.27, 0]
Loading

Deterministic fixture · required contract

The fixture exercises 15 routes: 8 are expected to emit rows and 7 intentionally exercise empty, loading, or timeout behavior.

Metric Base HEAD Δ
Run status success success —
Extracted rows / contract 40 / 40 40 / 40 0 (0.00%)
Contract fill 100.00% 100.00% 0.00 pp (0.00%)
Sites with rows 8 / 15 8 / 15 0 (0.00%)
Sites meeting row contract 15 / 15 15 / 15 0 (0.00%)
Unexpected empty sites 0 0 0
Partial-row sites 0 0 0
Site outcomes extracted: 7; HTTP error + rows: 1; empty: 3; timeout + empty: 4 extracted: 7; HTTP error + rows: 1; empty: 3; timeout + empty: 4 —
Observed duration 19.87 s 19.86 s -0.01 s (-0.03%)
Estimated CPU 0.41 s 0.42 s +0.01 s (+2.42%)
Peak PSS 66.47 MiB 66.92 MiB +0.45 MiB (+0.68%)
Peak RSS 70.07 MiB 70.70 MiB +0.63 MiB (+0.90%)
Peak threads 18 18 0 (0.00%)
Mismatched sites 0 0 0
Timeout with items 0 0 0

Full HTML, JSON, CSV, logs, and page snapshots: workflow run and full spider-bench-results artifact.

The public-web A/B is informational. The exact HEAD fixture contract runs as a separate required CI check; timing and public-site content deltas remain non-blocking.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

CI Regression Report

Source CI run · source state at render: failure · artifacts: 3/6

Check Status Signal
Release regression ⚪ artifact unavailable or invalid
Frontend differential ⚪ artifact unavailable or invalid
Agent episodes ✅ 8/8 Moli episodes passed; 0 failures
Runtime/CDP contracts ✅ 26 contract cases; 0 failures
CDP smoke ⚪ artifact unavailable or invalid
WebMainBench ✅ 545/545 completed; 0 unexpected failures
Release regression — ⚪ artifact unavailable or invalid

Artifact unavailable or invalid. See the source CI run for infrastructure details.

Frontend differential — ⚪ artifact unavailable or invalid

Artifact unavailable or invalid. See the source CI run for infrastructure details.

Agent episodes · Moli vs Chromium — ✅ 8/8 Moli episodes passed; 0 failures
Fast contract Episodes Passed Assertions Ready p50 Episode p50
Moli 8 8 47/47 2.67 ms 26.02 ms
Chromium 8 8 47/47 249.16 ms 92.99 ms
Operation p50 Chromium Moli Delta Delta %
navigate 39.55 ms 6.05 ms −33.51 ms −84.71%
observe 0.80 ms 1.00 ms +0.19 ms +23.98%
fill 3.86 ms 3.33 ms −0.54 ms −13.88%
click 5.58 ms 3.98 ms −1.60 ms −28.71%
Idle-resource episode Peak RSS Peak PSS Average CPU Peak CPU Peak processes Sampler
Moli 67.13 MiB 63.76 MiB 0.73% 10.00% 1 ✅
Chromium 1285.16 MiB 407.36 MiB 0.56% 6.00% 13 ✅
Runtime and CDP session contracts — ✅ 26 contract cases; 0 failures
Suite Cases Failures Median case p50 Median case p95 Median peak PSS p50
Synthetic fetch 13 0 18.13 ms 19.02 ms 628.00 KiB
Long-lived CDP session 13 0 17.72 ms 18.36 ms —
CDP smoke — ⚪ artifact unavailable or invalid

Artifact unavailable or invalid. See the source CI run for infrastructure details.

WebMainBench · 545 pages — ✅ 545/545 completed; 0 unexpected failures
Completed Successful Expected DNS failure Unexpected failures Panics Crashes Timeouts Empty output
545/545 544 1 0 0 0 0 0

Frozen HTML · Linux · --wait done · 45 seconds per page · no retries. Content quality is evaluated separately.

Diagnostics: webmainbench-results — every page's Markdown, stderr, and exit status. Source run and artifacts

All artifact fields are parsed by the trusted default-branch renderer; missing or invalid inputs remain visible as unavailable.

@ldm0
ldm0 force-pushed the fix/child-image-csp-inheritance-20261021 branch 3 times, most recently from a3e8a58 to 2805a57 Compare October 25, 2026 21:04
ldm0 added 3 commits October 26, 2026 15:56
Use the creator URL for source matching in inherited about:blank/srcdoc
documents. Keep actual document URLs in violation reports and preserve
opaque sandbox origins and data URL blocking.

Cover ordinary and sandboxed srcdoc, changed parent/child base URLs,
allowed same-origin images, blocked cross-origin images, and owner reports.

Regression-commit: 5399724
Regression-PR: #1714

Validate this independent patch on main ce0781f:
- cargo fmt --all
- cargo clippy --workspace --all-targets --all-features -- -D warnings
- cargo nextest run --no-fail-fast
     Summary [ 551.506s] 20434 tests run: 20434 passed (9 slow), 18 skipped

Original-commit: 59c8fc2
Capture the CSP matching URL in the policy container, preserve it through local-document snapshots, and replace it on network navigation. Recheck redirected responses and cached final URLs using the requesting Document policy while retaining local report URLs and Report-Only behavior.
Apply owner-document image policy before network dispatch or decoded resource reuse. Preserve Report-Only loading and verify owner reports, real HTTP requests, and redirected image cache admission.
@ldm0
ldm0 force-pushed the fix/child-image-csp-inheritance-20261021 branch from 2805a57 to b0f0f85 Compare October 26, 2026 08:46
@ldm0 ldm0 changed the title fix(csp): inherit image self sources in local child documents fix(csp): enforce child image policies across redirects and cache reuse Oct 26, 2026
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