Skip to content

Commit

Permalink
chore: configure agent server to avoid slowloris attack (#2342)
Browse files Browse the repository at this point in the history
## Description

- included timeout to avoid slowloris attack - `gosec`
https://github.com/securego/gosec G112: Potential slowloris attack

## Related Issue

Fixes #
<!-- or -->
Relates to #

## Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [x] Other (security config, docs update, etc)

## Checklist before merging

- [x] Test, docs, adr added or updated as needed
- [x] [Contributor Guide
Steps](https://github.com/defenseunicorns/zarf/blob/main/CONTRIBUTING.md#developer-workflow)
followed

Signed-off-by: naveensrinivasan <172697+naveensrinivasan@users.noreply.github.com>
  • Loading branch information
naveensrinivasan committed Feb 29, 2024
1 parent 0ee871d commit 4d8b833
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/internal/agent/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package http
import (
"fmt"
"net/http"
"time"

"github.com/defenseunicorns/zarf/src/internal/agent/hooks"
"github.com/defenseunicorns/zarf/src/pkg/message"
Expand Down Expand Up @@ -34,8 +35,9 @@ func NewAdmissionServer(port string) *http.Server {
mux.Handle("/metrics", promhttp.Handler())

return &http.Server{
Addr: fmt.Sprintf(":%s", port),
Handler: mux,
Addr: fmt.Sprintf(":%s", port),
Handler: mux,
ReadHeaderTimeout: 5 * time.Second, // Set ReadHeaderTimeout to avoid Slowloris attacks
}
}

Expand All @@ -49,8 +51,9 @@ func NewProxyServer(port string) *http.Server {
mux.Handle("/metrics", promhttp.Handler())

return &http.Server{
Addr: fmt.Sprintf(":%s", port),
Handler: mux,
Addr: fmt.Sprintf(":%s", port),
Handler: mux,
ReadHeaderTimeout: 5 * time.Second, // Set ReadHeaderTimeout to avoid Slowloris attacks
}
}

Expand Down

0 comments on commit 4d8b833

Please sign in to comment.