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(regression): validate docker loopback peers
cyhdd6f8e19f3bf
diff --git a/docker-compose.three-regression.yml b/docker-compose.three-regression.ymlindex 5af5838c9..6e76fbb70 100644--- a/docker-compose.three-regression.yml+++ b/docker-compose.three-regression.yml@@ -10,7 +10,7 @@ services:VIBE_REMOTE_HOME: /data/vibe_remoteVIBE_DEPLOYMENT_ENV: regressionVIBE_UI_PORT: 5123- VIBE_REMOTE_ALLOW_DOCKER_LOCAL_HOSTS: "1"+ VIBE_REMOTE_ALLOW_DOCKER_LOOPBACK_PEERS: "1"PYTHONUNBUFFERED: "1"ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-}ANTHROPIC_BASE_URL: ${ANTHROPIC_BASE_URL:-}@@ -24,7 +24,7 @@ services:retries: 20start_period: 30sports:- - "${THREE_REGRESSION_PORT:-15130}:5123"+ - "${THREE_REGRESSION_PORT_BIND_HOST:-127.0.0.1}:${THREE_REGRESSION_PORT:-15130}:5123"volumes:- ./_tmp/three-regression/vibe:/data/vibe_remote- ./_tmp/three-regression/shared-home/.claude:/root/.claudediff --git a/scripts/run_three_regression.sh b/scripts/run_three_regression.shindex 98e86489f..714fd0361 100755--- a/scripts/run_three_regression.sh+++ b/scripts/run_three_regression.sh@@ -131,24 +131,12 @@ fiprint_summary() {local port="${THREE_REGRESSION_PORT:-15130}"- local ui_host="${THREE_REGRESSION_UI_HOST:-127.0.0.1}"+ local bind_host="${THREE_REGRESSION_PORT_BIND_HOST:-127.0.0.1}"+ local ui_host="${THREE_REGRESSION_ACCESS_HOST:-$bind_host}"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 jsonimport sysdiff --git a/tests/test_ui_remote_access_auth.py b/tests/test_ui_remote_access_auth.pyindex d927fa1ca..8420b01c3 100644--- a/tests/test_ui_remote_access_auth.py+++ b/tests/test_ui_remote_access_auth.py@@ -87,13 +87,13 @@ def test_localhost_does_not_require_remote_access_cookie(monkeypatch, tmp_path):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)+ monkeypatch.delenv("VIBE_REMOTE_ALLOW_DOCKER_LOOPBACK_PEERS", 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"},+ environ_base={"REMOTE_ADDR": "172.17.0.1"},)assert response.status_code == 503@@ -102,13 +102,13 @@ def test_docker_loopback_host_requires_explicit_trust(monkeypatch, tmp_path):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")+ monkeypatch.setenv("VIBE_REMOTE_ALLOW_DOCKER_LOOPBACK_PEERS", "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"},+ environ_base={"REMOTE_ADDR": "172.17.0.1"},)assert response.status_code == 200@@ -116,45 +116,43 @@ def test_docker_loopback_host_is_local_when_explicitly_trusted(monkeypatch, tmp_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")+ monkeypatch.setenv("VIBE_REMOTE_ALLOW_DOCKER_LOOPBACK_PEERS", "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"},+ environ_base={"REMOTE_ADDR": "172.17.0.1"},)assert response.status_code == 503assert response.get_json()["error"] == "remote_access_host_mismatch"-def test_docker_configured_local_host_is_local_when_explicitly_trusted(monkeypatch, tmp_path):+def test_docker_loopback_trust_rejects_untrusted_peer(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()+ monkeypatch.setenv("VIBE_REMOTE_ALLOW_DOCKER_LOOPBACK_PEERS", "1")+ _save_config(tmp_path)response = app.test_client().get("/health",- base_url="http://192.168.2.3:15130",- environ_base={"REMOTE_ADDR": "172.18.0.1"},+ base_url="http://127.0.0.1:15130",+ environ_base={"REMOTE_ADDR": "8.8.8.8"},)- assert response.status_code == 200+ assert response.status_code == 503+ assert response.get_json()["error"] == "remote_access_host_mismatch"-def test_docker_tailscale_local_host_is_local_when_explicitly_trusted(monkeypatch, tmp_path):+def test_docker_loopback_trust_supports_configured_peer_cidrs(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()+ monkeypatch.setenv("VIBE_REMOTE_ALLOW_DOCKER_LOOPBACK_PEERS", "1")+ monkeypatch.setenv("VIBE_REMOTE_DOCKER_LOOPBACK_PEER_CIDRS", "100.64.0.0/10")+ _save_config(tmp_path)response = app.test_client().get("/health",- base_url="http://100.97.103.112:15130",+ base_url="http://127.0.0.1:15130",environ_base={"REMOTE_ADDR": "100.97.103.112"},)diff --git a/vibe/ui_server.py b/vibe/ui_server.pyindex ec141bb75..6ae4ba1c5 100644--- a/vibe/ui_server.py+++ b/vibe/ui_server.py@@ -228,27 +228,38 @@ def _is_loopback_host(value: str | None) -> bool:return False-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:+def _is_trusted_docker_peer() -> bool:+ if os.environ.get("VIBE_REMOTE_ALLOW_DOCKER_LOOPBACK_PEERS", "").lower() not in {"1", "true", "yes", "on"}:return False- setup_host = _normalized_host(config.ui.setup_host)- if not setup_host or setup_host in {"0.0.0.0", "::"}:++ remote_addr = (request.remote_addr or "").strip()+ try:+ address = ipaddress.ip_address(remote_addr)+ except ValueError:return False- return _normalized_host(request.host) == setup_host++ cidrs = os.environ.get("VIBE_REMOTE_DOCKER_LOOPBACK_PEER_CIDRS", "172.16.0.0/12,192.168.65.0/24")+ for raw_network in cidrs.split(","):+ raw_network = raw_network.strip()+ if not raw_network:+ continue+ try:+ network = ipaddress.ip_network(raw_network, strict=False)+ except ValueError:+ continue+ if address in network:+ return True+ return False-def _is_local_request(config: V2Config | None = None) -> bool:+def _is_local_request() -> bool:if _has_cloudflare_forwarded_metadata():return False- if not (_is_loopback_host(request.host) or _is_configured_local_host(config)):+ if not _is_loopback_host(request.host):return Falseif _is_loopback_peer():return True- return _are_docker_local_hosts_allowed()+ return _is_trusted_docker_peer()def _normalized_host(value: str | None) -> str:@@ -389,7 +400,7 @@ def _redirect_to_vibe_cloud_login(config: V2Config):@app.before_requestdef enforce_remote_access_cookie():config = _load_remote_access_config()- local_request = _is_local_request(config)+ local_request = _is_local_request()if config is None:if local_request:return None