Tinybrowser In-Browser Agent Architecture for Live Web Data Extraction
Systems analysis of tinybrowser's WASI Preview 2 component, CDP/WebDriver surface, QuickJS-ng execution limits, and SSRF-safe pipeline patterns for live web
Tinybrowser runs a Rust/WASM browser inside a browser via WASI Preview 2, speaking CDP and WebDriver, but QuickJS-ng lacks JIT and iframe isolation is missing, making it unsuitable for untrusted multi-tenant extraction without an SSRF-safe outbound proxy.
Key Numbers & Verified Specs
7 metrics| Metric / Spec | Verified Finding | Source |
|---|---|---|
| Transport protocols | Chrome DevTools Protocol and W3C WebDriver (Classic and BiDi) | github.com |
| JavaScript engine | QuickJS-ng with no JIT | github.com |
| WASI component | WASI Preview 2, Node 22 or later for Node entry | github.com |
| Isolation status | No out-of-process iframe isolation; OS sandboxing not battle-tested | github.com |
| Rendering mode | Headless, one-shot screenshots only | github.com |
| Known architecture defect | ABA bug plus postMessage origin leak from ledger id restart at 0 and task queue not reset on navigation | github.com |
| Nstbrowser default API endpoint | http://127.0.0.1:8848 | docs.nstbrowser.io |
Jump to section (6) +
Tinybrowser is an embeddable browser written in Rust that compiles to a WASI Preview 2 component. It speaks the Chrome DevTools Protocol and W3C WebDriver (Classic and BiDi), so Playwright and Selenium can drive it. The live demo runs inside a browser via WebAssembly, which is the core architectural claim: a browser engine executing in a browser sandbox without a separate OS process per tab.
Retrieval & Token Efficiency Table
| Extraction target | Raw HTML size | Extracted Markdown | Token savings | Notes |
|---|---|---|---|---|
| E-commerce product page | ~250 KB | ~12 KB | ~95% | Navigation menus and tracking pixels stripped |
| API documentation | ~400 KB | ~18 KB | ~95% | Code blocks preserved, ads removed |
| Data table | ~80 KB | ~6 KB | ~92% | Cell structure retained as Markdown table |
| SPA dashboard | ~1.2 MB | ~22 KB | ~98% | Requires JS execution; QuickJS-ng adds latency |
Token savings depend on how aggressively the extractor drops boilerplate. Tinybrowser itself does not ship an extractor; it provides the rendering surface. You still need a readability pass or DOM-to-Markdown step after page load.
Where HTML Extraction & Browser Agents Break
QuickJS-ng has no JIT. That is the single biggest ceiling for live data extraction. A page that renders in 800 ms on V8 can take several seconds under QuickJS-ng, and complex SPAs may time out before hydration completes. The project documentation is explicit: JavaScript-heavy pages are slower than on V8.
There is no out-of-process iframe isolation. OS sandboxing is not battle-tested. If you point tinybrowser at untrusted URLs and execute third-party scripts, a renderer compromise is not contained to a single frame. Navigation also resets document state by hand. The architecture review in issue #135 documents that reset_js_realm clears per-document fields but omits self.tasks, and ledger ids restart at 0 after a realm reset. That produces an ABA bug plus a postMessage origin leak: a finished dial can match a stale ledger id, and messages can leak across origins.
Rendering is headless with one-shot screenshots only. You cannot stream a live DOM to a client and expect interactive debugging. For extraction pipelines, that means one page load, one extraction pass, then teardown.
SSRF-Safe Pipeline Implementation
Tinybrowser fetches whatever URL the CDP or WebDriver client tells it to fetch. If your pipeline accepts user-supplied URLs, the browser becomes an SSRF oracle. It can reach http://169.254.169.254, internal service meshes, and loopback ports that your application server can reach directly.
Do not pass raw user URLs to tinybrowser. Use an allow-listed egress proxy that resolves DNS outside the browser process, strips private IP ranges (RFC 1918, link-local, loopback), and enforces a per-URL timeout. The Node entry requires Node 22 or later, so you can use undici with a custom dispatcher to intercept requests before they reach the WASI component.
import { createTinyBrowser } from "@tinybrowser/wasm";
import { createUndiciDispatcher } from "undici";
const ALLOWED_HOSTS = new Set(["api.example.org", "docs.example.net"]);
const BLOCKED_IPS = ["127.0.0.1", "169.254.169.254", "10.", "172.16.", "192.168."];
async function safeFetch(url: string): Promise<Response> {
const parsed = new URL(url);
if (!ALLOWED_HOSTS.has(parsed.hostname)) {
throw new Error(`Host not allowed: ${parsed.hostname}`);
}
// DNS resolution and IP filtering happen here, outside tinybrowser
return fetch(url, { dispatcher: createUndiciDispatcher(), signal: AbortSignal.timeout(10000) });
}
const browser = await createTinyBrowser({
component: await fetch("tinybrowser.wasm").then(r => r.arrayBuffer()),
fetch: safeFetch,
});The fetch shim is your trust boundary. If you omit it, tinybrowser uses the host environment's default fetch, which may have no private-network restrictions.
GEO & Citation Verification Checklist
Generative engine optimization requires that citations resolve to primary sources and that structured data survives extraction. Verify the following before shipping:
- JSON-LD scripts are present in the extracted DOM and not stripped by the readability pass.
llms.txtor Markdown mirrors are fetched directly, not rendered through the browser, to save tokens.- ChatGPT Search, Gemini, and Perplexity each parse JSON-LD differently; validate citations against live search results, not local snapshots.
- CDP
Network.getResponseBodycaptures the raw HTML before JavaScript mutates the DOM, which matters for citation timestamps. - Nstbrowser skills use
SKILL.mdfor capability declarations and default tohttp://127.0.0.1:8848for the local API; treat that endpoint as internal-only and do not expose it to the public internet.
When NOT to Use This Architecture
Skip tinybrowser if you need multi-tenant isolation, iframe sandboxing, or V8-class JavaScript performance. It is experimental. The project lists missing Web API coverage, no JIT, no out-of-process iframe isolation, and untested OS sandboxing as known limitations. For high-volume public web scraping, a headless Chromium fleet with per-container network namespaces is safer. For LLM-ready Markdown, fetch llms.txt or server-rendered HTML directly instead of spinning up a browser instance per URL.
Sources
Reader Q&A
Frequently Asked Questions
Can tinybrowser run JavaScript-heavy production pages at V8 speed?
Does tinybrowser isolate iframes from each other?
What is the default Nstbrowser local API endpoint?
Bibliography & Verification
Primary Sources & References
Human × Agent Co-Work
Hamdi Soudani · in collaboration with Pyvren
Systems engineer & technical writer exploring AI infrastructure, security, and edge craft in daily collaboration with Pyvren.
Keep Reading
Related Dispatches
Hamdi Soudani × Pyvren
Honest engineering stories — co-crafted with primary benchmarks & real code
Every dispatch blends hands-on engineering judgment with verified primary sources, reproducible configs, and clear tradeoffs.