Skip to content

fix(lint): address G114 gosec findings in ready, pprof, and health plugins#7798

Merged
thevilledev merged 1 commit intocoredns:masterfrom
syedazeez337:fix/gosec-g114-http-timeouts
Jan 1, 2026
Merged

fix(lint): address G114 gosec findings in ready, pprof, and health plugins#7798
thevilledev merged 1 commit intocoredns:masterfrom
syedazeez337:fix/gosec-g114-http-timeouts

Conversation

@syedazeez337
Copy link
Copy Markdown
Contributor

Replace http.Serve() with http.Server{} configured with timeouts to address G114 gosec findings (HTTP server without timeouts). This prevents potential slowloris attacks and resource exhaustion.

Changes:

  • Add ReadTimeout, WriteTimeout, IdleTimeout (5s each) to HTTP servers
  • Use srv.Shutdown(ctx) for graceful shutdown instead of ln.Close()
  • Follow existing pattern from plugin/metrics

Fixes part of #7793

…ugins

Replace http.Serve() with http.Server{} configured with timeouts to
address G114 gosec findings (HTTP server without timeouts). This
prevents potential slowloris attacks and resource exhaustion.

Changes:
- Add ReadTimeout, WriteTimeout, IdleTimeout (5s each) to HTTP servers
- Use srv.Shutdown(ctx) for graceful shutdown instead of ln.Close()
- Follow existing pattern from plugin/metrics

Fixes part of coredns#7793

Signed-off-by: Azeez Syed <syedazeez337@gmail.com>
Copy link
Copy Markdown
Collaborator

@thevilledev thevilledev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think following the approach from #7469 is fine. The timeout defaults are sensible but we can always parameterise them later if there's a need for it.

LGTM, thanks!

h.srv = &http.Server{
Handler: h.mux,
ReadTimeout: 5 * time.Second,
WriteTimeout: 5 * time.Second,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified that profiling with >5s of sampling works just fine. I guess pprof buffers the data internally and then does the write call. So all good.

@thevilledev thevilledev merged commit 6dca5b2 into coredns:master Jan 1, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants