diff --git a/gateway/platforms/api_server.py b/gateway/platforms/api_server.py index 3fa4f3680fa..759ec188d61 100644 --- a/gateway/platforms/api_server.py +++ b/gateway/platforms/api_server.py @@ -363,7 +363,8 @@ class APIServerAdapter(BasePlatformAdapter): Validate Bearer token from Authorization header. Returns None if auth is OK, or a 401 web.Response on failure. - If no API key is configured, all requests are allowed. + If no API key is configured, all requests are allowed (only when API + server is local) """ if not self._api_key: return None # No key configured — allow all (local-only use) diff --git a/hermes_cli/config.py b/hermes_cli/config.py index a981b1bbbf1..ebff61fa0fd 100644 --- a/hermes_cli/config.py +++ b/hermes_cli/config.py @@ -1163,8 +1163,8 @@ OPTIONAL_ENV_VARS = { "advanced": True, }, "API_SERVER_KEY": { - "description": "Bearer token for API server authentication. If empty, all requests are allowed (local use only).", - "prompt": "API server auth key (optional)", + "description": "Bearer token for API server authentication. Required for non-loopback binding; server refuses to start without it. On loopback (127.0.0.1), all requests are allowed if empty.", + "prompt": "API server auth key (required for network access)", "url": None, "password": True, "category": "messaging", @@ -1179,7 +1179,7 @@ OPTIONAL_ENV_VARS = { "advanced": True, }, "API_SERVER_HOST": { - "description": "Host/bind address for the API server (default: 127.0.0.1). Use 0.0.0.0 for network access — requires API_SERVER_KEY for security.", + "description": "Host/bind address for the API server (default: 127.0.0.1). Use 0.0.0.0 for network access — server refuses to start without API_SERVER_KEY.", "prompt": "API server host", "url": None, "password": False, diff --git a/website/docs/reference/environment-variables.md b/website/docs/reference/environment-variables.md index 7c14d9f3da4..179e777bf60 100644 --- a/website/docs/reference/environment-variables.md +++ b/website/docs/reference/environment-variables.md @@ -257,10 +257,10 @@ For cloud sandbox backends, persistence is filesystem-oriented. `TERMINAL_LIFETI | `WEBHOOK_PORT` | HTTP server port for receiving webhooks (default: `8644`) | | `WEBHOOK_SECRET` | Global HMAC secret for webhook signature validation (used as fallback when routes don't specify their own) | | `API_SERVER_ENABLED` | Enable the OpenAI-compatible API server (`true`/`false`). Runs alongside other platforms. | -| `API_SERVER_KEY` | Bearer token for API server authentication. Strongly recommended; required for any network-accessible deployment. | +| `API_SERVER_KEY` | Bearer token for API server authentication. Enforced for non-loopback binding. | | `API_SERVER_CORS_ORIGINS` | Comma-separated browser origins allowed to call the API server directly (for example `http://localhost:3000,http://127.0.0.1:3000`). Default: disabled. | | `API_SERVER_PORT` | Port for the API server (default: `8642`) | -| `API_SERVER_HOST` | Host/bind address for the API server (default: `127.0.0.1`). Use `0.0.0.0` for network access only with `API_SERVER_KEY` and a narrow `API_SERVER_CORS_ORIGINS` allowlist. | +| `API_SERVER_HOST` | Host/bind address for the API server (default: `127.0.0.1`). Use `0.0.0.0` for network access — requires `API_SERVER_KEY` and a narrow `API_SERVER_CORS_ORIGINS` allowlist. | | `MESSAGING_CWD` | Working directory for terminal commands in messaging mode (default: `~`) | | `GATEWAY_ALLOWED_USERS` | Comma-separated user IDs allowed across all platforms | | `GATEWAY_ALLOW_ALL_USERS` | Allow all users without allowlists (`true`/`false`, default: `false`) | diff --git a/website/docs/user-guide/features/api-server.md b/website/docs/user-guide/features/api-server.md index 71732285e75..bfed8c94f19 100644 --- a/website/docs/user-guide/features/api-server.md +++ b/website/docs/user-guide/features/api-server.md @@ -177,7 +177,7 @@ Authorization: Bearer *** Configure the key via `API_SERVER_KEY` env var. If you need a browser to call Hermes directly, also set `API_SERVER_CORS_ORIGINS` to an explicit allowlist. :::warning Security -The API server gives full access to hermes-agent's toolset, **including terminal commands**. If you change the bind address to `0.0.0.0` (network-accessible), **always set `API_SERVER_KEY`** and keep `API_SERVER_CORS_ORIGINS` narrow — without that, remote callers may be able to execute arbitrary commands on your machine. +The API server gives full access to hermes-agent's toolset, **including terminal commands**. When binding to a non-loopback address like `0.0.0.0`, `API_SERVER_KEY` is **required**. Also keep `API_SERVER_CORS_ORIGINS` narrow to control browser access. The default bind address (`127.0.0.1`) is for local-only use. Browser access is disabled by default; enable it only for explicit trusted origins. :::