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(regression): allow docker local UI hosts

cyh60d83ea29dc7
diff --git a/docker-compose.three-regression.yml b/docker-compose.three-regression.yml
index dbc38e67e..5af5838c9 100644
--- a/docker-compose.three-regression.yml
+++ b/docker-compose.three-regression.yml
@@ -10,6 +10,7 @@ services:
VIBE_REMOTE_HOME: /data/vibe_remote
VIBE_DEPLOYMENT_ENV: regression
VIBE_UI_PORT: 5123
+ VIBE_REMOTE_ALLOW_DOCKER_LOCAL_HOSTS: "1"
PYTHONUNBUFFERED: "1"
ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-}
ANTHROPIC_BASE_URL: ${ANTHROPIC_BASE_URL:-}
diff --git a/scripts/run_three_regression.sh b/scripts/run_three_regression.sh
index a078d7acc..98e86489f 100755
--- a/scripts/run_three_regression.sh
+++ b/scripts/run_three_regression.sh
@@ -133,6 +133,36 @@ print_summary() {
local port="${THREE_REGRESSION_PORT:-15130}"
local ui_host="${THREE_REGRESSION_UI_HOST:-127.0.0.1}"
local default_backend="${THREE_REGRESSION_DEFAULT_BACKEND:-opencode}"
+ local config_path="$OUTPUT_ROOT/vibe/config/config.json"
+
+ if [ -f "$config_path" ]; then
+ ui_host="$("$PYTHON_BIN" - "$config_path" "$ui_host" <<'PY'
+import json
+import sys
+
+path, fallback = sys.argv[1], sys.argv[2]
+try:
+ with open(path, encoding="utf-8") as fh:
+ payload = json.load(fh)
+ print((payload.get("ui") or {}).get("setup_host") or fallback)
+except Exception:
+ print(fallback)
+PY
+)"
+ default_backend="$("$PYTHON_BIN" - "$config_path" "$default_backend" <<'PY'
+import json
+import sys
+
+path, fallback = sys.argv[1], sys.argv[2]
+try:
+ with open(path, encoding="utf-8") as fh:
+ payload = json.load(fh)
+ print((payload.get("agents") or {}).get("default_backend") or fallback)
+except Exception:
+ print(fallback)
+PY
+)"
+ fi
local slack_channel="${THREE_REGRESSION_SLACK_CHANNEL:-}"
local discord_channel="${THREE_REGRESSION_DISCORD_CHANNEL:-}"
diff --git a/tests/test_ui_remote_access_auth.py b/tests/test_ui_remote_access_auth.py
index 0bca37922..d927fa1ca 100644
--- a/tests/test_ui_remote_access_auth.py
+++ b/tests/test_ui_remote_access_auth.py
@@ -85,6 +85,82 @@ def test_localhost_does_not_require_remote_access_cookie(monkeypatch, tmp_path):
assert response.status_code == 200
+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_LOCAL_HOSTS", raising=False)
+ _save_config(tmp_path)
+
+ response = app.test_client().get(
+ "/health",
+ base_url="http://127.0.0.1:15130",
+ environ_base={"REMOTE_ADDR": "203.0.113.10"},
+ )
+
+ assert response.status_code == 503
+ assert response.get_json()["error"] == "remote_access_host_mismatch"
+
+
+def test_docker_loopback_host_is_local_when_explicitly_trusted(monkeypatch, tmp_path):
+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))
+ monkeypatch.setenv("VIBE_REMOTE_ALLOW_DOCKER_LOCAL_HOSTS", "1")
+ _save_config(tmp_path)
+
+ response = app.test_client().get(
+ "/health",
+ base_url="http://127.0.0.1:15130",
+ environ_base={"REMOTE_ADDR": "203.0.113.10"},
+ )
+
+ assert response.status_code == 200
+
+
+def test_docker_loopback_trust_still_rejects_non_local_host(monkeypatch, tmp_path):
+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))
+ monkeypatch.setenv("VIBE_REMOTE_ALLOW_DOCKER_LOCAL_HOSTS", "1")
+ _save_config(tmp_path)
+
+ response = app.test_client().get(
+ "/health",
+ base_url="https://old-alex.avibe.bot",
+ environ_base={"REMOTE_ADDR": "203.0.113.10"},
+ )
+
+ assert response.status_code == 503
+ assert response.get_json()["error"] == "remote_access_host_mismatch"
+
+
+def test_docker_configured_local_host_is_local_when_explicitly_trusted(monkeypatch, tmp_path):
+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))
+ monkeypatch.setenv("VIBE_REMOTE_ALLOW_DOCKER_LOCAL_HOSTS", "1")
+ config = _save_config(tmp_path)
+ config.ui.setup_host = "192.168.2.3"
+ config.save()
+
+ response = app.test_client().get(
+ "/health",
+ base_url="http://192.168.2.3:15130",
+ environ_base={"REMOTE_ADDR": "172.18.0.1"},
+ )
+
+ assert response.status_code == 200
+
+
+def test_docker_tailscale_local_host_is_local_when_explicitly_trusted(monkeypatch, tmp_path):
+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))
+ monkeypatch.setenv("VIBE_REMOTE_ALLOW_DOCKER_LOCAL_HOSTS", "1")
+ config = _save_config(tmp_path)
+ config.ui.setup_host = "100.97.103.112"
+ config.save()
+
+ response = app.test_client().get(
+ "/health",
+ base_url="http://100.97.103.112:15130",
+ environ_base={"REMOTE_ADDR": "100.97.103.112"},
+ )
+
+ assert response.status_code == 200
+
+
def test_unmatched_non_local_host_fails_closed_when_remote_access_enabled(monkeypatch, tmp_path):
monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))
_save_config(tmp_path)
diff --git a/vibe/ui_server.py b/vibe/ui_server.py
index 3c09009ad..ec141bb75 100644
--- a/vibe/ui_server.py
+++ b/vibe/ui_server.py
@@ -228,8 +228,27 @@ def _is_loopback_host(value: str | None) -> bool:
return False
-def _is_local_request() -> bool:
- return _is_loopback_peer() and _is_loopback_host(request.host) and not _has_cloudflare_forwarded_metadata()
+def _are_docker_local_hosts_allowed() -> bool:
+ return os.environ.get("VIBE_REMOTE_ALLOW_DOCKER_LOCAL_HOSTS", "").lower() in {"1", "true", "yes", "on"}
+
+
+def _is_configured_local_host(config: V2Config | None) -> bool:
+ if config is None:
+ return False
+ setup_host = _normalized_host(config.ui.setup_host)
+ if not setup_host or setup_host in {"0.0.0.0", "::"}:
+ return False
+ return _normalized_host(request.host) == setup_host
+
+
+def _is_local_request(config: V2Config | None = None) -> bool:
+ if _has_cloudflare_forwarded_metadata():
+ return False
+ if not (_is_loopback_host(request.host) or _is_configured_local_host(config)):
+ return False
+ if _is_loopback_peer():
+ return True
+ return _are_docker_local_hosts_allowed()
def _normalized_host(value: str | None) -> str:
@@ -370,7 +389,7 @@ def _redirect_to_vibe_cloud_login(config: V2Config):
@app.before_request
def enforce_remote_access_cookie():
config = _load_remote_access_config()
- local_request = _is_local_request()
+ local_request = _is_local_request(config)
if config is None:
if local_request:
return None