Skip to content
uencoder

Worker Sandbox

A Worker sandbox exploits the Web Worker isolated execution context to restrict untrusted code from accessing the main thread DOM and cookies.

Purpose

To execute untrusted code in an isolated thread, restricting it to postMessage communication and protecting the main thread.

Mechanism

Workers run in a separate global context with no DOM, window, or document access, communicating with the main thread only via postMessage. SharedWorker and Service Worker carry additional restrictions.

Use cases

  • Isolated execution of untrusted code
  • Parallel safety
  • Main thread protection

Related tools

References