fix(serve): stop serving WS token over HTTP and warn on non-loopback bind (H9)#56
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR closes H9 from the security roadmap.
Problem
odek servepreviously embedded the per-instance WebSocket token in everyGET /response (HTML meta tag + HttpOnly cookie). BecauseGET /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:
http://<addr>/?token=<token>.handleStaticonly injects the cookie and meta tag when the request URL contains the correct?token=parameter.GET /still serves the UI, but with an empty token, so it cannot connect.X-Odek-Ws-Tokenheader or theodek.<token>WebSocket subprotocol.Tests & docs
TestServe_CSRF_TokenRequiredto verify the token is not leaked on a plainGET /and is delivered with?token=.TestIsLoopbackAddr.AGENTS.mdanddocs/SECURITY.md.