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

Local iframe Documents could reject same-origin images under CSP img-src 'self' because matching used about:blank or about:srcdoc. Capture the inherited CSP self URL in the policy container, independently of mutable base URLs and sandboxed Window origins, while reporting violations against the actual owner Document URL.

Also check redirected image responses against the owning Document's policy, preserve final response URLs for shared image resources, and apply img-src before CSS image admission. These remain three separate commits using the existing CSP and image-resource paths.

Rebased the complete implementation onto main 0197ba5e1b2fbb51373485c314124611ab2b3ee1. Conflict resolutions preserve main's exact owner dispatch, initial child policy setup and PageScriptHost APIs.

Checks passed before the final mechanical rebase (base f645d859a36e5a4ab37c29e9083ffdf32039309b):

  • cargo fmt --all
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo nextest run --no-fail-fast: 23,401 passed, 20 skipped.

Head: 1b31050ea5a5d5305f8bf900f6e084ee4afd3858. The final rebase changed no retained patches (all range-diff entries match). Remote CI is triggered by this push.

@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 0197ba5e1b → HEAD 1b31050ea5; benchmark order: base-first; workflow: success.

Session resilience

Metric Base HEAD
Attempted / planned 200 / 200 200 / 200
Direct observable pass 194 / 200 194 / 200
Failures / recovered 6 / 6 6 / 6
Recovery failures 0 0
Lifecycle order violations 0 0
Network order violations 0 0
Wall time 677.6 s 743.1 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 244.6 MiB 282.0 MiB +37.4 MiB
Periodic peak PSS 241.1 MiB 278.3 MiB +37.2 MiB
RSS · first 10 avg 166.2 MiB 174.5 MiB +8.3 MiB
RSS · last 10 avg 187.8 MiB 187.0 MiB -0.8 MiB
RSS · last − first window +21.6 MiB +12.5 MiB -9.1 MiB
RSS · warm slope / 100 nav +3.5 MiB +5.2 MiB +1.7 MiB
PSS · first 10 avg 163.0 MiB 170.8 MiB +7.8 MiB
PSS · last 10 avg 184.1 MiB 183.2 MiB -0.9 MiB
PSS · last − first window +21.1 MiB +12.4 MiB -8.7 MiB
PSS · warm slope / 100 nav +3.4 MiB +5.4 MiB +1.9 MiB
Peak file descriptors 72 73 1
Peak threads 35 35 0

HEAD memory by 50-navigation quarter

HEAD range Avg RSS Final RSS Peak RSS Avg PSS Final PSS Peak FD
1–50 182.1 MiB 152.9 MiB 219.6 MiB 178.4 MiB 149.3 MiB 68
51–100 185.7 MiB 213.7 MiB 231.7 MiB 182.0 MiB 210.2 MiB 65
101–150 187.0 MiB 162.7 MiB 224.6 MiB 183.5 MiB 159.2 MiB 69
151–200 192.1 MiB 192.0 MiB 227.1 MiB 188.6 MiB 188.5 MiB 66

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: 182 / 240 rows; 37 / 48 sites produced rows; 11 unexpected empty sites.

✅ Deterministic fixture contract is clean.

Common ancestor 0197ba5e1b2f → HEAD 1b31050ea5a5; benchmark order: base-first; workflow: success.

Public 48-site run · informational

