Harden desktop gateway exposure#96
Merged
Merged
Conversation
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.
Motivation
0.0.0.0and can start it automatically, enabling unauthenticated access on reachable networks. This change prevents accidental LAN exposure from the one-click desktop flow.Description
desktop/src/renderer/src/lib/install.tsto bind generated gateway configs to127.0.0.1and to automatically generate a dashboard token when the webapp is enabled but no token was provided, preserving the existing sentinel for previously stored secrets. (dashboardTokenfallback +host: "127.0.0.1").0.0.0.0to127.0.0.1insrc/octopal/infrastructure/config/models.pyandsrc/octopal/infrastructure/config/settings.pyto reduce insecure defaults.src/octopal/gateway/ws.pyto add_is_local_ws_client,_provided_ws_token, and_reject_wshelpers; reject non-local clients when no Tailscale allowlist is available; require the configured dashboard token for WS connections when set and close unauthorized sockets with a policy violation.tests/test_gateway_ws_resolution.pywith coverage for the local-host helper and an explicit case asserting WebSocket token requirement whendashboard_tokenis configured.Testing
uv run blackand lint checks withuv run ruffon modified files; both checks passed.uv run python -m py_compilefor changed Python modules; compilation succeeded.npm run typecheckandnpm run buildindesktop/; both succeeded.uv run python -m pytest tests/test_gateway_ws_resolution.py tests/test_dashboard_v2_api.py, but test collection could not complete in this environment because pytest/dev dependencies were not available in the local venv (network/download error for dev packages); unit test file updates were added and should pass in CI where test dependencies are installed.Codex Task