fix: code review (WS race, CSWSH, PBKDF2, base64 chunking, timeouts, Docker bumps) #4
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nm/magic-wormhole-web!4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/code-review"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Addresses findings from code review against Context7-verified docs:
- WS write race: wrap each subscriber connection in subscriberConn{conn,mu} so notifySubscribers and the WS handler serialize WriteMessage calls. gorilla/websocket allows only one concurrent writer per conn. - CSWSH: CheckOrigin now requires the request Origin host to match the server Host header (browser case); empty Origin (non-browser clients) is still allowed. - HTTP slowloris: set ReadHeaderTimeout=15s, IdleTimeout=120s, MaxHeaderBytes=1 MiB on http.Server. ReadTimeout/WriteTimeout left off intentionally so they don't kill long uploads or live WebSockets. - Progress flood: progressReader notifies callback at most every 250 ms (and on EOF/err) instead of every Read(), preventing the WS broadcast loop from being saturated by chunky reads. - crypto.ts PBKDF2: 100k -> 600k iterations per OWASP Password Storage Cheat Sheet (PBKDF2-HMAC-SHA256, 2024+). - crypto.ts base64: replace String.fromCharCode(...arr) and Uint8Array.from paths with chunked bytesToBase64/base64ToBytes helpers. Spread/apply fail on arrays past the engine argument-count limit (~16k-65k); large ciphertexts crashed silently. Regression test added (200 KiB payload). - Dockerfile / go.mod / CI Go install: Go 1.21 -> 1.24, alpine 3.19 -> 3.21 (both EOL); add HEALTHCHECK using wget against the embedded server. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>