diff --git a/openshift/patches/003-http2-cve.patch b/openshift/patches/003-http2-cve.patch new file mode 100644 index 0000000000..85d39e7aec --- /dev/null +++ b/openshift/patches/003-http2-cve.patch @@ -0,0 +1,44 @@ +diff --git a/vendor/knative.dev/pkg/webhook/webhook.go b/vendor/knative.dev/pkg/webhook/webhook.go +index 435dfe38..00fcd3c4 100644 +--- a/vendor/knative.dev/pkg/webhook/webhook.go ++++ b/vendor/knative.dev/pkg/webhook/webhook.go +@@ -63,6 +63,17 @@ type Options struct { + // GracePeriod is how long to wait after failing readiness probes + // before shutting down. + GracePeriod time.Duration ++ ++ // EnableHTTP2 enables HTTP2 for webhooks. ++ // Mitigate CVE-2023-44487 by disabling HTTP2 by default until the Go ++ // standard library and golang.org/x/net are fully fixed. ++ // Right now, it is possible for authenticated and unauthenticated users to ++ // hold open HTTP2 connections and consume huge amounts of memory. ++ // See: ++ // * https://github.com/kubernetes/kubernetes/pull/121120 ++ // * https://github.com/kubernetes/kubernetes/issues/121197 ++ // * https://github.com/golang/go/issues/63417#issuecomment-1758858612 ++ EnableHTTP2 bool + } + + // Operation is the verb being operated on +@@ -208,11 +219,18 @@ func (wh *Webhook) Run(stop <-chan struct{}) error { + QuietPeriod: wh.Options.GracePeriod, + } + ++ // If TLSNextProto is not nil, HTTP/2 support is not enabled automatically. ++ nextProto := map[string]func(*http.Server, *tls.Conn, http.Handler){} ++ if wh.Options.EnableHTTP2 { ++ nextProto = nil ++ } ++ + //nolint:gosec + server := &http.Server{ +- Handler: drainer, +- Addr: fmt.Sprint(":", wh.Options.Port), +- TLSConfig: wh.tlsConfig, ++ Handler: drainer, ++ Addr: fmt.Sprint(":", wh.Options.Port), ++ TLSConfig: wh.tlsConfig, ++ TLSNextProto: nextProto, + } + + eg, ctx := errgroup.WithContext(ctx) diff --git a/vendor/knative.dev/pkg/webhook/webhook.go b/vendor/knative.dev/pkg/webhook/webhook.go index 435dfe38aa..00fcd3c4ac 100644 --- a/vendor/knative.dev/pkg/webhook/webhook.go +++ b/vendor/knative.dev/pkg/webhook/webhook.go @@ -63,6 +63,17 @@ type Options struct { // GracePeriod is how long to wait after failing readiness probes // before shutting down. GracePeriod time.Duration + + // EnableHTTP2 enables HTTP2 for webhooks. + // Mitigate CVE-2023-44487 by disabling HTTP2 by default until the Go + // standard library and golang.org/x/net are fully fixed. + // Right now, it is possible for authenticated and unauthenticated users to + // hold open HTTP2 connections and consume huge amounts of memory. + // See: + // * https://github.com/kubernetes/kubernetes/pull/121120 + // * https://github.com/kubernetes/kubernetes/issues/121197 + // * https://github.com/golang/go/issues/63417#issuecomment-1758858612 + EnableHTTP2 bool } // Operation is the verb being operated on @@ -208,11 +219,18 @@ func (wh *Webhook) Run(stop <-chan struct{}) error { QuietPeriod: wh.Options.GracePeriod, } + // If TLSNextProto is not nil, HTTP/2 support is not enabled automatically. + nextProto := map[string]func(*http.Server, *tls.Conn, http.Handler){} + if wh.Options.EnableHTTP2 { + nextProto = nil + } + //nolint:gosec server := &http.Server{ - Handler: drainer, - Addr: fmt.Sprint(":", wh.Options.Port), - TLSConfig: wh.tlsConfig, + Handler: drainer, + Addr: fmt.Sprint(":", wh.Options.Port), + TLSConfig: wh.tlsConfig, + TLSNextProto: nextProto, } eg, ctx := errgroup.WithContext(ctx)