← Back to Pull requests

feat(html-render): a content security policy for rendered pages (W47) #335

Open
unknown opened this pull request with 293 lines diff across 3 files
View on GitHub
unknown unknown commented on Oct 28, 2026 20:07 UTC
Author

What

From preview.md#deferred: a content security policy for rendered pages in the reader's client. Decision D1689 in docs/plans/preview.md ("A rendered page's policy (W47)").

A page an agent rendered with html.render runs in a sandboxed srcdoc frame (never same-origin), but, as in T3, its scripts could load from anywhere and so also reach the reader's own loopback (the node at http://127.0.0.1:7777) and plain-HTTP devices of the reader's network. The web client now puts a <meta http-equiv="Content-Security-Policy"> first in the frame's document (after any doctype, so the page keeps standards mode):

default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' https: data: blob:;
style-src 'unsafe-inline' https: data:; img-src https: data: blob:; font-src https: data:;
media-src https: data: blob:; connect-src https:; worker-src blob: data:; frame-src 'none';
object-src 'none'; form-action 'none'; base-uri 'none'

A CDN chart library over HTTPS still loads; plain HTTP and WebSockets are refused. The stored page in the thread's stream is unchanged, and node-side measuring keeps its public-only proxy. What a scheme-based policy cannot do (shutting out private addresses over HTTPS) stays in Deferred.

Evidence

$ vp test run apps/web/test/html-render-policy.test.ts
 Test Files  1 passed (1)
      Tests  2 passed (2)

$ npx playwright test tests/html-render.spec.ts
[1/2] … D405–D407: an agent's rendered page shows in its turn, themed, and opens full screen
[2/2] … D1689: a rendered page reaches nothing over plain HTTP from the reader's client
  2 passed (16.6s)

The new e2e renders a page whose inline script fetches, and whose <img> loads, a server on the reader's loopback that answers with CORS allowed: the script runs and reports "blocked", and the server got no request. Without the policy the same test fails (run with srcDoc={props.html}):

    Error: expect(locator).toHaveText(expected) failed
    Expected: "blocked"
    Received: "reached"
  1 failed

$ vp check apps/web/src/plugins/html-render apps/web/test/html-render-policy.test.ts e2e/tests/html-render.spec.ts docs/plans/preview.md
pass: All 6 files are correctly formatted
pass: Found no warnings or lint errors in 5 files

🤖 Generated with Claude Code

Diff: 293 lines (+219 / -74) across 3 files Reviewer: claude[bot] Review duration: 3m
All Vouch review confidence checks passed
Residual risk 0.46 = Change Risk (0.63) × (1 − Review Confidence (0.28)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.63 · 293 lines diff across 3 files
0.63
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 41% · Reviewer familiarity: 35%
27%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth shallow_review_depth
0.344
Diff Size diff_size
0.340
Sensitive Paths sensitive_paths
0.063
Real PR Conversation Timeline
1 comments
"Review active on #335"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: medium confidence: 27.7% reviewed sensitive_module
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 63.1% (MEDIUM) · Higher = larger blast radius
63.1%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 27.7% · Lower = rushed or shallow review
27.7%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 45.6% · Moderate risk
45.6%
Repository