Metric Base HEAD Δ
Run status success success —
Extracted rows / contract 184 / 240 182 / 240 -2 (-1.09%)
Contract fill 76.67% 75.83% -0.84 pp (-1.10%)
Sites with rows 38 / 48 37 / 48 -1 (-2.63%)
Sites meeting row contract 36 / 48 36 / 48 0 (0.00%)
Unexpected empty sites 10 11 +1 (+10.00%)
Partial-row sites 2 1 -1 (-50.00%)
Site outcomes extracted: 36; HTTP error + rows: 2; empty: 8; HTTP error + empty: 1; snapshot error + empty: 1 extracted: 36; HTTP error + rows: 1; empty: 8; HTTP error + empty: 2; snapshot error + empty: 1 —
Observed duration 50.38 s 48.34 s -2.04 s (-4.05%)
Estimated CPU 40.20 s 35.49 s -4.70 s (-11.70%)
Peak PSS 251.83 MiB 219.39 MiB -32.45 MiB (-12.88%)
Peak RSS 255.87 MiB 223.80 MiB -32.06 MiB (-12.53%)
Peak threads 33 31 -2 (-6.06%)
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 32 / 40 30 / 40 -2
life 35 / 40 35 / 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.537, 3.04, 4.041, 5.542, 7.043, 8.545, 10.046, 11.048, 12.55, 14.05, 15.552, 17.052, 18.053, 19.555, 21.057, 21.558, 22.56, 24.06, 25.563, 26.564, 28.064, 29.567, 31.068, 32.571, 33.572, 35.074, 36.575, 37.076, 38.077, 39.579, 40.58, 42.083, 43.585, 45.086, 46.588, 47.59, 49.093, 50.095]
    y-axis "CPU percent" 0 --> 200
    line [43.96, 125.78, 78, 125.9, 85.97, 87.89, 47.88, 123.91, 6, 143.94, 23.99, 26, 117.66, 121.69, 97.95, 109.74, 117.75, 130.04, 125.88, 99.89, 101.88, 69.94, 57.95, 115.95, 145.89, 4, 29.98, 1.99, 55.96, 25.98, 25.97, 67.89, 15.98, 121.89, 137.83, 9.97, 111.68, 167.77]
Loading
xychart-beta
    title "Base memory: RSS then PSS"
    x-axis "Elapsed seconds" [0.036, 1.537, 3.04, 4.041, 5.542, 7.043, 8.545, 10.046, 11.048, 12.55, 14.05, 15.552, 17.052, 18.053, 19.555, 21.057, 21.558, 22.56, 24.06, 25.563, 26.564, 28.064, 29.567, 31.068, 32.571, 33.572, 35.074, 36.575, 37.076, 38.077, 39.579, 40.58, 42.083, 43.585, 45.086, 46.588, 47.59, 49.093, 50.095, 50.378]
    y-axis "Memory MiB" 0 --> 500
    line [14.11, 85.94, 120, 123.64, 168.06, 155, 137.86, 146.84, 156.33, 122.87, 155.39, 123.71, 130.45, 148.21, 147.2, 229.29, 255.87, 188.35, 154.13, 159.68, 172.69, 139.79, 143.45, 144.58, 243.47, 220.34, 225.29, 232.22, 232.22, 237.12, 232.15, 232.22, 246.46, 133.74, 165.38, 145.02, 142.64, 154.1, 159.35, 0]
    line [10.67, 82.33, 116.39, 120.02, 164.48, 151.25, 134.17, 143.17, 152.66, 119.2, 151.72, 120.04, 126.78, 144.54, 143.29, 225.66, 251.83, 186.25, 151.09, 155.91, 169.08, 136.12, 139.77, 140.9, 240.83, 216.89, 221.61, 228.54, 228.54, 233.45, 228.48, 228.55, 242.86, 130.06, 161.75, 141.36, 138.96, 150.58, 155.82, 0]
Loading

HEAD

xychart-beta
    title "HEAD CPU"
    x-axis "Elapsed seconds" [1.535, 2.535, 4.037, 5.54, 6.542, 8.044, 9.547, 11.049, 12.05, 13.552, 15.053, 16.053, 17.053, 17.554, 19.057, 20.059, 21.562, 22.062, 23.064, 24.567, 25.568, 27.068, 28.571, 29.571, 31.073, 32.575, 33.576, 35.078, 36.581, 37.583, 39.085, 40.587, 42.089, 43.091, 44.593, 46.095, 47.096, 48.098]
    y-axis "CPU percent" 0 --> 200
    line [95.95, 109.99, 125.78, 135.92, 131.72, 131.92, 89.77, 129.63, 39.91, 33.99, 55.9, 2, 0, 3.99, 69.93, 113.73, 103.7, 103.91, 113.79, 105.85, 137.93, 126.09, 95.89, 85.95, 69.95, 0, 0, 2, 0, 0, 2, 0, 90.06, 15.98, 115.9, 85.92, 129.93, 159.55]
