Skip to content

Commit

Permalink
webhook: Disable HTTP2 by default
Browse files Browse the repository at this point in the history
From docs: net/http/server.go

"[...] If TLSNextProto is not nil, HTTP/2 support
is not enabled automatically."
Server.TLSNextProto

Signed-off-by: Andrea Panattoni <[email protected]>
  • Loading branch information
zeeke authored and cgoncalves committed Oct 20, 2023
1 parent bf595e4 commit 2eefedb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cmd/webhook/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ import (
)

var (
certFile string
keyFile string
port int
certFile string
keyFile string
port int
enableHTTP2 bool
)

var (
Expand Down Expand Up @@ -48,6 +49,7 @@ func init() {
"File containing the default x509 private key matching --tls-cert-file.")
startCmd.Flags().IntVar(&port, "port", 443,
"Secure port that the webhook listens on")
startCmd.Flags().BoolVar(&enableHTTP2, "enable-http2", false, "If HTTP/2 should be enabled for the metrics and webhook servers.")
}

// serve handles the http portion of a request prior to handing to an admit
Expand Down Expand Up @@ -152,6 +154,11 @@ func runStartCmd(cmd *cobra.Command, args []string) {
TLSConfig: &tls.Config{
GetCertificate: keyPair.GetCertificateFunc(),
},
// CVE-2023-39325 https://github.com/golang/go/issues/63417
TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, http.Handler)),
}
if enableHTTP2 {
server.TLSNextProto = nil
}
err := server.ListenAndServeTLS("", "")
if err != nil {
Expand Down

0 comments on commit 2eefedb

Please sign in to comment.