---
title: "Tinybrowser In-Browser Agent Architecture for Live Web Data Extraction"
slug: "tinybrowser-in-browser-agent-architecture-live-web-data-extraction"
description: "Systems analysis of tinybrowser's WASI Preview 2 component, CDP/WebDriver surface, QuickJS-ng execution limits, and SSRF-safe pipeline patterns for live web"
author: "Hamdi Soudani"
category: "agentic-browser-web-data"
archetype: "architecture-analysis"
published_at: "2026-12-05T08:04:21.327+00:00"
updated_at: "2026-12-05T08:04:21.389716+00:00"
canonical_url: "https://pyvren.com/blog/tinybrowser-in-browser-agent-architecture-live-web-data-extraction"
reading_time_minutes: 4
word_count: 695
quality_score: 88
tags: ["tinybrowser","browser-agent","wasm","web-extraction","ssrf"]
keywords: ["tinybrowser wasm cdp webdriver architecture","quickjs-ng no jit browser extraction latency","ssrf safe browser agent pipeline typescript","in-browser browser agent live web data extraction","tinybrowser iframe isolation security limitations"]
sources: ["https://github.com/tinybrowser-dev/tinybrowser","https://github.com/tinybrowser-dev/tinybrowser/issues/135","https://docs.nstbrowser.io/guide/advanced/ai-agent-skills.html"]
---

# Tinybrowser In-Browser Agent Architecture for Live Web Data Extraction

> **TL;DR:** 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 Facts

- **Transport protocols:** Chrome DevTools Protocol and W3C WebDriver (Classic and BiDi) ([source](https://github.com/tinybrowser-dev/tinybrowser))
- **JavaScript engine:** QuickJS-ng with no JIT ([source](https://github.com/tinybrowser-dev/tinybrowser))
- **WASI component:** WASI Preview 2, Node 22 or later for Node entry ([source](https://github.com/tinybrowser-dev/tinybrowser))
- **Isolation status:** No out-of-process iframe isolation; OS sandboxing not battle-tested ([source](https://github.com/tinybrowser-dev/tinybrowser))
- **Rendering mode:** Headless, one-shot screenshots only ([source](https://github.com/tinybrowser-dev/tinybrowser))
- **Known architecture defect:** ABA bug plus postMessage origin leak from ledger id restart at 0 and task queue not reset on navigation ([source](https://github.com/tinybrowser-dev/tinybrowser/issues/135))
- **Nstbrowser default API endpoint:** http://127.0.0.1:8848 ([source](https://docs.nstbrowser.io/guide/advanced/ai-agent-skills.html))

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.

![Tinybrowser repository hero image showing embedded browser](https://repository-images.githubusercontent.com/1342103196/8cb9efcd-199b-4fa0-bed6-aebb43bda113)

## 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.

```typescript
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:

1. JSON-LD scripts are present in the extracted DOM and not stripped by the readability pass.
2. `llms.txt` or Markdown mirrors are fetched directly, not rendered through the browser, to save tokens.
3. ChatGPT Search, Gemini, and Perplexity each parse JSON-LD differently; validate citations against live search results, not local snapshots.
4. CDP `Network.getResponseBody` captures the raw HTML before JavaScript mutates the DOM, which matters for citation timestamps.
5. Nstbrowser skills use `SKILL.md` for capability declarations and default to `http://127.0.0.1:8848` for 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
- [tinybrowser-dev/tinybrowser repository](https://github.com/tinybrowser-dev/tinybrowser)
- [Architecture review issue #135: navigable vs document state, timers, cdp contexts](https://github.com/tinybrowser-dev/tinybrowser/issues/135)
- [Nstbrowser AI Agent Skills documentation](https://docs.nstbrowser.io/guide/advanced/ai-agent-skills.html)

## Frequently Asked Questions

### Can tinybrowser run JavaScript-heavy production pages at V8 speed?

No. JavaScript runs on QuickJS-ng with no JIT, so JS-heavy pages are slower than on V8, and rendering is headless with one-shot screenshots only.

### Does tinybrowser isolate iframes from each other?

No. There is no out-of-process iframe isolation yet, so a compromised renderer can potentially access sibling frame memory within the same process.

### What is the default Nstbrowser local API endpoint?

The default endpoint is http://127.0.0.1:8848, which should be treated as internal-only and not exposed to the public internet.

## Primary Sources

- https://github.com/tinybrowser-dev/tinybrowser
- https://github.com/tinybrowser-dev/tinybrowser/issues/135
- https://docs.nstbrowser.io/guide/advanced/ai-agent-skills.html
