Skip to content

Commit 6d526e2

Browse files
committed
disable http2 for metrics and webhooks by default
It appears that mitigating the recent http2 vulnerabilities (see CVE-2023-44487 and CVE-2023-39325) requires [more than just a library update to golang.org/x/net][1]. Until better mitigations have been developed, disable http2 in both the metrics and webhooks servers. [1]: kubernetes/kubernetes#121197 Signed-off-by: Andy Sadler <[email protected]>
1 parent dadc923 commit 6d526e2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

main.go

+15
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package main
1818

1919
import (
20+
"crypto/tls"
2021
"flag"
2122
"os"
2223
"time"
@@ -64,13 +65,15 @@ func main() {
6465
var enableLeaderElection bool
6566
var probeAddr string
6667
var migrateFromVMware bool
68+
var enableHTTP2 bool
6769
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
6870
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
6971
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
7072
"Enable leader election for controller manager. "+
7173
"Enabling this will ensure there is only one active controller manager.")
7274
flag.BoolVar(&migrateFromVMware, "migrate-from-vmware", false,
7375
"Enable migration from the VMware implementation.")
76+
flag.BoolVar(&enableHTTP2, "enable-http2", false, "Enable HTTP2 for the metrics and webhook servers")
7477
opts := zap.Options{
7578
Development: true,
7679
}
@@ -79,14 +82,26 @@ func main() {
7982

8083
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
8184

85+
disableHTTP2 := func(t *tls.Config) {
86+
if enableHTTP2 {
87+
t.NextProtos = []string{"http/1.1"}
88+
}
89+
}
90+
8291
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
8392
Scheme: scheme,
8493
Metrics: server.Options{
8594
BindAddress: metricsAddr,
95+
TLSOpts: []func(*tls.Config){
96+
disableHTTP2,
97+
},
8698
},
8799
WebhookServer: &webhook.DefaultServer{
88100
Options: webhook.Options{
89101
Port: 9443,
102+
TLSOpts: []func(*tls.Config){
103+
disableHTTP2,
104+
},
90105
},
91106
},
92107
Cache: cache.Options{

0 commit comments

Comments
 (0)