Skip to content

feat(engine): isolate game execution in sandboxed iframe - #4400

Open
SSoggyTacoMan wants to merge 8 commits into
hackclub:mainfrom
SSoggyTacoMan:feat/sandboxed-game-runner
Open

SSoggyTacoMan wants to merge 8 commits into
hackclub:mainfrom
SSoggyTacoMan:feat/sandboxed-game-runner

Conversation

@SSoggyTacoMan

Copy link
Copy Markdown
Contributor

Supersedes and resolves issues in #3906.

Summary

Isolates Sprig game execution into a dedicated opaque-origin sandbox iframe (/game-sandbox) to prevent untrusted user game code from accessing session cookies, local storage, or the main application DOM.

Improvements over #3906

  1. Valid CORS Asset Loading:
    • Replaced invalid Access-Control-Allow-Origin: "null" + Access-Control-Allow-Credentials: "true" headers with standard wildcard Access-Control-Allow-Origin: "*" on /_astro/* assets without invalid credential flags.
    • Removed fragile HTML middleware string replacement injecting crossorigin="use-credentials".
  2. Robust Sprite Extraction:
    • Enhanced extractLegendBitmaps to statically extract object properties (e.g. SPRITES.PLAYER), bitmap variable declarations, and setLegend calls using exact boundary matching.
    • Added EXTRACT_BITMAPS sandbox protocol message so dynamic sprites (e.g. loops, spreads) can be evaluated headlessly inside the isolated sandbox frame instead of executing on the parent window.
    • Prevented overwriting existing bitmaps.value when static extraction returns empty.
  3. Audio Autoplay & Key Shortcut Propagation:
    • Added allow="autoplay" to the sandbox <iframe> and auto-resumed suspended AudioContext instances on user input.
    • Forwarded modifier key events (Cmd/Ctrl+Enter, Escape) from the sandbox frame to the parent window to keep editor hotkeys functional while the game canvas is focused.

@vercel

vercel Bot commented Oct 16, 2026

Copy link
Copy Markdown

@SSoggyTacoMan is attempting to deploy a commit to the Hack Club Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sprig Ready Ready Preview Oct 18, 2026 3:12pm UTC

Request Review

This branch has not been deployed

No deployments
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.

3 participants