AUTO-UPDATED

Is It Safe to Host HTML That Runs Its Own JavaScript?

ShareMyPage developer explains how the platform securely hosts user-generated HTML and JavaScript by utilizing sandboxed iframes and isolated, cookieless origins to prevent session hijacking and cross-site scripting attacks.

Key Points

  • ShareMyPage avoids sanitizing HTML to preserve the functionality of interactive, data-driven web prototypes.
  • The platform uses sandboxed iframes with the allow-same-origin permission omitted to ensure scripts run within a null origin.
  • Content is served from a separate, temporary origin that contains no session cookies or authentication tokens.
  • The architecture prevents XSS and session hijacking by ensuring that even a successful sandbox escape would land in an empty, non-privileged environment.
  • The security model does not prevent CPU-intensive tasks like cryptomining or potential browser-level zero-day exploits.

Why it Matters

This approach demonstrates a "defense-in-depth" strategy that prioritizes architectural isolation over the often-unreliable practice of filtering malicious code. By assuming the sandbox will eventually fail, the developer creates a system where security breaches result in no data loss, offering a robust model for platforms that must execute untrusted third-party code.
Sharemypage.app Published by ShareMyPage
Read original