fix: Use secure defaults for Pico channel setup and stop leaking the token in the URL#1563
Conversation
|
@alexhoshina Could you please review this PR? I'd appreciate any feedbacks. |
web/backend/api/pico.go
Outdated
| // local-dev scenarios (Vite on 5173, launcher on 18800) without opening the | ||
| // WebSocket to arbitrary cross-origin pages. | ||
| var defaultPicoOrigins = []string{ | ||
| "http://localhost:5173", |
There was a problem hiding this comment.
allow_origins should not be seeded with a fixed localhost port list here.
CheckOrigin does exact Origin matching in pkg/channels/pico/pico.go (line 69), while buildWsURL() intentionally returns the current request host in public/LAN launcher mode, for example ws://192.168.1.9:18790/pico/ws in web/backend/api/gateway_host_test.go (line 30).
After this change, /api/pico/setup writes only localhost/127.0.0.1 origins, so opening the launcher from http://192.168.1.9:18800 or any custom UI port will fail the WebSocket handshake even though setup reports success.
Could we derive the default allow_origins from the incoming request Origin (or the active launcher origin) instead of hard-coding 5173 and 18800? That would preserve the security improvement without breaking public/LAN or custom-port setups.
You can use picoclaw-launcher -public to test.
|
hi @bittoby, I'm not very familiar with this part of the code, so I've asked other maintainers to review it🙏 |
|
Ok. @alexhoshina If possible, could you review this as soon as possible? I can update and respond right away. So feel free to reach out any time. I will solve soon. |
@bittoby this #1563 (comment) |
Yes. I am fixing that problem now |
…der instead of hardcoding localhost ports
|
@wj-xiao Thanks for your feedback. Good points! I have fixed and added test code. It works well. please review again. Cc: @alexhoshina |
|
@alexhoshina @wj-xiao Could you please review once more? |
|
Thanks! |
|
@bittoby Good security hardening here. Switching the token from query string to WebSocket subprotocol header and locking down the CORS origins are both important fixes. Query string tokens leaking into logs and browser history is a real risk. We have a PicoClaw Dev Group on Discord where contributors connect and collaborate on the project. If you'd like to join, send an email to |
…token in the URL (sipeed#1563) * fix: Use secure defaults for Pico channel setup and stop leaking the token in the URL * fix: Derive default allow_origins from the setup request's Origin header instead of hardcoding localhost ports
…token in the URL (sipeed#1563) * fix: Use secure defaults for Pico channel setup and stop leaking the token in the URL * fix: Derive default allow_origins from the setup request's Origin header instead of hardcoding localhost ports
…token in the URL (sipeed#1563) * fix: Use secure defaults for Pico channel setup and stop leaking the token in the URL * fix: Derive default allow_origins from the setup request's Origin header instead of hardcoding localhost ports
📝 Description
Secure Pico channel setup defaults and stop leaking the token in the URL.
allow_token_queryon setup*origins🗣️ Type of Change
🤖 AI Code Generation
🔗 Related Issue
Fixes #1530
📚 Technical Context (Skip for Docs)
☑️ Checklist