Skip to content

fix(serve): stop serving WS token over HTTP and warn on non-loopback bind (H9)#56

Merged
jkyberneees merged 1 commit into
mainfrom
fix/h9-serve-token-disclosure
Jul 18, 2026
Merged

fix(serve): stop serving WS token over HTTP and warn on non-loopback bind (H9)#56
jkyberneees merged 1 commit into
mainfrom
fix/h9-serve-token-disclosure

Conversation

@jkyberneees

Copy link
Copy Markdown
Contributor

This PR closes H9 from the security roadmap.

Problem

odek serve previously embedded the per-instance WebSocket token in every GET / response (HTML meta tag + HttpOnly cookie). Because GET / was unauthenticated, any network attacker who could reach the port could fetch the token, upgrade to /ws, and drive the agent with the operator's model, tools, and API key.

Fix

The token is now treated like a Jupyter notebook token:

  • On startup, the console prints the token and a URL of the form http://<addr>/?token=<token>.
  • handleStatic only injects the cookie and meta tag when the request URL contains the correct ?token= parameter.
  • A plain GET / still serves the UI, but with an empty token, so it cannot connect.
  • Non-browser clients can continue to use the X-Odek-Ws-Token header or the odek.<token> WebSocket subprotocol.
  • A prominent warning is printed when the server is bound to a non-loopback address.

Tests & docs

  • Updated TestServe_CSRF_TokenRequired to verify the token is not leaked on a plain GET / and is delivered with ?token=.
  • Added TestIsLoopbackAddr.
  • Updated AGENTS.md and docs/SECURITY.md.

…bind (H9)

- The per-instance WebSocket token is now printed to the console only, like a Jupyter token.

- handleStatic only injects the token cookie/meta tag when the request includes ?token=<token>.

- A plain GET / returns the UI with an empty token, so unauthenticated visitors cannot retrieve the credential.

- A loud warning is printed when the bind address is not loopback.

- Update tests, AGENTS.md, and docs/SECURITY.md.
@jkyberneees
jkyberneees merged commit fbb9ced into main Jul 18, 2026
6 of 7 checks passed
@jkyberneees
jkyberneees deleted the fix/h9-serve-token-disclosure branch July 18, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant