Commit 0284a5b
committed
fix: replace http.DefaultServeMux fallback handlers with safe defaults
The HTTP server uses http.DefaultServeMux as the fallback handler
for unmatched routes and disallowed methods. Since DefaultServeMux
is a global shared instance that may have handlers registered by
init() functions (e.g. net/http/pprof), this can unintentionally
expose debug endpoints like /debug/pprof/ to the network.
Replace with:
- http.NotFoundHandler() for NotFoundHandler (returns 404)
- A simple 405 handler for MethodNotAllowedHandler
Users who need the previous behavior can still explicitly set
http.DefaultServeMux using the existing NotFoundHandler() and
MethodNotAllowedHandler() server options.
Fixes go-kratos#38101 parent f149714 commit 0284a5b
1 file changed
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | | - | |
193 | | - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
194 | 196 | | |
195 | 197 | | |
196 | 198 | | |
| |||
0 commit comments