Skip to content

The headless browser for AI agents and web scraping

docs: document new flags, stealth identity vars, MCP/SSRF hardening, and DOM-agent CDP methods (#288)

SGavrl3eada2404c87
diff --git a/docs/CLI-reference.md b/docs/CLI-reference.md
index 592c4b9b..fee7a510 100644
--- a/docs/CLI-reference.md
+++ b/docs/CLI-reference.md
@@ -61,6 +61,7 @@ Run the CDP server. Puppeteer and Playwright connect over WebSocket.
--allow-file-access Permit CDP clients to navigate to file:// URLs
--storage-dir <DIR> Persistent cookies and localStorage
--allow-private-network Permit loopback / RFC1918 / link-local
+-q, --quiet Suppress info logging
-v, --verbose Enable info logging
```
@@ -95,6 +96,7 @@ Run obscura as an MCP server.
```
--http HTTP transport instead of stdio
+ --host <HOST> HTTP bind host (default 127.0.0.1)
--port <PORT> HTTP port (default 3000)
--proxy <URL> HTTP or SOCKS5 proxy
--user-agent <UA> Override the User-Agent
@@ -103,4 +105,6 @@ Run obscura as an MCP server.
-v, --verbose Enable info logging
```
+`--host` only applies with `--http`. The default `127.0.0.1` keeps the server loopback-only; set `0.0.0.0` to bind all interfaces (for example a Docker Compose sidecar) and pair it with `OBSCURA_MCP_ALLOWED_ORIGINS`.
+
Default transport is stdio. See [Use the MCP server](Use-the-MCP-server.md).
diff --git a/docs/Configure-stealth-and-proxies.md b/docs/Configure-stealth-and-proxies.md
index 50b13dd9..e3b3e074 100644
--- a/docs/Configure-stealth-and-proxies.md
+++ b/docs/Configure-stealth-and-proxies.md
@@ -60,6 +60,31 @@ obscura serve --user-agent "Mozilla/5.0 (...) ..."
Default UA matches a recent Chrome on the build platform.
+## Browser profile, timezone, and geolocation
+
+The engine presents one of a built-in pool of realistic browser profiles (a mix of Windows and macOS, recent Chrome versions). Each profile keeps `navigator.platform`, `navigator.userAgentData` (platform and platform version), the UA string, and the WebGL/GPU renderer internally consistent, so the surfaces a site fingerprints agree with each other. Windows profiles report ANGLE Direct3D11 renderers, macOS profiles report ANGLE Metal renderers.
+
+A single stable profile is used by default. One IP cycling through different identities is itself a signal, so rotation is opt-in:
+
+```bash
+OBSCURA_PROFILE=2 obscura serve # pin a specific profile by index
+OBSCURA_ROTATE_PROFILE=1 obscura serve # random profile per browser context
+```
+
+Timezone is driven by the process zone so `Date` (`getTimezoneOffset`, `toString`) and `Intl.DateTimeFormat` report the same region. Default is `Europe/Berlin`; set it to match the exit IP:
+
+```bash
+OBSCURA_TIMEZONE=America/New_York obscura serve
+```
+
+`navigator.geolocation` reports configurable coordinates. Set them as `lat,lon` and keep them consistent with the timezone and proxy region:
+
+```bash
+OBSCURA_GEOLOCATION="40.7128,-74.0060" obscura serve
+```
+
+Keep these aligned. A rotated or mismatched profile carries no matching TLS or timezone fingerprint, so when you pin a proxy region or TLS fingerprint, leave rotation off and set the timezone and geolocation to the same region. See [Environment variables](Environment-variables.md) for the full list.
+
## Combine
```bash
diff --git a/docs/Connect-Puppeteer-or-Playwright.md b/docs/Connect-Puppeteer-or-Playwright.md
index 1653c025..8d347714 100644
--- a/docs/Connect-Puppeteer-or-Playwright.md
+++ b/docs/Connect-Puppeteer-or-Playwright.md
@@ -72,13 +72,15 @@ await page.goto('https://example.com', { waitUntil: 'load' });
- `page.goto`, `page.reload`, `page.goBack`, `page.goForward`
- `page.evaluate`, `page.evaluateHandle`
-- `page.click`, `page.type`, `page.fill`
+- `page.click`, `page.type`, `page.fill`, `page.focus`
- `page.waitForSelector`, `page.waitForFunction`, `page.waitForNavigation`
- `page.cookies`, `page.setCookie`, `context.cookies`
- `page.setRequestInterception`, block / modify
- `page.exposeFunction`
- `page.content`, `page.title`, `page.url`
+DOM-agent frameworks such as browser-use also connect: obscura implements `DOMSnapshot.captureSnapshot` and `Target.targetInfoChanged` for perception, and `DOM.focus` so a focused field receives `Input.dispatchKeyEvent` keystrokes.
+
## Not supported
- `page.screenshot`: obscura doesn't render pixels.
diff --git a/docs/Environment-variables.md b/docs/Environment-variables.md
index 05ae02e9..af50c5e9 100644
--- a/docs/Environment-variables.md
+++ b/docs/Environment-variables.md
@@ -2,7 +2,9 @@
### `OBSCURA_ALLOW_PRIVATE_NETWORK`
-Allow fetches to loopback (`127.0.0.0/8`), RFC1918 (`10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`), and link-local (`169.254.0.0/16`) addresses. Off by default to block SSRF.
+Allow fetches to loopback (`127.0.0.0/8`), RFC1918 (`10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`), and link-local (`169.254.0.0/16`, including the `169.254.169.254` cloud-metadata endpoint) addresses. The deny-set also covers the unspecified address (`0.0.0.0` / `::`), IPv6 unique-local (`fc00::/7`), and any IPv4-mapped form of the above. Off by default to block SSRF.
+
+The guard validates at DNS-resolution time as well as on literal hosts, so a public hostname that resolves to a forbidden address is rejected at connect time (DNS-rebinding safe), not just hosts written as raw IPs.
Truthy values: `1`, `true`, `yes`, `on`.
@@ -44,6 +46,52 @@ Default proxy URL used by `obscura-worker` for the parallel `scrape` command whe
OBSCURA_PROXY=http://proxy.example.com:8080 obscura scrape - < urls.txt
```
+## Stealth and identity
+
+These tune the browser identity the engine presents so it stays internally consistent. See [Configure stealth and proxies](Configure-stealth-and-proxies.md) for the full picture.
+
+### `OBSCURA_TIMEZONE`
+
+Pins the process timezone before V8/ICU reads it, so `Date` (`getTimezoneOffset`, `toString`) and `Intl.DateTimeFormat` report one consistent zone. Default `Europe/Berlin`. Set it to match the exit IP's region.
+
+```bash
+OBSCURA_TIMEZONE=America/New_York obscura serve
+```
+
+### `OBSCURA_GEOLOCATION`
+
+Override the coordinates the `navigator.geolocation` shim reports, as `lat,lon`. Without it the shim reports a fixed default. Keep it consistent with `OBSCURA_TIMEZONE` and the proxy region.
+
+```bash
+OBSCURA_GEOLOCATION="40.7128,-74.0060" obscura serve
+```
+
+### `OBSCURA_PROFILE`
+
+Pin a specific browser profile from the built-in pool by index (`0`-based). Each profile keeps `navigator.platform`, `userAgentData`, the UA string, and the GPU renderer internally consistent. Without it a single stable profile is used.
+
+```bash
+OBSCURA_PROFILE=2 obscura serve
+```
+
+### `OBSCURA_ROTATE_PROFILE`
+
+Opt into picking a random profile per browser context instead of the stable default. Leave it off when you pin a TLS fingerprint, proxy region, or timezone, since a rotated profile would no longer match those.
+
+```bash
+OBSCURA_ROTATE_PROFILE=1 obscura serve
+```
+
+## MCP
+
+### `OBSCURA_MCP_ALLOWED_ORIGINS`
+
+Comma-separated `Origin` allowlist for the HTTP MCP transport (`obscura mcp --http`). Off by default, which keeps the permissive behavior. When set, a browser request whose `Origin` is not listed is refused with `403` before it can drive the server; native, non-browser MCP clients (which send no `Origin`) are always allowed. Use it to stop cross-origin pages from reaching a loopback MCP port.
+
+```bash
+OBSCURA_MCP_ALLOWED_ORIGINS="https://app.example.com" obscura mcp --http --host 0.0.0.0
+```
+
## Logging
### `RUST_LOG`
@@ -76,7 +124,7 @@ V8 flags are passed via `--v8-flags`, not environment variables:
obscura serve --v8-flags "--max-old-space-size=2048 --expose-gc"
```
-Default heap is 4 GB on 64-bit systems.
+Defaults are `--max-old-space-size=4096 --max-semi-space-size=4 --optimize-for-size` on 64-bit systems (a 4 GB old-space ceiling, a capped young generation, and codegen tuned for a smaller footprint to cut RSS). Anything you pass with `--v8-flags` is appended after these, and V8 uses the last value for a repeated flag, so your value wins for that flag while the other defaults stay in effect.
## HTTP proxy environment
diff --git a/docs/Run-in-production-at-scale.md b/docs/Run-in-production-at-scale.md
index 0958cbe4..6eaafdf4 100644
--- a/docs/Run-in-production-at-scale.md
+++ b/docs/Run-in-production-at-scale.md
@@ -50,13 +50,13 @@ Use one worker per CPU core. Each worker handles its own pool of pages. Sessions
## V8 heap
-Default V8 heap is 4 GB on 64-bit systems. Override:
+Default V8 heap is 4 GB on 64-bit systems. The defaults also cap the young generation (`--max-semi-space-size=4`) and pass `--optimize-for-size` to hold RSS down. Override:
```bash
obscura serve --v8-flags "--max-old-space-size=2048"
```
-Lower for memory-constrained hosts, raise for heavy SPAs.
+Flags you pass are appended after the defaults, and V8 uses the last value for a repeated flag, so your `--max-old-space-size` wins while the memory-tuning defaults stay in effect. Lower for memory-constrained hosts, raise for heavy SPAs.
## Parallel scrape
@@ -120,6 +120,17 @@ Obscura's CDP server has no built-in auth. Anyone who can reach the port can dri
Never bind `0.0.0.0` on a public IP without one of the above.
+## MCP HTTP transport
+
+`obscura mcp --http` binds `127.0.0.1` by default. To reach it from another container, bind with `--host 0.0.0.0` and set an `Origin` allowlist so a browser page cannot drive it cross-origin:
+
+```bash
+OBSCURA_MCP_ALLOWED_ORIGINS="https://app.example.com" \
+ obscura mcp --http --host 0.0.0.0 --port 3000
+```
+
+Request bodies are capped at 16 MiB. Like the CDP server it has no built-in auth, so keep it on an internal network or behind an authenticating proxy. See [Use the MCP server](Use-the-MCP-server.md).
+
## Observability
```bash
diff --git a/docs/Use-the-MCP-server.md b/docs/Use-the-MCP-server.md
index 9769deb6..b6af3d09 100644
--- a/docs/Use-the-MCP-server.md
+++ b/docs/Use-the-MCP-server.md
@@ -14,12 +14,31 @@ HTTP (for remote or shared use):
obscura mcp --http --port 3000
```
+The HTTP transport binds `127.0.0.1` by default. Bind all interfaces with `--host` for a container or sidecar deployment:
+
+```bash
+obscura mcp --http --host 0.0.0.0 --port 3000
+```
+
With stealth and proxy:
```bash
obscura mcp --stealth --proxy http://proxy.example.com:8080
```
+## Security
+
+The HTTP transport has no built-in auth, so anyone who can reach the port can drive the browser. Two guards ship for the HTTP transport:
+
+- **Origin allowlist.** Set `OBSCURA_MCP_ALLOWED_ORIGINS` to a comma-separated list of allowed `Origin` values. When set, a browser request from an unlisted origin is refused with `403` before it can drive the server, which blocks a malicious page from POSTing to a loopback MCP port. Native, non-browser clients send no `Origin` and are always allowed. Unset (the default) keeps the permissive behavior.
+- **Body cap.** A single request body is capped at 16 MiB, so an unauthenticated caller cannot force a large allocation with an oversized `Content-Length`.
+
+```bash
+OBSCURA_MCP_ALLOWED_ORIGINS="https://app.example.com" obscura mcp --http --host 0.0.0.0
+```
+
+When you expose the HTTP transport beyond loopback, set the allowlist and put it behind a reverse proxy or network isolation that enforces auth.
+
## Tools exposed
The server keeps a live browser session, so tools operate on the current page rather than taking a URL each call. Navigate first, then read or act.