Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(ui): reject spoofed test remote addr header
cyh62f09f8562c2
diff --git a/tests/test_ui_remote_access_auth.py b/tests/test_ui_remote_access_auth.pyindex 4623daf49..dd10cbb96 100644--- a/tests/test_ui_remote_access_auth.py+++ b/tests/test_ui_remote_access_auth.py@@ -2,8 +2,11 @@ from __future__ import annotationsimport ipaddressimport socket+import asynciofrom collections import namedtuple+import httpx+from config.v2_config import AgentsConfig, PlatformsConfig, RemoteAccessConfig, RuntimeConfig, SlackConfig, UiConfig, V2Configfrom config.v2_config import CONFIG_LOCKfrom tests.ui_server_test_helpers import csrf_headers@@ -137,6 +140,27 @@ def test_localhost_does_not_require_remote_access_cookie(monkeypatch, tmp_path):assert response.status_code == 200+def test_live_request_cannot_spoof_test_remote_addr_header(monkeypatch, tmp_path):+ """The compatibility test-client shim accepts an environ_base REMOTE_ADDR,+ but the transport header it uses must not be honored on live ASGI traffic."""+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))+ _save_config(tmp_path)++ async def _exercise():+ transport = httpx.ASGITransport(app=app, client=("203.0.113.10", 50000))+ async with httpx.AsyncClient(transport=transport, base_url="http://127.0.0.1:5123") as client:+ return await client.get(+ "/dashboard",+ headers={"X-Vibe-Test-Remote-Addr": "127.0.0.1"},+ follow_redirects=False,+ )++ response = asyncio.run(_exercise())++ assert response.status_code == 503+ assert response.json()["error"] == "remote_access_host_mismatch"++def test_docker_loopback_host_requires_explicit_trust(monkeypatch, tmp_path):monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))monkeypatch.delenv("VIBE_REMOTE_ALLOW_DOCKER_LOOPBACK_PEERS", raising=False)diff --git a/vibe/ui_compat.py b/vibe/ui_compat.pyindex c92fad6f2..c6a0ee19f 100644--- a/vibe/ui_compat.py+++ b/vibe/ui_compat.py@@ -16,6 +16,8 @@ from fastapi.testclient import TestClientfrom starlette.datastructures import Headers, QueryParams, URL+TEST_REMOTE_ADDR_HEADER = "x-vibe-test-remote-addr"+_request_var: ContextVar["CompatRequest"] = ContextVar("ui_request")_g_var: ContextVar[Any] = ContextVar("ui_g")@@ -272,7 +274,7 @@ class CompatTestClient:if not base_url and "Origin" in headers:request_url = _join_base_url(headers["Origin"], url)remote_addr = environ_base.get("REMOTE_ADDR") or "127.0.0.1"- headers["X-Vibe-Test-Remote-Addr"] = str(remote_addr)+ headers[TEST_REMOTE_ADDR_HEADER] = str(remote_addr)request_url = _normalize_test_url_for_starlette(request_url, headers)kwargs.setdefault("follow_redirects", False)response = self._client.request(method, request_url, headers=headers, **kwargs)@@ -344,14 +346,7 @@ class CompatApp(FastAPI):async def __call__(self, scope: Any, receive: Any, send: Any) -> None:if scope.get("type") == "http":query = scope.get("query_string", b"").decode("latin-1")- remote_addr = next(- (- value.decode("latin-1")- for key, value in scope.get("headers", [])- if key == b"x-vibe-test-remote-addr"- ),- None,- )+ remote_addr = _test_remote_addr_from_scope(scope)if "&" in query or remote_addr:scope = dict(scope)scope["query_string"] = query.replace("&", "&").encode("latin-1")@@ -410,7 +405,7 @@ class CompatApp(FastAPI):defaults: dict[str, Any],) -> Response:json_payload = await _read_json_payload(starlette_request)- remote_addr = starlette_request.headers.get("x-vibe-test-remote-addr")+ remote_addr = _test_remote_addr_from_scope(starlette_request.scope)if remote_addr:starlette_request.scope["vibe_remote_addr"] = remote_addrcompat_request = CompatRequest(starlette_request, json_payload=json_payload)@@ -448,6 +443,20 @@ def _extract_path_args(route_regex: re.Pattern[str], path: str) -> dict[str, strreturn match.groupdict() if match else {}+def _test_remote_addr_from_scope(scope: Any) -> str | None:+ client = scope.get("client")+ if not isinstance(client, tuple) or client[:1] != ("testclient",):+ return None+ return next(+ (+ value.decode("latin-1")+ for key, value in scope.get("headers", [])+ if key == TEST_REMOTE_ADDR_HEADER.encode("latin-1")+ ),+ None,+ )++async def _read_json_payload(request: FastAPIRequest) -> Any:content_type = request.headers.get("content-type", "")if "application/json" not in content_type.lower():