You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clarify or harden management API access when binding beyond loopback #24
When opencodex is bound beyond loopback, the management API and data-plane origin checks are weaker than the hostname: "0.0.0.0" setting suggests.
Current behavior:
hostname can be configured as 0.0.0.0, exposing the proxy on the LAN.
isLocalOrigin() returns true when the request has no Origin header.
Management API origin checks only run for POST, PUT, and DELETE; GET endpoints skip the check entirely.
Relevant code:
OcxConfig.hostname documents 0.0.0.0 as exposing all interfaces.
isLocalOrigin() accepts requests with no Origin.
handleManagementAPI() only gates mutating methods.
Why this matters
A browser-origin check is useful for blocking ordinary cross-origin browser requests, but it does not protect a proxy intentionally or accidentally bound to a LAN address from non-browser clients or same-network callers.
Read endpoints expose operational state such as provider list, masked config, model list, logs, sidecar settings, OAuth status, and selected subagent models. Mutating endpoints can add/remove providers, toggle settings, start OAuth flows, logout providers, or stop the proxy when the request does not include an Origin header.
Possible directions
Keep /api/* loopback-only even when the data plane is bound to 0.0.0.0.
Require a local management token for /api/* when binding to non-loopback hosts.
Split bind/listen config into data-plane host and management/API host.
At minimum, document that hostname: "0.0.0.0" exposes both the management API and the model proxy, not only /v1/responses.
I am opening this as an issue rather than a PR because the right fix affects local GUI, CLI live updates, remote dashboard usage, and backwards compatibility.
I re-checked this against current dev / PR #28 and it looks like the main hardening path may already be implemented there:
isApiAuthRequired(config) returns true for non-loopback hostnames.
assertServerAuthConfig(config) requires OPENCODEX_API_AUTH_TOKEN when binding beyond loopback.
requireApiAuth() is applied to both management/data-plane paths, including /v1/responses and websocket upgrade.
The existing local Origin checks still remain as an additional browser-origin guard.
So this may be mostly resolved by the dev work rather than needing a separate implementation issue.
Possible remaining follow-up, if you think it is worthwhile:
Document the non-loopback contract explicitly in README / config docs: hostname: "0.0.0.0" requires OPENCODEX_API_AUTH_TOKEN, and LAN clients must send x-opencodex-api-key.
Add a clearer startup/CLI hint when the proxy refuses to start because the token is missing.
Optionally surface the requirement in the GUI/settings page before users switch to a non-loopback bind.
Do you consider #24 closed once PR #28 lands, or would you like a small follow-up PR for docs/UX around this? If you agree with the follow-up, I can take it, unless you prefer to handle it directly while the current auth changes are fresh.
assertServerAuthConfig() requires OPENCODEX_API_AUTH_TOKEN when binding beyond loopback
hasValidApiAuth() checks x-opencodex-api-key header with constant-time comparison
Both management API (/api/*) and data-plane (/v1/responses) enforce the token
Proxy refuses to start without the token on non-loopback binding
Documentation (docs commit pending):
README.md / README.ko.md: new "Remote access" subsection under Configuration
docs-site configuration reference (EN + KO): hostname field added to config table, dedicated "Remote access" / "원격 접근" section with usage examples and security caution
Tests: tests/server-auth.test.ts covers loopback detection, token validation, and non-loopback enforcement.
Activity
0disoft commentedon Jun 25, 2026
I re-checked this against current
dev/ PR #28 and it looks like the main hardening path may already be implemented there:isApiAuthRequired(config)returns true for non-loopback hostnames.assertServerAuthConfig(config)requiresOPENCODEX_API_AUTH_TOKENwhen binding beyond loopback.requireApiAuth()is applied to both management/data-plane paths, including/v1/responsesand websocket upgrade.So this may be mostly resolved by the
devwork rather than needing a separate implementation issue.Possible remaining follow-up, if you think it is worthwhile:
hostname: "0.0.0.0"requiresOPENCODEX_API_AUTH_TOKEN, and LAN clients must sendx-opencodex-api-key.Do you consider #24 closed once PR #28 lands, or would you like a small follow-up PR for docs/UX around this? If you agree with the follow-up, I can take it, unless you prefer to handle it directly while the current auth changes are fresh.
lidge-jun commentedon Jun 25, 2026
Resolved. Implementation and documentation are both in place:
Implementation (merged via PR #28):
assertServerAuthConfig()requiresOPENCODEX_API_AUTH_TOKENwhen binding beyond loopbackhasValidApiAuth()checksx-opencodex-api-keyheader with constant-time comparison/api/*) and data-plane (/v1/responses) enforce the tokenDocumentation (docs commit pending):
hostnamefield added to config table, dedicated "Remote access" / "원격 접근" section with usage examples and security cautionTests:
tests/server-auth.test.tscovers loopback detection, token validation, and non-loopback enforcement.docs: document OPENCODEX_API_AUTH_TOKEN and config recovery behavior