Self-hosted homelab infrastructure visualizer — interactive network diagram with live status monitoring
TypeScript diagramhomelabhomelab-infrastructure-observabilitynetworkproxmox-veself-hostedzigbeezwavezwave-js
fix(proxmox): bind the env token to host and port, reject only a TLS downgrade
Pouzorabdfe7af001b
diff --git a/backend/app/api/routes/proxmox.py b/backend/app/api/routes/proxmox.pyindex 7022a9d..e2dacc6 100644--- a/backend/app/api/routes/proxmox.py+++ b/backend/app/api/routes/proxmox.py@@ -4,7 +4,9 @@ Fetches hosts/VMs/LXC from the Proxmox REST API and upserts them into thepending inventory (same review→approve flow as scans and mesh imports).Credentials: the API token comes from the request body when provided, else-falls back to the server-configured env token (``settings.proxmox_token_*``).+falls back to the server-configured env token (``settings.proxmox_token_*``) —+only for the configured host and port, and never with TLS verification off+when the server keeps it on.The token is never persisted by the app and never returned by any endpoint."""@@ -76,12 +78,19 @@ def _resolve_credentials(payload: ProxmoxConnectionRequest) -> tuple[str, str]:not configured_hostor request_host != configured_hostor payload.port != settings.proxmox_port- or payload.verify_tls != settings.proxmox_verify_tls):raise HTTPException(status_code=400,detail="Custom Proxmox hosts require an explicit API token",)+ # Verifying more strictly than configured is fine (the modal's checkbox+ # defaults to on, over a self-signed env setup); turning off verification+ # the server keeps on would hand the env token to an unverified peer.+ if settings.proxmox_verify_tls and not payload.verify_tls:+ raise HTTPException(+ status_code=400,+ detail="The server-configured Proxmox token requires TLS verification",+ )if not settings.proxmox_token_id or not settings.proxmox_token_secret:raise HTTPException(status_code=400,diff --git a/backend/tests/test_proxmox_router.py b/backend/tests/test_proxmox_router.pyindex 3b405c1..e7af63a 100644--- a/backend/tests/test_proxmox_router.py+++ b/backend/tests/test_proxmox_router.py@@ -738,7 +738,6 @@ async def test_env_token_used_for_configured_host(client: AsyncClient, headers:@pytest.mark.parametrize("override", [{"host": "attacker.example"},{"port": 443},- {"verify_tls": False},])async def test_env_token_never_sent_to_another_endpoint(client: AsyncClient, headers: dict, override: dict@@ -753,6 +752,44 @@ async def test_env_token_never_sent_to_another_endpoint(probe.assert_not_called()[email protected]("_env_proxmox")+async def test_env_token_refused_when_request_turns_tls_off(+ client: AsyncClient, headers: dict+) -> None:+ """The server verifies TLS; a request turning it off never gets the env token."""+ probe = AsyncMock(return_value=(True, "ok"))+ with patch("app.api.routes.proxmox.test_proxmox_connection", new=probe):+ res = await client.post(+ "/api/v1/proxmox/test-connection",+ json={"host": "pve.lan", "port": 8006, "verify_tls": False},+ headers=headers,+ )+ assert res.status_code == 400+ assert res.json()["detail"] == "The server-configured Proxmox token requires TLS verification"+ probe.assert_not_called()++[email protected]("_env_proxmox")+async def test_env_token_used_when_request_verifies_more_strictly(+ client: AsyncClient, headers: dict+) -> None:+ """Regression: a self-signed env setup (verify off) broke the import modal,+ whose TLS checkbox defaults to on — a stricter request is always safe."""+ settings.proxmox_verify_tls = False+ probe = AsyncMock(return_value=(True, "ok"))+ with patch("app.api.routes.proxmox.test_proxmox_connection", new=probe):+ res = await client.post(+ "/api/v1/proxmox/test-connection",+ json={"host": "pve.lan", "port": 8006, "verify_tls": True},+ headers=headers,+ )+ assert res.status_code == 200, res.text+ assert probe.call_args.kwargs["token_secret"] == "env-secret"+ assert probe.call_args.kwargs["verify_tls"] is True++@pytest.mark.asyncio@pytest.mark.usefixtures("_env_proxmox")async def test_body_token_allowed_for_any_host(client: AsyncClient, headers: dict) -> None: