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(auth): validate wire revision before ACK

Maxvintfeec17e549b1
diff --git a/tests/test_project_access_sync.py b/tests/test_project_access_sync.py
index c77faa23c..fc648e2c2 100644
--- a/tests/test_project_access_sync.py
+++ b/tests/test_project_access_sync.py
@@ -231,6 +231,46 @@ def test_invalid_intent_is_rejected_with_exact_ack(monkeypatch, tmp_path) -> Non
]
+def test_malformed_wire_revisions_are_rejected_without_ack(monkeypatch, tmp_path) -> None:
+ _engine, project = _create_project(tmp_path)
+ ack_payloads: list[dict] = []
+
+ malformed_intents = [
+ {
+ "project_id": project["id"],
+ "mode": "restricted",
+ "bindings": [],
+ },
+ {
+ "project_id": project["id"],
+ "revision": True,
+ "mode": "restricted",
+ "bindings": [],
+ },
+ {
+ "project_id": project["id"],
+ "revision": "0",
+ "mode": "restricted",
+ "bindings": [],
+ },
+ ]
+
+ def request(method, url, **kwargs):
+ if url.endswith("/project-index"):
+ return _Response({"projects": []})
+ if url.endswith("/project-access-intents"):
+ return _Response({"intents": malformed_intents})
+ ack_payloads.append(kwargs["json"])
+ return _Response({"project": {}})
+
+ monkeypatch.setattr(project_access_sync.requests, "request", request)
+ result = project_access_sync.sync_project_access_once(_config())
+
+ assert result["rejected"] == 3
+ assert result["ack_errors"] == 0
+ assert ack_payloads == []
+
+
def test_stale_intent_does_not_revert_or_ack(monkeypatch, tmp_path) -> None:
engine, project = _create_project(tmp_path)
with engine.begin() as conn:
diff --git a/vibe/project_access_sync.py b/vibe/project_access_sync.py
index f9ffb0ab9..8c61dc775 100644
--- a/vibe/project_access_sync.py
+++ b/vibe/project_access_sync.py
@@ -198,10 +198,14 @@ def sync_project_access_once(config: V2Config | None = None) -> dict[str, Any]:
continue
if result.changed:
changed_project_ids.append(result.project_id)
+ wire_revision = intent.get("revision") if isinstance(intent, Mapping) else None
if (
not result.project_id
- or result.revision < 0
- or result.revision > project_access_service.MAX_CONTROL_PLANE_REVISION
+ or not isinstance(wire_revision, int)
+ or isinstance(wire_revision, bool)
+ or wire_revision < 0
+ or wire_revision > project_access_service.MAX_CONTROL_PLANE_REVISION
+ or wire_revision != result.revision
):
continue
try: