Skip to content

fix: stop exposing WebSocket auth token to unauthenticated UI callers#25

Closed
pproenca wants to merge 1 commit intomasterfrom
codex/fix-ws-auth-token-exposure
Closed

fix: stop exposing WebSocket auth token to unauthenticated UI callers#25
pproenca wants to merge 1 commit intomasterfrom
codex/fix-ws-auth-token-exposure

Conversation

@pproenca
Copy link
Copy Markdown
Owner

@pproenca pproenca commented Apr 7, 2026

Motivation

  • The WS auth token was previously embedded in browser-facing URLs and logged, allowing token recovery via redirects or logs and enabling an easy auth bypass.
  • The intent is to keep the token secret while preserving existing RPC access for clients that rely on the token query parameter.

Description

  • Make format_ws_url return a token-less endpoint (ws://.../ws) and add format_ws_url_with_auth to build a tokenized URL when needed for state-file compatibility.
  • Stop embedding the token in the UI redirect: the root handler now sets an HttpOnly cookie and redirects to /ui and /ui also sets the same cookie so browser loads can authenticate without query secrets.
  • Accept authentication for /ws either via the original ?token= query (backwards compatibility) or via the new agent_tui_ws_token cookie, implemented with helper functions ws_auth_cookie and read_cookie_value.
  • Update state handling and unit tests to reflect tokenless public URLs and to test cookie parsing and new URL helpers.

Testing

  • Ran cd cli && cargo test -p agent-tui-app ws_server -- --nocapture and all relevant tests passed (9 tests, 0 failed).
  • Ran cd cli && cargo fmt --all to format code.

Codex Task

@pproenca pproenca closed this Apr 12, 2026
@pproenca pproenca deleted the codex/fix-ws-auth-token-exposure branch April 12, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant