🐼 Lightpanda Session Bridge
The Authenticated Session Bridge for Machines and Autonomous AI Agents

Live Showcase Website · Read Article on DEV.to · Playwright & Puppeteer Integration · Architecture · Quickstart · Security Standard · Python SDK
Seamlessly bridge real-world authenticated web sessions (Google OAuth, Passkeys, SSO, 2FA) from your primary browser into a fast, isolated Lightpanda headless browser runtime in a single click. Zero credentials typed, zero secrets exposed to LLMs.
Works with any Chromium-based browser — Chrome, Edge, Brave, Opera, Vivaldi, Arc, Comet, Chromium itself. Any browser that can load a Manifest V3 extension and speak CDP works as the source of the session.
🌟 Overview
Modern web services (SaaS consoles, API dashboards, cloud providers) protect their dashboards with Google OAuth, multi-factor authentication, and bot mitigations.
Autonomous AI agents using headless browsers cannot easily log in themselves without requiring sensitive credentials, passwords, or handling complex OTP prompts.
Lightpanda Session Bridge solves this fundamental friction:
- You log in naturally in your favorite desktop browser (using your actual Google account or Passkey).
- Click the Bridge extension (or run the CLI tool): your session cookies and local storage are filtered, validated, and injected over CDP into Lightpanda.
- Your AI agents operate autonomously in the background on the real authenticated session at 9x the speed of Chrome and with 16x less memory.
🔒 Security Guarantees (Zero-Trust Standard)
- 🛡️ Strict Origin Scoping: Loopback addresses, private networks, identity provider root domains (
accounts.google.com, login.microsoftonline.com, auth0.com, github.com) are permanently blocked. Only target SaaS domains (e.g., a6api.com, mail.google.com, console.cloud.google.com) are admitted.
- 🍪 RFC 6265bis Compliance (
__Host- / __Secure-): Domain attributes on domain-locked cookies are automatically normalized to guarantee zero rejection by Lightpanda’s CDP parser.
- ⚡ CDP Enum Translation: Automatic translation of Chromium’s lowercase
sameSite strings (no_restriction, lax) into strict PascalCase enum tags (Strict, Lax, None) preventing -31998 InvalidEnumTag errors.
- 🔑 Zero Secret Leakage: No passwords, refresh tokens, or API keys are ever stored in disk logs or transmitted in chat histories.
- 📌 Extension-ID Pinning (TOFU): The relay only reflects CORS and accepts extension callers from a pinned extension ID (default: the official extension ID, enforced on
/v1/bootstrap, /v1/sessions, /v1/cdp, and preflights). First-use pinning for custom builds: LP_BRIDGE_TOFU=1 (or list trusted IDs in LP_BRIDGE_ALLOWED_EXTENSION_IDS). Unpacked extensions derive their ID from the load path — if you load the extension from a custom location, use TOFU mode on first launch or the relay will refuse it (upstream discussion: #1, thanks @suleyman416).
- ⚠️ Known Limitation — the CDP port is a network boundary, not a process one: The relay authenticates its API (shared token + extension origin checks), but the Lightpanda runtime it feeds lives on an unauthenticated CDP port (
127.0.0.1:9222). Any local process that can open a loopback socket can list targets via GET /json and drive the authenticated session — on an agent host, that population includes the agent’s own subprocesses and whatever it was told to run. Treat the synchronized runtime as disposable: only sync sessions for sites you consider low-risk, keep the port bound to loopback, and shut Lightpanda down when no agent run needs the session.
- 🔌 Playwright & Puppeteer ready: Connect any CDP client (
playwright.chromium.connect_over_cdp, puppeteer.connect) to the authenticated Lightpanda instance on 127.0.0.1:9222 — no login walls, no 2FA prompts inside your tests. See docs/PLAYWRIGHT_PUPPETEER.md.
📐 Architecture
flowchart LR
subgraph Host ["Your Desktop Browser (Comet / Chrome)"]
A[User authenticates via Google OAuth / 2FA] --> B[Lightpanda Bridge Extension MV3]
end
subgraph Guard ["Loopback Guard Relay (:8765)"]
B -- HTTP POST Encrypted JSON --> C[Python Bridge Server]
C -- Origin & Domain Validation --> D[RFC Normalizer]
end
subgraph Runtime ["Headless Execution (WSL2 :9222)"]
D -- CDP WebSocket Transport --> E[Lightpanda Zig/V8 Kernel]
E --> F[(Isolated Memory Profile)]
end
subgraph Agents ["Autonomous AI Coding Agents"]
G[Hermes / Claude / Codex Agent] -->|lightpanda_client.py| E
end
📦 Installation Options
Option A: Clone & Run Locally
git clone https://github.com/Raknaos/lightpanda-session-bridge.git
cd lightpanda-session-bridge
pip install -r requirements.txt
Option B: Install via Pip (Package mode)
pip install lightpanda-session-bridge
(Provides lightpanda_client module and CLI utilities directly in your Python environment).
🚀 Quickstart (zero configuration)
One command — everything installs and starts:
python bridge.py setup
Installs Python deps, WSL2/Ubuntu check, the Lightpanda binary (auto-download), starts Lightpanda + the relay daemon, and prints what to do next (30 seconds, no manual steps).
Then load the browser extension (the only manual step, ~30 s):
python bridge.py install-browser-ext
- Open
chrome://extensions in your Chromium browser (Chrome, Edge, Brave, Opera, Vivaldi, Arc, Comet — edge://extensions in Edge, arc://extensions in Arc).
- Enable Developer Mode → Load unpacked → select the
extension/ folder.
- Pin the 🐼 icon. The extension auto-pairs with the relay on first open — no token to copy.
Sync any site and use it from agents:
- Click the 🐼 icon on any logged-in page → Sync Session. Done.
- Agents immediately act on the authenticated page:
from bridge_agent import AuthenticatedSession
s = AuthenticatedSession() # connects through the relay (token auto-read)
s.open("https://dev.to/settings") # any site you synced
print(s.js("document.body.getAttribute('data-user-status')")) # -> logged-in
Diagnose / status:
python bridge.py status # what's running
python bridge.py doctor # full diagnosis with fixes
Chrome never updates an extension that is loaded unpacked, and an extension is
not allowed to rewrite its own files. The bridge solves it the only way that
works: the local relay performs the update.
- A badge on the toolbar (and a chip in the popup) appears as soon as GitHub
is ahead of what the browser is running: a newer release, or a newer commit
on
main.
- Update makes the relay download the release zip (or the
main source
archive), verify its sha256 against the published sidecar, check that the
archive really is this extension, back up the current tree, write the new
files and reload the extension.
- Undo restores the tree saved immediately before the last update.
The same three operations from a terminal:
python relay/server.py --check-update # GitHub vs what runs here
python relay/server.py --apply-update # download + install + provenance
python relay/server.py --rollback-update # back to the previous tree
The provenance of the deployed copy lands in extension/.build-info.json
(version, tag, commit, sha256, source). It is git-ignored: it describes this
machine’s install, not the repository.
Only https://api.github.com, github.com, codeload.github.com and GitHub’s
object hosts are accepted, the download is size-capped, zip-slip and absolute
paths are refused, and the extension directory is the only thing ever written.
🛠️ Advanced: manual service control
Start services individually (legacy workflow)
Launch Lightpanda CDP server
Windows (WSL2):
./scripts/start-lightpanda.ps1
Linux / macOS (native):
chmod +x scripts/start-lightpanda.sh scripts/start-relay.sh
./scripts/start-lightpanda.sh
Listens on http://127.0.0.1:9222.
Start the local bridge relay
Windows (WSL2):
./scripts/start-relay.ps1
Linux / macOS (native):
./scripts/start-relay.sh
Listens on loopback http://127.0.0.1:8765.
Or simply: python bridge.py start (idempotent — starts only what’s missing).
🐍 Python SDK (bridge_agent.py)
Once a session is synchronized, autonomous agents interact through the relay’s persistent CDP connection (the only connection that holds the synced sessions):
from bridge_agent import AuthenticatedSession
# Connects through the relay — token is read automatically
s = AuthenticatedSession()
# Navigate to the authenticated page
s.open("https://a6api.com/console/log")
# Evaluate and extract authenticated data in memory
stats = s.js("""(async () => {
let res = await fetch('/api/user/self');
return await res.json();
})()""", await_promise=True)
print(f"Logged in user: {stats['data']['username']}")
⚠️ Why not connect to ws://127.0.0.1:9222 directly? Lightpanda scopes its cookie jar per CDP connection. A raw socket sees none of the synced sessions. All agent traffic must flow through POST /v1/cdp on the relay (loopback-only, token-authenticated) — bridge_agent.py does this for you. The legacy lightpanda_client.py is kept as a compatibility shim routed through the same proxy.
🧪 Security Test Suite
Run the unit test suite covering private IP rejection, IdP blocking, and CDP envelope validation:
python -m unittest discover -s tests -v
python relay/server.py --self-test
📄 License & Credits
- License: MIT License.
- Upstream Browser Engine: Lightpanda.io (GitHub).
- Bridge Authors: Raknaos & Nous Research.
评论