Loading
xychart-beta
    title "HEAD memory: RSS then PSS"
    x-axis "Elapsed seconds" [0.034, 1.535, 2.535, 4.037, 5.54, 6.542, 8.044, 9.547, 11.049, 12.05, 13.552, 15.053, 16.053, 17.053, 17.554, 19.057, 20.059, 21.562, 22.062, 23.064, 24.567, 25.568, 27.068, 28.571, 29.571, 31.073, 32.575, 33.576, 35.078, 36.581, 37.583, 39.085, 40.587, 42.089, 43.091, 44.593, 46.095, 47.096, 48.098, 48.337]
    y-axis "Memory MiB" 0 --> 500
    line [13.69, 94.47, 118.56, 156.32, 149.89, 142.45, 160.31, 144.52, 147.17, 139.07, 131.21, 140.11, 120.56, 125.57, 124.52, 134.11, 143.28, 170.37, 223.8, 184.14, 155.41, 160.43, 150.19, 148.93, 144.41, 139.8, 126.76, 124.5, 124.48, 124.48, 124.48, 124.48, 124.48, 148.26, 127.79, 160.79, 129.5, 145.09, 131.71, 0]
    line [10.24, 92.46, 115.01, 152.69, 146.33, 138.65, 154.81, 141.04, 143.51, 135.41, 127.64, 136.28, 116.93, 121.94, 120.89, 130.48, 139.65, 167.24, 219.39, 180.54, 151.78, 156.54, 146.56, 145.3, 140.78, 136.17, 123.03, 120.77, 120.76, 120.75, 120.75, 120.75, 120.75, 144.53, 124.06, 157.08, 125.76, 141.38, 128.09, 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.86 s 19.87 s +0.01 s (+0.03%)
Estimated CPU 0.41 s 0.41 s +0.00 s (+0.24%)
Peak PSS 71.87 MiB 71.38 MiB -0.49 MiB (-0.68%)
Peak RSS 75.40 MiB 74.84 MiB -0.56 MiB (-0.75%)
Peak threads 22 22 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: in_progress · artifacts: 6/6

Check Status Signal
Release regression ✅ HEAD/base failures 0/0; raw binary +0.005591%
Frontend differential ✅ 1,020/1,020 cases matched; 0 issues
Agent episodes ✅ 8/8 Moli episodes passed; 0 failures
Runtime/CDP contracts ✅ 26 contract cases; 0 failures
CDP smoke ❌ 118/122 groups passed; 2,028 scenarios
WebMainBench ✅ 545/545 completed; 0 unexpected failures
Release regression — ✅ HEAD/base failures 0/0; raw binary +0.005591%

Package and image size

Metric Base HEAD Delta Delta %
Raw binary 154.75 MiB 154.76 MiB +8.86 KiB +0.005591%
Stripped binary 107.12 MiB 107.13 MiB +8.00 KiB +0.007293%
gzip binary 53.51 MiB 53.51 MiB +3.83 KiB +0.006983%
Rootfs 161.65 MiB 161.66 MiB +10.00 KiB +0.006041%
gzip rootfs 62.62 MiB 62.62 MiB +4.80 KiB +0.007490%

Startup latency and PSS

Case Base p50 HEAD p50 Delta Base PSS HEAD PSS Delta
Serve ready 26.94 ms 26.84 ms −0.11 ms 4.84 MiB 4.46 MiB −395.00 KiB
CDP first page 49.00 ms 48.75 ms −0.24 ms 4.59 MiB 4.73 MiB +141.00 KiB
CDP warm page 11.29 ms 11.47 ms +0.18 ms 52.91 MiB 52.78 MiB −141.00 KiB
CLI about:blank 12.76 ms 12.28 ms −0.48 ms 4.22 MiB 4.18 MiB −38.50 KiB
CLI local JS 24.07 ms 25.52 ms +1.45 ms 4.80 MiB 3.94 MiB −878.50 KiB

Concurrency matrix

Concurrency Base p50 HEAD p50 Delta Base PSS HEAD PSS Delta HEAD failures Unstable B/H
1 23.76 ms 23.45 ms −0.31 ms 585.00 KiB 611.00 KiB +26.00 KiB 0 0/0
5 28.95 ms 27.92 ms −1.03 ms 13.74 MiB 13.10 MiB −651.50 KiB 0 0/0
10 27.71 ms 27.69 ms −0.02 ms 11.33 MiB 12.79 MiB +1.46 MiB 0 0/0
25 29.50 ms 28.31 ms −1.19 ms 13.17 MiB 14.46 MiB +1.28 MiB 0 0/0
100 27.48 ms 27.76 ms +0.28 ms 12.96 MiB 12.72 MiB −253.00 KiB 0 0/0
Frontend differential — ✅ 1,020/1,020 cases matched; 0 issues
Match DOM mismatch Diagnostic mismatch Moli error Reference error Infrastructure error Mismatched frames Duration
1,020 0 0 0 0 0 0 6m 58.15s
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 28.70 ms 33.53 ms
Chromium 8 8 47/47 284.17 ms 95.06 ms
Operation p50 Chromium Moli Delta Delta %
navigate 46.45 ms 6.11 ms −40.34 ms −86.85%
observe 0.95 ms 1.21 ms +0.25 ms +26.59%
fill 3.93 ms 4.25 ms +0.32 ms +8.20%
click 6.25 ms 4.47 ms −1.78 ms −28.44%
Idle-resource episode Peak RSS Peak PSS Average CPU Peak CPU Peak processes Sampler
Moli 71.69 MiB 69.22 MiB 0.84% 12.01% 1 ✅
Chromium 1311.82 MiB 437.13 MiB 1.15% 26.27% 13 ⚠️ PSS partial
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 34.36 ms 40.29 ms 704.00 KiB
Long-lived CDP session 13 0 18.13 ms 19.02 ms —
CDP smoke — ❌ 118/122 groups passed; 2,028 scenarios

Workers: 4 · cumulative group time: 607.41 s · failed groups: 4

Slowest group Scenarios Duration Status
dom-input 64 30.17 s ✅
dom-input 64 29.80 s ✅
scrollbar-visibility 22 27.52 s ✅
scrollbar-visibility 22 27.05 s ✅
fetch-resource-dispatch 72 26.79 s ✅

Failed groups

  • core — failed · Traceback (most recent call last): File "/__w/moli/moli/moli-cdp-smoke/moli_cdp_smoke/runner.py", line 824, in _run_worker await run_smoke(endpoint, fixtu
  • core — failed · Traceback (most recent call last): File "/__w/moli/moli/moli-cdp-smoke/moli_cdp_smoke/runner.py", line 824, in _run_worker await run_smoke(endpoint, fixtu
  • network — failed · Traceback (most recent call last): File "/__w/moli/moli/moli-cdp-smoke/moli_cdp_smoke/assertions.py", line 65, in wait_until await asyncio.sleep(interval_
  • network — failed · Traceback (most recent call last): File "/__w/moli/moli/moli-cdp-smoke/moli_cdp_smoke/assertions.py", line 65, in wait_until await asyncio.sleep(interval_
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 4 times, most recently 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
@ldm0
ldm0 force-pushed the fix/child-image-csp-inheritance-20261021 branch from b0f0f85 to 4433f08 Compare October 28, 2026 20:12
@ldm0
ldm0 force-pushed the fix/child-image-csp-inheritance-20261021 branch from 4433f08 to c653b20 Compare November 14, 2026 17:56
ldm0 added 3 commits November 15, 2026 02:12
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 c653b20 to 1b31050 Compare November 14, 2026 18:13
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