Building a Cloud-Hosted Disposable Browser for Untrusted Web Content
System DesignModel answerLast updated
Architect a platform that renders risky web pages in throwaway cloud sandboxes and streams the result to employees, covering isolation, streaming, state, policy and scale for 50k sessions.
Design a Disposable Cloud Browser Service for Employees
Your company wants to protect its workforce from malicious websites. Instead of letting a link open in the employee's own browser, the page should load and run inside a short-lived, locked-down browser in the cloud. The employee sees and interacts with the result through an ordinary browser tab.
Design this service end to end.
What the system must do
- Isolation: All HTML, JavaScript and CSS from the visited site is fetched and executed on a remote browser instance, never on the employee's device.
- Interactive viewing: The employee should feel as if they were using a normal local browser: scrolling, clicking, typing and watching video should all work smoothly.
- Administrator control: Admins can define rules that block particular sites or particular scripts.
Quality goals
- Responsiveness: Scrolling and clicking must feel almost immediate.
- Scale: Handle 50,000 simultaneous sessions for a globally distributed workforce.
- Containment: Nothing malicious may survive from one session to the next, and nothing may break out of the isolated environment.
What your answer should cover
- The design of the remote browser host: how each instance is packaged and sandboxed (containers, micro-VMs, full virtual desktops, etc.).
- The protocol that carries visuals from the remote browser to the user and carries input back.
- How you treat session state, including reconnects and any data that should outlive a session.
- The trade-off between sending rendered pixels and sending a reconstructed, sanitized version of the page's DOM to the client.
State your assumptions, do rough capacity math, and call out the main risks and trade-offs.
Hints
Hint 1
Start with sizing: estimate memory and CPU per browser instance, then derive host count, regional spread and aggregate egress bandwidth for 50,000 sessions. Also break a ~100 ms input-to-display budget into network, render, encode and decode parts.
Hint 2
Ask what the blast radius is if the browser's own sandbox is escaped. This should drive your choice between containers, user-space kernels and micro-VMs, and push you toward one-session-per-VM, no reuse, and egress only through a filtering proxy.
Hint 3
Separate state into two classes: runtime state (DOM, JS heap) that should never be saved, and opt-in user profile data (cookies for approved apps) that can be encrypted and rehydrated. Then think about enforcing policy at several layers: network proxy, inside the browser, and in the viewer.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
1. Clarify and size the problem
Assumptions:
- 50,000 concurrent sessions, global, with load following business hours across time zones.
- One Chromium instance needs roughly 300-500 MB RAM and 0.3-0.5 vCPU on average, with spikes on video-heavy pages.
- A 64 vCPU / 256 GB host holds about 100 sessions, so about 500 hosts. Add 20-30% for warm pools and N+1 redundancy, spread over around 8 regions with edge points of presence.
- Pixel streaming averages 1-3 Mbps per session using damage-region video encoding. At 2 Mbps, 50k sessions is about 100 Gbps of egress. DOM-style streaming is closer to 100-300 kbps.
- Latency budget for input-to-photon at p95: under 100 ms, roughly 40 ms network RTT, 20 ms render, 15 ms encode, 10 ms decode, plus slack. Users therefore need a PoP within about 40 ms RTT.
- Clientless: the user needs only a normal browser tab running a JS viewer, reached via a secure web gateway redirect or an extension.
2. Interfaces
POST /v1/sessions {url, tenantId}returns session ID, signaling URL, ICE servers and a token.GET /v1/sessions/{id}andDELETE /v1/sessions/{id}.- A WebSocket signaling channel for SDP/ICE exchange and reconnects.
PUT /v1/admin/policies/{tenantId}for rules.- Input events (mouse, keys, scroll, IME, clipboard) go over a WebRTC data channel, not REST.
3. Data model
- Session: id, user, tenant, node, region, state (WARM, ACTIVE, DETACHED, TERMINATED), timestamps. Kept in a regional KV store with TTL.
- Policy: versioned per tenant (URL categories, allow/deny lists, script patterns, clipboard/upload/download rules, render mode). Stored in replicated SQL and pushed to nodes as snapshots.
- UserProfile: encrypted cookie jar and preferences, encrypted with a per-user KMS/HSM key.
- AuditEvent: append-only stream (Kafka into a SIEM).
4. Architecture
- GeoDNS/anycast plus a global load balancer send users to the nearest healthy region.
- A regional session broker authenticates through the corporate IdP (OIDC/SAML), checks policy, claims a pre-warmed VM and returns signaling details.
- A browser node fleet runs Firecracker micro-VMs under a node agent.
- A media layer streams over WebRTC, with TURN on UDP/443 and TCP/443 for restrictive networks.
- An egress proxy carries all outbound traffic: URL filtering, TLS inspection, malware scanning, and tenant-specific egress IPs.
- A file sanitization service applies content disarm and reconstruction or converts downloads to rendered PDFs.
- A control plane handles policy, autoscaling, image builds, telemetry and audit.
5. Deep dives
Browser node
Containers share the host kernel, so a Chromium sandbox escape plus a kernel exploit could compromise every co-located session. Micro-VMs give each session its own guest kernel with a minimal device model, boot in about 125 ms and cost around 5 MB overhead. gVisor is a middle ground; full VDI at 1-2 GB per session is too heavy.
Guest image: immutable read-only root, tmpfs scratch, hardened Chromium with its internal sandbox still on, a headless display, a capture/encode pipeline and a small agent. No SSH, no shell. The network allows egress only to the proxy, with no path to other VMs or the cloud metadata service.
Disposability: destroy the VM on session end, idle timeout or a hard cap (e.g. 8 hours); never reuse it across users. A warm pool of 5-10% of capacity hides boot time. Rebuild images daily so browser patches ship within hours.
Streaming
WebRTC is the primary transport: UDP with SRTP, built-in congestion control, NACK/FEC and hardware decode in the client. The server encodes H.264 or VP9, with GPU encoding for media-heavy pools and CPU elsewhere. Encoding only damaged regions makes static pages nearly free. The fallback is WebSocket over TLS with WebCodecs/MSE when UDP is blocked.
Input uses an unordered, unreliable data channel for mouse moves and a reliable, ordered one for keys and clicks. Latency tricks: optimistic local scroll momentum, locally drawn cursor, local echo for typing, and trading resolution for frame rate when bandwidth drops.
State and persistence
- Runtime state (DOM, JS heap) is never persisted. On a network blip, the VM goes to DETACHED for a grace window of about 5 minutes; the client reconnects with its session ID and token and the broker routes it back to the same node. If the node dies, the session is lost and the user starts fresh from profile state.
- Profile state (cookies and storage for allow-listed SaaS domains, preferences) is opt-in per policy. It is checkpointed periodically, encrypted per user, and rehydrated into new VMs. Cookies from uncategorized or risky sites are never saved, so malicious state cannot carry across sessions.
Policy enforcement
Three layers: the proxy (URL categories, domain lists), the browser (request interception via DevTools Protocol to block script URLs or hashes, CSP injection, disabling APIs such as WebUSB), and the viewer (clipboard direction, printing, uploads, read-only mode on suspected phishing pages). Policies are versioned, hot-pushed and every decision is logged.
6. Pixels vs DOM reconstruction
| Pixel streaming | DOM reconstruction | |
|---|---|---|
| Security | Strongest; only pixels reach the endpoint | Weaker; sanitized markup/CSS runs locally, so parser bugs become attack surface |
| Fidelity | Works on any site | Struggles with canvas, WebGL, complex SPAs |
| Bandwidth | 1-5 Mbps | 100-300 kbps |
| Latency feel | Depends on RTT unless masked locally | Local scrolling and text feel native |
| Accessibility | Poor for text selection, screen readers unless extra metadata is sent | Native |
A sensible answer is hybrid: default to pixels for unknown or high-risk sites, and allow DOM mode for trusted categories or bandwidth-constrained users, with the mode chosen by policy.
7. Failure modes and common mistakes
- Reusing VMs or containers across users to save boot cost; use warm pools instead.
- Forgetting that the proxy and TURN are part of the attack surface and need their own hardening.
- Ignoring UDP-blocked networks, which breaks WebRTC for many corporate users.
- Persisting full browser profiles, which lets malware persist.
- Not sizing egress: 100 Gbps drives PoP placement and cost.
- Overlooking file transfer: downloads and uploads are the main exfiltration and infection path.
Scaling follows regional demand: autoscale on active plus warm sessions, drain hosts gracefully, and keep each region able to absorb a neighbour's failover with the headroom budgeted above.