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_server): verify tailscale utun addresses
cyh2fb535a87d30
diff --git a/tests/test_ui_remote_access_auth.py b/tests/test_ui_remote_access_auth.pyindex 9b9b4d459..dac4b55ed 100644--- a/tests/test_ui_remote_access_auth.py+++ b/tests/test_ui_remote_access_auth.py@@ -1363,6 +1363,7 @@ def test_setup_host_wildcard_does_not_trust_generic_utun_tunnel(monkeypatch, tmpmonkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))_save_config_with_setup_host(tmp_path, "0.0.0.0")_mock_interface(monkeypatch, "100.97.103.112", 32, name="utun4")+ monkeypatch.setattr(ui_server, "_tailscale_local_addresses", lambda: frozenset())response = app.test_client().get("/dashboard",@@ -1375,10 +1376,27 @@ def test_setup_host_wildcard_does_not_trust_generic_utun_tunnel(monkeypatch, tmpassert response.get_json()["error"] == "remote_access_host_mismatch"+def test_setup_host_wildcard_trusts_utun_when_tailscale_reports_local_ip(monkeypatch, tmp_path):+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))+ _save_config_with_setup_host(tmp_path, "0.0.0.0")+ address = ipaddress.ip_address("100.97.103.112")+ _mock_interface(monkeypatch, str(address), 32, name="utun4")+ monkeypatch.setattr(ui_server, "_tailscale_local_addresses", lambda: frozenset({address}))++ response = app.test_client().get(+ "/health",+ base_url="http://100.97.103.112:5123",+ environ_base={"REMOTE_ADDR": "100.97.103.5"},+ )++ assert response.status_code == 200++def test_setup_host_ipv6_wildcard_does_not_trust_generic_utun_tunnel(monkeypatch, tmp_path):monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))_save_config_with_setup_host(tmp_path, "::")_mock_interface(monkeypatch, "fd7a:115c:a1e0::5", 128, name="utun4")+ monkeypatch.setattr(ui_server, "_tailscale_local_addresses", lambda: frozenset())response = app.test_client().get("/dashboard",@@ -1391,6 +1409,22 @@ def test_setup_host_ipv6_wildcard_does_not_trust_generic_utun_tunnel(monkeypatchassert response.get_json()["error"] == "remote_access_host_mismatch"+def test_setup_host_ipv6_wildcard_trusts_utun_when_tailscale_reports_local_ip(monkeypatch, tmp_path):+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))+ _save_config_with_setup_host(tmp_path, "::")+ address = ipaddress.ip_address("fd7a:115c:a1e0::5")+ _mock_interface(monkeypatch, str(address), 128, name="utun4")+ monkeypatch.setattr(ui_server, "_tailscale_local_addresses", lambda: frozenset({address}))++ response = app.test_client().get(+ "/health",+ base_url="http://[fd7a:115c:a1e0::5]:5123",+ environ_base={"REMOTE_ADDR": "fd7a:115c:a1e0::20"},+ )++ assert response.status_code == 200++def test_setup_host_with_cloudflare_metadata_is_not_local(monkeypatch, tmp_path):monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))_save_config_with_setup_host(tmp_path, "192.168.2.3")diff --git a/vibe/ui_server.py b/vibe/ui_server.pyindex bc717d78a..cd9768104 100644--- a/vibe/ui_server.py+++ b/vibe/ui_server.py@@ -9,7 +9,10 @@ import mimetypesimport osimport reimport secrets+import shutilimport socket+import subprocess+import timeimport threadingfrom datetime import datetimefrom pathlib import Path@@ -293,6 +296,9 @@ _WILDCARD_TRUST_LAN_INTERFACE_PREFIXES = (_WILDCARD_TRUST_OVERLAY_INTERFACE_PREFIXES = ("tailscale",)+_TAILSCALE_UTUN_INTERFACE_PREFIXES = ("utun",)+_TAILSCALE_IP_CACHE_TTL_SECONDS = 30.0+_TAILSCALE_IP_CACHE: tuple[float, frozenset[ipaddress._BaseAddress]] | None = Nonedef _is_private_address(address: ipaddress._BaseAddress) -> bool:@@ -496,15 +502,74 @@ def _is_wildcard_setup_host(setup_host: str) -> bool:return setup_host in {"0.0.0.0", "::", "*"}-def _allows_wildcard_setup_host_trust(interface_name: str, address: ipaddress._BaseAddress) -> bool:- normalized_name = interface_name.lower()- if (+def _is_tailscale_overlay_address(address: ipaddress._BaseAddress) -> bool:+ return (isinstance(address, ipaddress.IPv4Address)and address in _SHARED_ADDRESS_SPACEor isinstance(address, ipaddress.IPv6Address)and address in _TAILSCALE_IPV6_ADDRESS_SPACE- ):- return normalized_name.startswith(_WILDCARD_TRUST_OVERLAY_INTERFACE_PREFIXES)+ )+++def _tailscale_cli_candidates() -> list[str]:+ candidates: list[str] = []+ path = shutil.which("tailscale")+ if path:+ candidates.append(path)+ macos_app_cli = Path("/Applications/Tailscale.app/Contents/MacOS/Tailscale")+ if macos_app_cli.exists():+ candidates.append(str(macos_app_cli))+ return list(dict.fromkeys(candidates))+++def _tailscale_local_addresses() -> frozenset[ipaddress._BaseAddress]:+ global _TAILSCALE_IP_CACHE++ now = time.monotonic()+ if _TAILSCALE_IP_CACHE is not None:+ cached_at, cached_addresses = _TAILSCALE_IP_CACHE+ if now - cached_at < _TAILSCALE_IP_CACHE_TTL_SECONDS:+ return cached_addresses++ addresses: set[ipaddress._BaseAddress] = set()+ env = {**os.environ, "TAILSCALE_BE_CLI": "1"}+ for candidate in _tailscale_cli_candidates():+ try:+ result = subprocess.run(+ [candidate, "ip"],+ capture_output=True,+ text=True,+ timeout=1.5,+ check=False,+ env=env,+ )+ except Exception:+ continue+ if result.returncode != 0:+ continue+ for line in result.stdout.splitlines():+ try:+ address = ipaddress.ip_address(line.strip())+ except ValueError:+ continue+ if _is_tailscale_overlay_address(address):+ addresses.add(address)+ if addresses:+ break++ cached = frozenset(addresses)+ _TAILSCALE_IP_CACHE = (now, cached)+ return cached+++def _allows_wildcard_setup_host_trust(interface_name: str, address: ipaddress._BaseAddress) -> bool:+ normalized_name = interface_name.lower()+ if _is_tailscale_overlay_address(address):+ if normalized_name.startswith(_WILDCARD_TRUST_OVERLAY_INTERFACE_PREFIXES):+ return True+ if normalized_name.startswith(_TAILSCALE_UTUN_INTERFACE_PREFIXES):+ return address in _tailscale_local_addresses()+ return Falsereturn normalized_name.startswith(_WILDCARD_TRUST_LAN_INTERFACE_PREFIXES)