T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/bridge_server.py:33- Finding
Unauthenticated WebSocket Bridge Exposes Privileged Browser Automation
- Content
View full analysis
None: try: raw = await asyncio.wait_for(ws.recv(), timeout=10) except (TimeoutError, Exception) as e: logger.warning("Handshake timeout or failure: %s", e) return try: msg = json.loads(raw) except json.JSONDecodeError: return role = msg.get("role") if role == "extension": await self._handle_extension(ws) elif role == "cli": await self._handle_cli(ws, msg) else: logger.warning("Unknown role: %s", role) ``` ```python async def _handle_cli(self, ws: ServerConnection, msg: dict) -> None: if msg.get("method") == "ping_server": await ws.send( json.dumps({"result": {"extension_connected": self._extension_ws is not None}}) ) return if not self._extension_ws: err = ( "Extension not connected. Please ensure Chrome has " "the LinkedIn Bridge extension installed and enabled." ) await ws.send(json.dumps({"error": err})) return msg_id = str(uuid.uuid4()) msg["id"] = msg_id loop = asyncio.get_event_loop() future: asyncio.Future[Any] = loop.create_future() self._pending[msg_id] = future await self._extension_ws.send(json.dumps(msg)) ``` ```python async with websockets.serve(server.handle, "localhost", port): logger.info("Bridge server started: ws://localhost:%d", port) logger.info("Waiting for browser extension to connect...") await asyncio.Future() ``` The extension dispatches forwarded messages to privileged operations: ```javascript async function handleCommand(msg ...[truncated 3415 chars]- Remediation
View remediation
