Skip to content

armgit / avibe

Public Imported from GitHub
0

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.

fix(remote-access): tighten local bypass checks

cyh4e966272c287
diff --git a/tests/test_ui_remote_access_auth.py b/tests/test_ui_remote_access_auth.py
index 7cf5af8a9..0bca37922 100644
--- a/tests/test_ui_remote_access_auth.py
+++ b/tests/test_ui_remote_access_auth.py
@@ -100,6 +100,20 @@ def test_unmatched_non_local_host_fails_closed_when_remote_access_enabled(monkey
assert response.get_json()["error"] == "remote_access_host_mismatch"
+def test_loopback_proxy_with_public_host_mismatch_fails_closed(monkeypatch, tmp_path):
+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))
+ _save_config(tmp_path)
+
+ response = app.test_client().get(
+ "/dashboard",
+ base_url="https://old-alex.avibe.bot",
+ follow_redirects=False,
+ )
+
+ assert response.status_code == 503
+ assert response.get_json()["error"] == "remote_access_host_mismatch"
+
+
def test_remote_host_allows_valid_remote_session(monkeypatch, tmp_path):
monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))
config = _save_config(tmp_path)
@@ -228,6 +242,23 @@ def test_remote_host_fails_closed_when_public_url_is_invalid(monkeypatch, tmp_pa
assert response.get_json()["error"] == "remote_access_public_url_invalid"
+def test_remote_host_fails_closed_when_public_url_is_http(monkeypatch, tmp_path):
+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))
+ config = _save_config(tmp_path)
+ config.remote_access.vibe_cloud.public_url = "http://alex.avibe.bot"
+ config.save()
+
+ response = app.test_client().get(
+ "/dashboard",
+ base_url="https://alex.avibe.bot",
+ environ_base=_remote_peer(),
+ follow_redirects=False,
+ )
+
+ assert response.status_code == 503
+ assert response.get_json()["error"] == "remote_access_public_url_invalid"
+
+
def test_remote_host_fails_closed_when_public_url_contains_userinfo(monkeypatch, tmp_path):
monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))
config = _save_config(tmp_path)
diff --git a/vibe/ui_server.py b/vibe/ui_server.py
index d7fd592dd..3c09009ad 100644
--- a/vibe/ui_server.py
+++ b/vibe/ui_server.py
@@ -218,8 +218,18 @@ def _is_loopback_peer() -> bool:
return bool(mapped and mapped.is_loopback)
+def _is_loopback_host(value: str | None) -> bool:
+ host = _normalized_host(value)
+ if host == "localhost":
+ return True
+ try:
+ return ipaddress.ip_address(host).is_loopback
+ except ValueError:
+ return False
+
+
def _is_local_request() -> bool:
- return _is_loopback_peer() and not _has_cloudflare_forwarded_metadata()
+ return _is_loopback_peer() and _is_loopback_host(request.host) and not _has_cloudflare_forwarded_metadata()
def _normalized_host(value: str | None) -> str:
@@ -245,7 +255,7 @@ def _remote_access_public_host(config: V2Config) -> str | None:
if not public_url:
return ""
parsed = urlparse(public_url)
- if parsed.scheme not in {"http", "https"} or not parsed.netloc or parsed.username or parsed.password:
+ if parsed.scheme != "https" or not parsed.netloc or parsed.username or parsed.password:
return None
return _normalized_host(parsed.hostname)