fix(web): add missing returns after http.Error in handlers - #3455
fix(web): add missing returns after http.Error in handlers#3455ndf14685 wants to merge 1 commit into
Conversation
Five handlers wrote an error response but continued executing: - handleService: an invalid JSON body returned 400 but still invoked service.CallService with a zero-value WebCallType - handleService: a response-marshal failure still wrote headers/body on top of the 500 - handleWaveFile: an invalid offset returned 400 but kept serving the file with offset=0 - handleWaveFile: a fileinfo-marshal failure still streamed the file data after the 500 - handleStreamFile: an ExpandHomeDir error returned 400 but still called http.ServeFile with the unexpanded path Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NctL6NKspWCzRxHJDwBGMk
|
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
WalkthroughThe web handlers now terminate immediately after error responses. Estimated code review effort: 1 (Trivial) | ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
wavetermdev#3455) Cinco handlers seguían ejecutando tras escribir el error HTTP; documentado en SECURITY.md junto al triage D-019. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NctL6NKspWCzRxHJDwBGMk
Incluye el fix de seguridad de pkg/web (returns faltantes tras http.Error, PR upstream wavetermdev#3455) y el triage CodeQL documentado (D-019). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NctL6NKspWCzRxHJDwBGMk
Summary
Five HTTP handlers in
pkg/web/web.gowrite an error response withhttp.Error(...)but are missing thereturnafterwards, so the handler keeps executing on the error path:handleServiceservice.CallServicewith a zero-valueWebCallTypehandleServicehandleWaveFileoffsetparam (400)offset=0handleWaveFilehandleStreamFileExpandHomeDirerror (400)http.ServeFilewith the unexpanded pathThe
handleServicecase is the most relevant one: a malformed request body is rejected with 400 but the service call is executed anyway with empty data.The fix is the same one-liner in each spot:
returnafterhttp.Error. No behavior change on success paths.Found while triaging CodeQL alerts on a fork; these were flagged around the
go/stack-trace-exposure/go/path-injectionsites but the underlying real bug is the missing early return.Test plan
go vet ./pkg/web/andgo build ./pkg/web/pass.http.Error(single response per request); success paths untouched.🤖 Generated with Claude Code
https://claude.ai/code/session_01NctL6NKspWCzRxHJDwBGMk