Files
OpenMAIC/render-service/test
wyucandClaude Opus 4.8 7420d26ebb fix(render-service): contain untrusted HTML with a network policy on preview and render (#1512)
Headless Chromium renders caller-supplied HTML on two paths, and neither applied
the Content-Security-Policy the app packager injects for exports. Inline script
in a preview scene or an uploaded render project could reach loopback and
internal addresses, and on the render path the response is painted into the
returned MP4.

- Add a single untrusted-HTML CSP and an injector that places the policy as the
  first node the parser processes (ASCII whitespace only; a leading BOM is
  stripped; a byte-level injector preserves non-UTF-8 bodies).
- Inject the policy into the interactive preview srcDoc and add a Puppeteer
  request guard that blocks non-data/blob/about requests from the untrusted
  frame and non-about main-frame navigations.
- Harden every extracted project HTML, and sanitize framed same-origin .svg and
  .xhtml documents (scripts, on* handlers, javascript: URLs, foreignObject,
  nested frames removed via parse5), which cannot carry a meta CSP.
- Document the residual top-level-navigation risk on the render path, which the
  egress lockdown must contain.
- Add real-Chromium boundary tests (zero listener hits incl. WebSocket) and a
  packager-equivalence test for the policy.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-15 17:47:22 +08:00
..