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): gate docker loopback trust

cyha033b5f366b1
diff --git a/docker-compose.three-regression.yml b/docker-compose.three-regression.yml
index 6e76fbb70..0cef8ef29 100644
--- a/docker-compose.three-regression.yml
+++ b/docker-compose.three-regression.yml
@@ -11,6 +11,7 @@ services:
VIBE_DEPLOYMENT_ENV: regression
VIBE_UI_PORT: 5123
VIBE_REMOTE_ALLOW_DOCKER_LOOPBACK_PEERS: "1"
+ VIBE_REMOTE_DOCKER_LOOPBACK_BIND_HOST: "${THREE_REGRESSION_PORT_BIND_HOST:-127.0.0.1}"
PYTHONUNBUFFERED: "1"
ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-}
ANTHROPIC_BASE_URL: ${ANTHROPIC_BASE_URL:-}
diff --git a/tests/test_ui_remote_access_auth.py b/tests/test_ui_remote_access_auth.py
index 8420b01c3..914af4516 100644
--- a/tests/test_ui_remote_access_auth.py
+++ b/tests/test_ui_remote_access_auth.py
@@ -103,6 +103,7 @@ 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_LOOPBACK_PEERS", "1")
+ monkeypatch.setenv("VIBE_REMOTE_DOCKER_LOOPBACK_BIND_HOST", "127.0.0.1")
_save_config(tmp_path)
response = app.test_client().get(
@@ -114,9 +115,26 @@ def test_docker_loopback_host_is_local_when_explicitly_trusted(monkeypatch, tmp_
assert response.status_code == 200
+def test_docker_loopback_trust_requires_loopback_port_binding(monkeypatch, tmp_path):
+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))
+ monkeypatch.setenv("VIBE_REMOTE_ALLOW_DOCKER_LOOPBACK_PEERS", "1")
+ monkeypatch.setenv("VIBE_REMOTE_DOCKER_LOOPBACK_BIND_HOST", "0.0.0.0")
+ _save_config(tmp_path)
+
+ response = app.test_client().get(
+ "/health",
+ base_url="http://127.0.0.1:15130",
+ environ_base={"REMOTE_ADDR": "172.17.0.1"},
+ )
+
+ assert response.status_code == 503
+ assert response.get_json()["error"] == "remote_access_host_mismatch"
+
+
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_LOOPBACK_PEERS", "1")
+ monkeypatch.setenv("VIBE_REMOTE_DOCKER_LOOPBACK_BIND_HOST", "127.0.0.1")
_save_config(tmp_path)
response = app.test_client().get(
@@ -132,6 +150,7 @@ def test_docker_loopback_trust_still_rejects_non_local_host(monkeypatch, tmp_pat
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_LOOPBACK_PEERS", "1")
+ monkeypatch.setenv("VIBE_REMOTE_DOCKER_LOOPBACK_BIND_HOST", "127.0.0.1")
_save_config(tmp_path)
response = app.test_client().get(
@@ -147,6 +166,7 @@ def test_docker_loopback_trust_rejects_untrusted_peer(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_LOOPBACK_PEERS", "1")
+ monkeypatch.setenv("VIBE_REMOTE_DOCKER_LOOPBACK_BIND_HOST", "127.0.0.1")
monkeypatch.setenv("VIBE_REMOTE_DOCKER_LOOPBACK_PEER_CIDRS", "100.64.0.0/10")
_save_config(tmp_path)
diff --git a/vibe/ui_server.py b/vibe/ui_server.py
index 6ae4ba1c5..92fcc3def 100644
--- a/vibe/ui_server.py
+++ b/vibe/ui_server.py
@@ -228,8 +228,21 @@ def _is_loopback_host(value: str | None) -> bool:
return False
+def _env_flag_enabled(name: str) -> bool:
+ return os.environ.get(name, "").lower() in {"1", "true", "yes", "on"}
+
+
+def _has_loopback_only_docker_port_binding() -> bool:
+ bind_host = os.environ.get("VIBE_REMOTE_DOCKER_LOOPBACK_BIND_HOST")
+ if not bind_host:
+ return False
+ return _is_loopback_host(bind_host)
+
+
def _is_trusted_docker_peer() -> bool:
- if os.environ.get("VIBE_REMOTE_ALLOW_DOCKER_LOOPBACK_PEERS", "").lower() not in {"1", "true", "yes", "on"}:
+ if not _env_flag_enabled("VIBE_REMOTE_ALLOW_DOCKER_LOOPBACK_PEERS"):
+ return False
+ if not _has_loopback_only_docker_port_binding():
return False
remote_addr = (request.remote_addr or "").strip()