Headline
CVE-2022-23509: Add HTTPS support to bucket server by makkes · Pull Request #3098 · weaveworks/weave-gitops
Weave GitOps is a simple open source developer platform for people who want cloud native applications, without needing Kubernetes expertise. GitOps run has a local S3 bucket which it uses for synchronizing files that are later applied against a Kubernetes cluster. The communication between GitOps Run and the local S3 bucket is not encrypted. This allows privileged users or process to tap the local traffic to gain information permitting access to the s3 bucket. From that point, it would be possible to alter the bucket content, resulting in changes in the Kubernetes cluster’s resources. There are no known workaround(s) for this vulnerability. This vulnerability has been fixed by commits ce2bbff and babd915. Users should upgrade to Weave GitOps version >= v0.12.0 released on 08/12/2022.
@@ -0,0 +1,115 @@ package http_test
import ( “context” “crypto/tls” “crypto/x509” “fmt” “io” “log” “math/rand” “net/http” “os” “testing”
. “github.com/onsi/gomega”
wegohttp “github.com/weaveworks/weave-gitops/pkg/http” )
func TestMultiServerStartReturnsImmediatelyWithClosedContext(t *testing.T) { g := NewGomegaWithT(t) srv := wegohttp.MultiServer{ CertFile: "testdata/localhost.crt", KeyFile: "testdata/localhost.key", Logger: log.Default(), } ctx, cancel := context.WithCancel(context.Background()) cancel() g.Expect(srv.Start(ctx, nil)).To(Succeed()) }
func TestMultiServerWithoutTLSConfigFailsToStart(t *testing.T) { g := NewGomegaWithT(t) srv := wegohttp.MultiServer{} ctx, cancel := context.WithCancel(context.Background()) cancel()
err := srv.Start(ctx, nil) g.Expect(err).To(HaveOccurred()) g.Expect(err.Error()).To(HavePrefix(“failed to create TLS listener”)) }
func TestMultiServerServesOverBothProtocols(t *testing.T) { g := NewGomegaWithT(t)
httpPort := rand.Intn(49151-1024) + 1024 httpsPort := rand.Intn(49151-1024) + 1024
for httpPort == httpsPort { httpsPort = rand.Intn(49151-1024) + 1024 }
srv := wegohttp.MultiServer{ HTTPPort: httpPort, HTTPSPort: httpsPort, CertFile: "testdata/localhost.crt", KeyFile: "testdata/localhost.key", Logger: log.Default(), } ctx, cancel := context.WithCancel(context.Background())
exitChan := make(chan struct{}) go func(exitChan chan<- struct{}) { hndlr := http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { fmt.Fprintf(rw, “success”) }) g.Expect(srv.Start(ctx, hndlr)).To(Succeed()) close(exitChan) }(exitChan)
// test HTTP
resp, err := http.Get(fmt.Sprintf("http://localhost:%d/", httpPort)) g.Expect(err).NotTo(HaveOccurred()) g.Expect(resp.StatusCode).To(Equal(http.StatusOK)) body, err := io.ReadAll(resp.Body) g.Expect(err).NotTo(HaveOccurred()) g.Expect(string(body)).To(Equal(“success”))
// test HTTPS
certBytes, err := os.ReadFile(“testdata/localhost.crt”) g.Expect(err).NotTo(HaveOccurred())
rootCAs := x509.NewCertPool() rootCAs.AppendCertsFromPEM(certBytes)
tr := &http.Transport{ TLSClientConfig: &tls.Config{ RootCAs: rootCAs, }, } c := http.Client{ Transport: tr, } resp, err = c.Get(fmt.Sprintf("https://localhost:%d/", httpsPort)) g.Expect(err).NotTo(HaveOccurred()) g.Expect(resp.StatusCode).To(Equal(http.StatusOK)) body, err = io.ReadAll(resp.Body) g.Expect(err).NotTo(HaveOccurred()) g.Expect(string(body)).To(Equal(“success”))
cancel() g.Eventually(exitChan, “3s”).Should(BeClosed())
// ensure both ports are freed up
_, err = c.Get(fmt.Sprintf("https://localhost:%d/", httpsPort)) g.Expect(err).To(HaveOccurred()) g.Expect(err.Error()).To(ContainSubstring(“connection refused”))
_, err = http.Get(fmt.Sprintf("http://localhost:%d/", httpPort)) g.Expect(err).To(HaveOccurred()) g.Expect(err.Error()).To(ContainSubstring(“connection refused”)) }
Related news
### Impact GitOps run has a local S3 bucket which it uses for synchronising files that are later applied against a Kubernetes cluster. The communication between GitOps Run and the local s3 bucket is not encrypted. This allows privileged users or process to tap the local traffic to gain information permitting access to the s3 bucket. From that point, it would be possible to alter the bucket content, resulting in changes in the Kubernetes cluster's resources(e.g. CVE-2022-23508). ### Patches This vulnerability has been fixed by commits [ce2bbff](https://github.com/weaveworks/weave-gitops/pull/3106/commits/ce2bbff0a3609c33396050ed544a5a21f8d0797f) and [babd915](https://github.com/weaveworks/weave-gitops/pull/3098/commits/babd91574b99b310b84aeec9f8f895bd18acb967). Users should upgrade to Weave GitOps version >= v0.12.0 released on 08/12/2022. ### Workarounds There is no workaround for this vulnerability. ### References Disclosed by Paulo Gomes, Senior Software Engineer, Weaveworks. #...