ai newsDi., 1. Dez.

Hardening an AI Browser MCP Without Stripping CSP: Origin-Guarded Iframes, Fail-Fast Batching & 17 Adversarial Probes

Most browser-automation tools for AI agents end up making an uncomfortable trade-off: Option A: Keep the automation surface minimal and safe, and watch the agent fail whenever it meets an OAuth iframe, a multi-field form that eats 6 LLM round trips, or a button checking event.isTrusted . Option B:

dev.toMontag 02:42 · 30.11.2 Min. Lesezeit
Bild: dev.to

Posted on Nov 30 • Originally published at wasabihu.github.io

Most browser-automation tools for AI agents end up making an uncomfortable trade-off:

In sessfork-mcp v0.3.1 (a single 913.2 KiB stripped Rust binary with zero Node.js and zero Tokio), we added all three high-leverage capabilities — cross-origin iframe execution, multi-step form batching, and real trusted mouse events — without loosening a single security invariant. Every boundary is backed by a runnable black-box adversarial suite ( scripts/security_verify.py: 17/17 PASS across 9 security domains, plus 45 Rust unit tests and 51 Python/E2E tests ).

Here is how the architecture works and how each failure mode is tested.

A common shortcut in browser-driver extensions is attaching a declarativeNetRequest rule that strips Content-Security-Policy response headers across the entire browser so injected scripts and eval never get blocked. That is unacceptable when the host browser holds live developer, cloud, or corporate sessions.

Instead of weakening CSP, sessfork-mcp works entirely through Chrome DevTools Protocol (CDP) isolation primitives:

In D9_frames_batch_and_trusted_click, the test harness mounts four iframes simultaneously ( same-origin with?code=OAUTH_SECRET_1#tok=FRAG_1, cross-origin with?jwt=CROSS_SECRET_2 and a hostile window.JSON.stringify = () => 'HIJACKED', a data:text/html frame, and a sandbox="allow-scripts" frame) and verifies:

Filling a login or settings form one MCP call at a time burns 4–6 extra LLM round trips. Yet letting an agent pass an arbitrary sequence of blind actions introduces two nasty hazards: password values echoing back into conversation history and post-navigation blind clicks (e.g., step 1 clicks a link that loads a confirmation page, and step 2 blindly clicks #danger on the new DOM).

browser_batch solves both at the protocol layer:

For normal browsing, sessfork-mcp runs zero-layout on Moli ( --compact --diff ), avoiding getBoundingClientRect() layout triggers so peak RSS stays at 66.6 MB, cumulative 8-step SaaS SPA input tokens drop by -85.4% ( 25,474 vs 174,114 on Playwright MCP), and a single 24 GB MacBook scales to 160 parallel agents ( +0.0 MB swap).

However, certain widgets explicitly check event.isTrusted === true or apply CSS transforms ( transform: rotate(15deg) ) where synthetic DOM.click() gets ignored.

v0.3.1 adds opt-in browser_click(..., trusted=true):

Security prose is cheap; runnable exploit probes stay honest across refactors. Every release of sessfork ships a zero-dependency local harness ( python3 scripts/security_verify.py ) that spawns the real compiled sessfork-mcp Rust binary and attacks it across 9 trust boundaries:

Zero API keys, zero external network calls, and zero access to your real browser profile:

git clone https://github.com/wasabihu/sessfork.git cd sessfork # 1. Build the single Rust MCP binary (~913 KiB, zero Tokio) cd rust/sessfork-mcp && cargo build --release --locked && cargo test --locked --all-targets && cd../.. # 2. Run all 17 live black-box adversarial probes (D1–D9) python3 scripts/security_verify.py # 3. Run Python unit & integration tests (51 tests) PYTHONPATH = src python3 -m unittest discover -s tests Enter fullscreen mode Exit fullscreen mode 5. Honest Boundaries ( Not Tested ≠ Clean ) A security write-up is only useful if it states what the system does not protect against:

Quelle: dev.to (dev.to). Original öffnen