!47 Fix multi CVEs
From: @jackchan8 Reviewed-by: @jing-rui Signed-off-by: @jing-rui
This commit is contained in:
commit
094284d05e
375
0046-release-branch.go1.15-net-verify-results-from-Lookup.patch
Normal file
375
0046-release-branch.go1.15-net-verify-results-from-Lookup.patch
Normal file
@ -0,0 +1,375 @@
|
||||
From 31d60cda1f58b7558fc5725d2b9e4531655d980e Mon Sep 17 00:00:00 2001
|
||||
From: Roland Shoemaker <roland@golang.org>
|
||||
Date: Thu, 27 May 2021 10:40:06 -0700
|
||||
Subject: [PATCH] [release-branch.go1.15] net: verify results from Lookup* are
|
||||
valid domain names
|
||||
|
||||
For the methods LookupCNAME, LookupSRV, LookupMX, LookupNS, and
|
||||
LookupAddr check that the returned domain names are in fact valid DNS
|
||||
names using the existing isDomainName function.
|
||||
|
||||
Thanks to Philipp Jeitner and Haya Shulman from Fraunhofer SIT for
|
||||
reporting this issue.
|
||||
|
||||
Updates #46241
|
||||
Fixes #46356
|
||||
Fixes CVE-2021-33195
|
||||
|
||||
Conflict:NA
|
||||
Reference:https://github.com/golang/go/commit/31d60cda1f58b7558fc5725d2b9e4531655d980e
|
||||
|
||||
Change-Id: I47a4f58c031cb752f732e88bbdae7f819f0af4f3
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/323131
|
||||
Trust: Roland Shoemaker <roland@golang.org>
|
||||
Run-TryBot: Roland Shoemaker <roland@golang.org>
|
||||
TryBot-Result: Go Bot <gobot@golang.org>
|
||||
Reviewed-by: Filippo Valsorda <filippo@golang.org>
|
||||
Reviewed-by: Katie Hockman <katie@golang.org>
|
||||
(cherry picked from commit cdcd02842da7c004efd023881e3719105209c908)
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/323269
|
||||
---
|
||||
src/net/dnsclient_unix_test.go | 157 +++++++++++++++++++++++++++++++++
|
||||
src/net/lookup.go | 111 ++++++++++++++++++++---
|
||||
2 files changed, 255 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/src/net/dnsclient_unix_test.go b/src/net/dnsclient_unix_test.go
|
||||
index 06553636ee..819f20b887 100644
|
||||
--- a/src/net/dnsclient_unix_test.go
|
||||
+++ b/src/net/dnsclient_unix_test.go
|
||||
@@ -1799,3 +1799,160 @@ func TestPTRandNonPTR(t *testing.T) {
|
||||
t.Errorf("names = %q; want %q", names, want)
|
||||
}
|
||||
}
|
||||
+
|
||||
+func TestCVE202133195(t *testing.T) {
|
||||
+ fake := fakeDNSServer{
|
||||
+ rh: func(n, _ string, q dnsmessage.Message, _ time.Time) (dnsmessage.Message, error) {
|
||||
+ r := dnsmessage.Message{
|
||||
+ Header: dnsmessage.Header{
|
||||
+ ID: q.Header.ID,
|
||||
+ Response: true,
|
||||
+ RCode: dnsmessage.RCodeSuccess,
|
||||
+ RecursionAvailable: true,
|
||||
+ },
|
||||
+ Questions: q.Questions,
|
||||
+ }
|
||||
+ switch q.Questions[0].Type {
|
||||
+ case dnsmessage.TypeCNAME:
|
||||
+ r.Answers = []dnsmessage.Resource{}
|
||||
+ case dnsmessage.TypeA: // CNAME lookup uses a A/AAAA as a proxy
|
||||
+ r.Answers = append(r.Answers,
|
||||
+ dnsmessage.Resource{
|
||||
+ Header: dnsmessage.ResourceHeader{
|
||||
+ Name: dnsmessage.MustNewName("<html>.golang.org."),
|
||||
+ Type: dnsmessage.TypeA,
|
||||
+ Class: dnsmessage.ClassINET,
|
||||
+ Length: 4,
|
||||
+ },
|
||||
+ Body: &dnsmessage.AResource{
|
||||
+ A: TestAddr,
|
||||
+ },
|
||||
+ },
|
||||
+ )
|
||||
+ case dnsmessage.TypeSRV:
|
||||
+ n := q.Questions[0].Name
|
||||
+ if n.String() == "_hdr._tcp.golang.org." {
|
||||
+ n = dnsmessage.MustNewName("<html>.golang.org.")
|
||||
+ }
|
||||
+ r.Answers = append(r.Answers,
|
||||
+ dnsmessage.Resource{
|
||||
+ Header: dnsmessage.ResourceHeader{
|
||||
+ Name: n,
|
||||
+ Type: dnsmessage.TypeSRV,
|
||||
+ Class: dnsmessage.ClassINET,
|
||||
+ Length: 4,
|
||||
+ },
|
||||
+ Body: &dnsmessage.SRVResource{
|
||||
+ Target: dnsmessage.MustNewName("<html>.golang.org."),
|
||||
+ },
|
||||
+ },
|
||||
+ )
|
||||
+ case dnsmessage.TypeMX:
|
||||
+ r.Answers = append(r.Answers,
|
||||
+ dnsmessage.Resource{
|
||||
+ Header: dnsmessage.ResourceHeader{
|
||||
+ Name: dnsmessage.MustNewName("<html>.golang.org."),
|
||||
+ Type: dnsmessage.TypeMX,
|
||||
+ Class: dnsmessage.ClassINET,
|
||||
+ Length: 4,
|
||||
+ },
|
||||
+ Body: &dnsmessage.MXResource{
|
||||
+ MX: dnsmessage.MustNewName("<html>.golang.org."),
|
||||
+ },
|
||||
+ },
|
||||
+ )
|
||||
+ case dnsmessage.TypeNS:
|
||||
+ r.Answers = append(r.Answers,
|
||||
+ dnsmessage.Resource{
|
||||
+ Header: dnsmessage.ResourceHeader{
|
||||
+ Name: dnsmessage.MustNewName("<html>.golang.org."),
|
||||
+ Type: dnsmessage.TypeNS,
|
||||
+ Class: dnsmessage.ClassINET,
|
||||
+ Length: 4,
|
||||
+ },
|
||||
+ Body: &dnsmessage.NSResource{
|
||||
+ NS: dnsmessage.MustNewName("<html>.golang.org."),
|
||||
+ },
|
||||
+ },
|
||||
+ )
|
||||
+ case dnsmessage.TypePTR:
|
||||
+ r.Answers = append(r.Answers,
|
||||
+ dnsmessage.Resource{
|
||||
+ Header: dnsmessage.ResourceHeader{
|
||||
+ Name: dnsmessage.MustNewName("<html>.golang.org."),
|
||||
+ Type: dnsmessage.TypePTR,
|
||||
+ Class: dnsmessage.ClassINET,
|
||||
+ Length: 4,
|
||||
+ },
|
||||
+ Body: &dnsmessage.PTRResource{
|
||||
+ PTR: dnsmessage.MustNewName("<html>.golang.org."),
|
||||
+ },
|
||||
+ },
|
||||
+ )
|
||||
+ }
|
||||
+ return r, nil
|
||||
+ },
|
||||
+ }
|
||||
+
|
||||
+ r := Resolver{PreferGo: true, Dial: fake.DialContext}
|
||||
+ // Change the default resolver to match our manipulated resolver
|
||||
+ originalDefault := DefaultResolver
|
||||
+ DefaultResolver = &r
|
||||
+ defer func() {
|
||||
+ DefaultResolver = originalDefault
|
||||
+ }()
|
||||
+
|
||||
+ _, err := r.LookupCNAME(context.Background(), "golang.org")
|
||||
+ if expected := "lookup golang.org: CNAME target is invalid"; err == nil || err.Error() != expected {
|
||||
+ t.Errorf("Resolver.LookupCNAME returned unexpected error, got %q, want %q", err.Error(), expected)
|
||||
+ }
|
||||
+ _, err = LookupCNAME("golang.org")
|
||||
+ if expected := "lookup golang.org: CNAME target is invalid"; err == nil || err.Error() != expected {
|
||||
+ t.Errorf("LookupCNAME returned unexpected error, got %q, want %q", err.Error(), expected)
|
||||
+ }
|
||||
+
|
||||
+ _, _, err = r.LookupSRV(context.Background(), "target", "tcp", "golang.org")
|
||||
+ if expected := "lookup golang.org: SRV target is invalid"; err == nil || err.Error() != expected {
|
||||
+ t.Errorf("Resolver.LookupSRV returned unexpected error, got %q, want %q", err.Error(), expected)
|
||||
+ }
|
||||
+ _, _, err = LookupSRV("target", "tcp", "golang.org")
|
||||
+ if expected := "lookup golang.org: SRV target is invalid"; err == nil || err.Error() != expected {
|
||||
+ t.Errorf("LookupSRV returned unexpected error, got %q, want %q", err.Error(), expected)
|
||||
+ }
|
||||
+
|
||||
+ _, _, err = r.LookupSRV(context.Background(), "hdr", "tcp", "golang.org")
|
||||
+ if expected := "lookup golang.org: SRV header name is invalid"; err == nil || err.Error() != expected {
|
||||
+ t.Errorf("Resolver.LookupSRV returned unexpected error, got %q, want %q", err.Error(), expected)
|
||||
+ }
|
||||
+ _, _, err = LookupSRV("hdr", "tcp", "golang.org")
|
||||
+ if expected := "lookup golang.org: SRV header name is invalid"; err == nil || err.Error() != expected {
|
||||
+ t.Errorf("LookupSRV returned unexpected error, got %q, want %q", err.Error(), expected)
|
||||
+ }
|
||||
+
|
||||
+ _, err = r.LookupMX(context.Background(), "golang.org")
|
||||
+ if expected := "lookup golang.org: MX target is invalid"; err == nil || err.Error() != expected {
|
||||
+ t.Errorf("Resolver.LookupMX returned unexpected error, got %q, want %q", err.Error(), expected)
|
||||
+ }
|
||||
+ _, err = LookupMX("golang.org")
|
||||
+ if expected := "lookup golang.org: MX target is invalid"; err == nil || err.Error() != expected {
|
||||
+ t.Errorf("LookupMX returned unexpected error, got %q, want %q", err.Error(), expected)
|
||||
+ }
|
||||
+
|
||||
+ _, err = r.LookupNS(context.Background(), "golang.org")
|
||||
+ if expected := "lookup golang.org: NS target is invalid"; err == nil || err.Error() != expected {
|
||||
+ t.Errorf("Resolver.LookupNS returned unexpected error, got %q, want %q", err.Error(), expected)
|
||||
+ }
|
||||
+ _, err = LookupNS("golang.org")
|
||||
+ if expected := "lookup golang.org: NS target is invalid"; err == nil || err.Error() != expected {
|
||||
+ t.Errorf("LookupNS returned unexpected error, got %q, want %q", err.Error(), expected)
|
||||
+ }
|
||||
+
|
||||
+ _, err = r.LookupAddr(context.Background(), "1.2.3.4")
|
||||
+ if expected := "lookup 1.2.3.4: PTR target is invalid"; err == nil || err.Error() != expected {
|
||||
+ t.Errorf("Resolver.LookupAddr returned unexpected error, got %q, want %q", err.Error(), expected)
|
||||
+ }
|
||||
+ _, err = LookupAddr("1.2.3.4")
|
||||
+ if expected := "lookup 1.2.3.4: PTR target is invalid"; err == nil || err.Error() != expected {
|
||||
+ t.Errorf("LookupAddr returned unexpected error, got %q, want %q", err.Error(), expected)
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/net/lookup.go b/src/net/lookup.go
|
||||
index 5f7119872a..0660268249 100644
|
||||
--- a/src/net/lookup.go
|
||||
+++ b/src/net/lookup.go
|
||||
@@ -389,8 +389,11 @@ func (r *Resolver) LookupPort(ctx context.Context, network, service string) (por
|
||||
// LookupCNAME does not return an error if host does not
|
||||
// contain DNS "CNAME" records, as long as host resolves to
|
||||
// address records.
|
||||
+//
|
||||
+// The returned canonical name is validated to be a properly
|
||||
+// formatted presentation-format domain name.
|
||||
func LookupCNAME(host string) (cname string, err error) {
|
||||
- return DefaultResolver.lookupCNAME(context.Background(), host)
|
||||
+ return DefaultResolver.LookupCNAME(context.Background(), host)
|
||||
}
|
||||
|
||||
// LookupCNAME returns the canonical name for the given host.
|
||||
@@ -403,8 +406,18 @@ func LookupCNAME(host string) (cname string, err error) {
|
||||
// LookupCNAME does not return an error if host does not
|
||||
// contain DNS "CNAME" records, as long as host resolves to
|
||||
// address records.
|
||||
-func (r *Resolver) LookupCNAME(ctx context.Context, host string) (cname string, err error) {
|
||||
- return r.lookupCNAME(ctx, host)
|
||||
+//
|
||||
+// The returned canonical name is validated to be a properly
|
||||
+// formatted presentation-format domain name.
|
||||
+func (r *Resolver) LookupCNAME(ctx context.Context, host string) (string, error) {
|
||||
+ cname, err := r.lookupCNAME(ctx, host)
|
||||
+ if err != nil {
|
||||
+ return "", err
|
||||
+ }
|
||||
+ if !isDomainName(cname) {
|
||||
+ return "", &DNSError{Err: "CNAME target is invalid", Name: host}
|
||||
+ }
|
||||
+ return cname, nil
|
||||
}
|
||||
|
||||
// LookupSRV tries to resolve an SRV query of the given service,
|
||||
@@ -416,8 +429,11 @@ func (r *Resolver) LookupCNAME(ctx context.Context, host string) (cname string,
|
||||
// That is, it looks up _service._proto.name. To accommodate services
|
||||
// publishing SRV records under non-standard names, if both service
|
||||
// and proto are empty strings, LookupSRV looks up name directly.
|
||||
+//
|
||||
+// The returned service names are validated to be properly
|
||||
+// formatted presentation-format domain names.
|
||||
func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err error) {
|
||||
- return DefaultResolver.lookupSRV(context.Background(), service, proto, name)
|
||||
+ return DefaultResolver.LookupSRV(context.Background(), service, proto, name)
|
||||
}
|
||||
|
||||
// LookupSRV tries to resolve an SRV query of the given service,
|
||||
@@ -429,28 +445,82 @@ func LookupSRV(service, proto, name string) (cname string, addrs []*SRV, err err
|
||||
// That is, it looks up _service._proto.name. To accommodate services
|
||||
// publishing SRV records under non-standard names, if both service
|
||||
// and proto are empty strings, LookupSRV looks up name directly.
|
||||
-func (r *Resolver) LookupSRV(ctx context.Context, service, proto, name string) (cname string, addrs []*SRV, err error) {
|
||||
- return r.lookupSRV(ctx, service, proto, name)
|
||||
+//
|
||||
+// The returned service names are validated to be properly
|
||||
+// formatted presentation-format domain names.
|
||||
+func (r *Resolver) LookupSRV(ctx context.Context, service, proto, name string) (string, []*SRV, error) {
|
||||
+ cname, addrs, err := r.lookupSRV(ctx, service, proto, name)
|
||||
+ if err != nil {
|
||||
+ return "", nil, err
|
||||
+ }
|
||||
+ if cname != "" && !isDomainName(cname) {
|
||||
+ return "", nil, &DNSError{Err: "SRV header name is invalid", Name: name}
|
||||
+ }
|
||||
+ for _, addr := range addrs {
|
||||
+ if addr == nil {
|
||||
+ continue
|
||||
+ }
|
||||
+ if !isDomainName(addr.Target) {
|
||||
+ return "", nil, &DNSError{Err: "SRV target is invalid", Name: name}
|
||||
+ }
|
||||
+ }
|
||||
+ return cname, addrs, nil
|
||||
}
|
||||
|
||||
// LookupMX returns the DNS MX records for the given domain name sorted by preference.
|
||||
+//
|
||||
+// The returned mail server names are validated to be properly
|
||||
+// formatted presentation-format domain names.
|
||||
func LookupMX(name string) ([]*MX, error) {
|
||||
- return DefaultResolver.lookupMX(context.Background(), name)
|
||||
+ return DefaultResolver.LookupMX(context.Background(), name)
|
||||
}
|
||||
|
||||
// LookupMX returns the DNS MX records for the given domain name sorted by preference.
|
||||
+//
|
||||
+// The returned mail server names are validated to be properly
|
||||
+// formatted presentation-format domain names.
|
||||
func (r *Resolver) LookupMX(ctx context.Context, name string) ([]*MX, error) {
|
||||
- return r.lookupMX(ctx, name)
|
||||
+ records, err := r.lookupMX(ctx, name)
|
||||
+ if err != nil {
|
||||
+ return nil, err
|
||||
+ }
|
||||
+ for _, mx := range records {
|
||||
+ if mx == nil {
|
||||
+ continue
|
||||
+ }
|
||||
+ if !isDomainName(mx.Host) {
|
||||
+ return nil, &DNSError{Err: "MX target is invalid", Name: name}
|
||||
+ }
|
||||
+ }
|
||||
+ return records, nil
|
||||
}
|
||||
|
||||
// LookupNS returns the DNS NS records for the given domain name.
|
||||
+//
|
||||
+// The returned name server names are validated to be properly
|
||||
+// formatted presentation-format domain names.
|
||||
func LookupNS(name string) ([]*NS, error) {
|
||||
- return DefaultResolver.lookupNS(context.Background(), name)
|
||||
+ return DefaultResolver.LookupNS(context.Background(), name)
|
||||
}
|
||||
|
||||
// LookupNS returns the DNS NS records for the given domain name.
|
||||
+//
|
||||
+// The returned name server names are validated to be properly
|
||||
+// formatted presentation-format domain names.
|
||||
func (r *Resolver) LookupNS(ctx context.Context, name string) ([]*NS, error) {
|
||||
- return r.lookupNS(ctx, name)
|
||||
+ records, err := r.lookupNS(ctx, name)
|
||||
+ if err != nil {
|
||||
+ return nil, err
|
||||
+ }
|
||||
+ for _, ns := range records {
|
||||
+ if ns == nil {
|
||||
+ continue
|
||||
+ }
|
||||
+ if !isDomainName(ns.Host) {
|
||||
+ return nil, &DNSError{Err: "NS target is invalid", Name: name}
|
||||
+ }
|
||||
+ }
|
||||
+ return records, nil
|
||||
}
|
||||
|
||||
// LookupTXT returns the DNS TXT records for the given domain name.
|
||||
@@ -466,14 +536,29 @@ func (r *Resolver) LookupTXT(ctx context.Context, name string) ([]string, error)
|
||||
// LookupAddr performs a reverse lookup for the given address, returning a list
|
||||
// of names mapping to that address.
|
||||
//
|
||||
+// The returned names are validated to be properly formatted presentation-format
|
||||
+// domain names.
|
||||
+//
|
||||
// When using the host C library resolver, at most one result will be
|
||||
// returned. To bypass the host resolver, use a custom Resolver.
|
||||
func LookupAddr(addr string) (names []string, err error) {
|
||||
- return DefaultResolver.lookupAddr(context.Background(), addr)
|
||||
+ return DefaultResolver.LookupAddr(context.Background(), addr)
|
||||
}
|
||||
|
||||
// LookupAddr performs a reverse lookup for the given address, returning a list
|
||||
// of names mapping to that address.
|
||||
-func (r *Resolver) LookupAddr(ctx context.Context, addr string) (names []string, err error) {
|
||||
- return r.lookupAddr(ctx, addr)
|
||||
+//
|
||||
+// The returned names are validated to be properly formatted presentation-format
|
||||
+// domain names.
|
||||
+func (r *Resolver) LookupAddr(ctx context.Context, addr string) ([]string, error) {
|
||||
+ names, err := r.lookupAddr(ctx, addr)
|
||||
+ if err != nil {
|
||||
+ return nil, err
|
||||
+ }
|
||||
+ for _, name := range names {
|
||||
+ if !isDomainName(name) {
|
||||
+ return nil, &DNSError{Err: "PTR target is invalid", Name: addr}
|
||||
+ }
|
||||
+ }
|
||||
+ return names, nil
|
||||
}
|
||||
--
|
||||
2.27.0
|
||||
|
||||
130
0047-release-branch.go1.15-archive-zip-only-preallocate-F.patch
Normal file
130
0047-release-branch.go1.15-archive-zip-only-preallocate-F.patch
Normal file
@ -0,0 +1,130 @@
|
||||
From c92adf420a3d9a5510f9aea382d826f0c9216a10 Mon Sep 17 00:00:00 2001
|
||||
From: Roland Shoemaker <roland@golang.org>
|
||||
Date: Tue, 11 May 2021 11:31:31 -0700
|
||||
Subject: [PATCH] [release-branch.go1.15] archive/zip: only preallocate File
|
||||
slice if reasonably sized
|
||||
|
||||
Since the number of files in the EOCD record isn't validated, it isn't
|
||||
safe to preallocate Reader.Files using that field. A malformed archive
|
||||
can indicate it contains up to 1 << 128 - 1 files. We can still safely
|
||||
preallocate the slice by checking if the specified number of files in
|
||||
the archive is reasonable, given the size of the archive.
|
||||
|
||||
Thanks to the OSS-Fuzz project for discovering this issue and to
|
||||
Emmanuel Odeke for reporting it.
|
||||
|
||||
Updates #46242
|
||||
Fixes #46396
|
||||
Fixes CVE-2021-33196
|
||||
|
||||
Conflict:NA
|
||||
Reference:https://github.com/golang/go/commit/c92adf420a3d9a5510f9aea382d826f0c9216a10
|
||||
|
||||
Change-Id: I3c76d8eec178468b380d87fdb4a3f2cb06f0ee76
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/318909
|
||||
Trust: Roland Shoemaker <roland@golang.org>
|
||||
Trust: Katie Hockman <katie@golang.org>
|
||||
Trust: Joe Tsai <thebrokentoaster@gmail.com>
|
||||
Run-TryBot: Roland Shoemaker <roland@golang.org>
|
||||
TryBot-Result: Go Bot <gobot@golang.org>
|
||||
Reviewed-by: Katie Hockman <katie@golang.org>
|
||||
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
|
||||
(cherry picked from commit 74242baa4136c7a9132a8ccd9881354442788c8c)
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/322949
|
||||
Reviewed-by: Filippo Valsorda <filippo@golang.org>
|
||||
---
|
||||
src/archive/zip/reader.go | 10 +++++-
|
||||
src/archive/zip/reader_test.go | 59 ++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 68 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/archive/zip/reader.go b/src/archive/zip/reader.go
|
||||
index 13ff9ddcf4..2d5151af3d 100644
|
||||
--- a/src/archive/zip/reader.go
|
||||
+++ b/src/archive/zip/reader.go
|
||||
@@ -84,7 +84,15 @@ func (z *Reader) init(r io.ReaderAt, size int64) error {
|
||||
return err
|
||||
}
|
||||
z.r = r
|
||||
- z.File = make([]*File, 0, end.directoryRecords)
|
||||
+ // Since the number of directory records is not validated, it is not
|
||||
+ // safe to preallocate z.File without first checking that the specified
|
||||
+ // number of files is reasonable, since a malformed archive may
|
||||
+ // indicate it contains up to 1 << 128 - 1 files. Since each file has a
|
||||
+ // header which will be _at least_ 30 bytes we can safely preallocate
|
||||
+ // if (data size / 30) >= end.directoryRecords.
|
||||
+ if (uint64(size)-end.directorySize)/30 >= end.directoryRecords {
|
||||
+ z.File = make([]*File, 0, end.directoryRecords)
|
||||
+ }
|
||||
z.Comment = end.comment
|
||||
rs := io.NewSectionReader(r, 0, size)
|
||||
if _, err = rs.Seek(int64(end.directoryOffset), io.SeekStart); err != nil {
|
||||
diff --git a/src/archive/zip/reader_test.go b/src/archive/zip/reader_test.go
|
||||
index adca87a8b3..6f67d2e4a9 100644
|
||||
--- a/src/archive/zip/reader_test.go
|
||||
+++ b/src/archive/zip/reader_test.go
|
||||
@@ -1070,3 +1070,62 @@ func TestIssue12449(t *testing.T) {
|
||||
t.Errorf("Error reading the archive: %v", err)
|
||||
}
|
||||
}
|
||||
+
|
||||
+func TestCVE202133196(t *testing.T) {
|
||||
+ // Archive that indicates it has 1 << 128 -1 files,
|
||||
+ // this would previously cause a panic due to attempting
|
||||
+ // to allocate a slice with 1 << 128 -1 elements.
|
||||
+ data := []byte{
|
||||
+ 0x50, 0x4b, 0x03, 0x04, 0x14, 0x00, 0x08, 0x08,
|
||||
+ 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
+ 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x02,
|
||||
+ 0x03, 0x62, 0x61, 0x65, 0x03, 0x04, 0x00, 0x00,
|
||||
+ 0xff, 0xff, 0x50, 0x4b, 0x07, 0x08, 0xbe, 0x20,
|
||||
+ 0x5c, 0x6c, 0x09, 0x00, 0x00, 0x00, 0x03, 0x00,
|
||||
+ 0x00, 0x00, 0x50, 0x4b, 0x01, 0x02, 0x14, 0x00,
|
||||
+ 0x14, 0x00, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00,
|
||||
+ 0x00, 0x00, 0xbe, 0x20, 0x5c, 0x6c, 0x09, 0x00,
|
||||
+ 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00,
|
||||
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
+ 0x01, 0x02, 0x03, 0x50, 0x4b, 0x06, 0x06, 0x2c,
|
||||
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d,
|
||||
+ 0x00, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
+ 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
+ 0xff, 0xff, 0xff, 0x31, 0x00, 0x00, 0x00, 0x00,
|
||||
+ 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x00,
|
||||
+ 0x00, 0x00, 0x00, 0x50, 0x4b, 0x06, 0x07, 0x00,
|
||||
+ 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x00,
|
||||
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x50,
|
||||
+ 0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0xff,
|
||||
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
+ 0xff, 0xff, 0xff, 0x00, 0x00,
|
||||
+ }
|
||||
+ _, err := NewReader(bytes.NewReader(data), int64(len(data)))
|
||||
+ if err != ErrFormat {
|
||||
+ t.Fatalf("unexpected error, got: %v, want: %v", err, ErrFormat)
|
||||
+ }
|
||||
+
|
||||
+ // Also check that an archive containing a handful of empty
|
||||
+ // files doesn't cause an issue
|
||||
+ b := bytes.NewBuffer(nil)
|
||||
+ w := NewWriter(b)
|
||||
+ for i := 0; i < 5; i++ {
|
||||
+ _, err := w.Create("")
|
||||
+ if err != nil {
|
||||
+ t.Fatalf("Writer.Create failed: %s", err)
|
||||
+ }
|
||||
+ }
|
||||
+ if err := w.Close(); err != nil {
|
||||
+ t.Fatalf("Writer.Close failed: %s", err)
|
||||
+ }
|
||||
+ r, err := NewReader(bytes.NewReader(b.Bytes()), int64(b.Len()))
|
||||
+ if err != nil {
|
||||
+ t.Fatalf("NewReader failed: %s", err)
|
||||
+ }
|
||||
+ if len(r.File) != 5 {
|
||||
+ t.Errorf("Archive has unexpected number of files, got %d, want 5", len(r.File))
|
||||
+ }
|
||||
+}
|
||||
--
|
||||
2.27.0
|
||||
|
||||
154
0048-release-branch.go1.15-net-http-httputil-always-remov.patch
Normal file
154
0048-release-branch.go1.15-net-http-httputil-always-remov.patch
Normal file
@ -0,0 +1,154 @@
|
||||
From cbd1ca84453fecf3825a6bb9f985823e8bc32b76 Mon Sep 17 00:00:00 2001
|
||||
From: Filippo Valsorda <filippo@golang.org>
|
||||
Date: Fri, 21 May 2021 14:02:30 -0400
|
||||
Subject: [PATCH] [release-branch.go1.15] net/http/httputil: always remove
|
||||
hop-by-hop headers
|
||||
|
||||
Previously, we'd fail to remove the Connection header from a request
|
||||
like this:
|
||||
|
||||
Connection:
|
||||
Connection: x-header
|
||||
|
||||
Updates #46313
|
||||
Fixes #46314
|
||||
Fixes CVE-2021-33197
|
||||
|
||||
Change-Id: Ie3009e926ceecfa86dfa6bcc6fe14ff01086be7d
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/321929
|
||||
Run-TryBot: Filippo Valsorda <filippo@golang.org>
|
||||
Reviewed-by: Katie Hockman <katie@golang.org>
|
||||
Trust: Katie Hockman <katie@golang.org>
|
||||
Trust: Filippo Valsorda <filippo@golang.org>
|
||||
TryBot-Result: Go Bot <gobot@golang.org>
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/323091
|
||||
Run-TryBot: Katie Hockman <katie@golang.org>
|
||||
|
||||
Conflict:NA
|
||||
Reference:https://github.com/golang/go/commit/cbd1ca84453fecf3825a6bb9f985823e8bc32b76
|
||||
|
||||
---
|
||||
src/net/http/httputil/reverseproxy.go | 22 ++++----
|
||||
src/net/http/httputil/reverseproxy_test.go | 63 +++++++++++++++++++++-
|
||||
2 files changed, 70 insertions(+), 15 deletions(-)
|
||||
|
||||
diff --git a/src/net/http/httputil/reverseproxy.go b/src/net/http/httputil/reverseproxy.go
|
||||
index 3f48fab544..f49cefbb4f 100644
|
||||
--- a/src/net/http/httputil/reverseproxy.go
|
||||
+++ b/src/net/http/httputil/reverseproxy.go
|
||||
@@ -248,22 +248,18 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||
// important is "Connection" because we want a persistent
|
||||
// connection, regardless of what the client sent to us.
|
||||
for _, h := range hopHeaders {
|
||||
- hv := outreq.Header.Get(h)
|
||||
- if hv == "" {
|
||||
- continue
|
||||
- }
|
||||
- if h == "Te" && hv == "trailers" {
|
||||
- // Issue 21096: tell backend applications that
|
||||
- // care about trailer support that we support
|
||||
- // trailers. (We do, but we don't go out of
|
||||
- // our way to advertise that unless the
|
||||
- // incoming client request thought it was
|
||||
- // worth mentioning)
|
||||
- continue
|
||||
- }
|
||||
outreq.Header.Del(h)
|
||||
}
|
||||
|
||||
+ // Issue 21096: tell backend applications that care about trailer support
|
||||
+ // that we support trailers. (We do, but we don't go out of our way to
|
||||
+ // advertise that unless the incoming client request thought it was worth
|
||||
+ // mentioning.) Note that we look at req.Header, not outreq.Header, since
|
||||
+ // the latter has passed through removeConnectionHeaders.
|
||||
+ if httpguts.HeaderValuesContainsToken(req.Header["Te"], "trailers") {
|
||||
+ outreq.Header.Set("Te", "trailers")
|
||||
+ }
|
||||
+
|
||||
// After stripping all the hop-by-hop connection headers above, add back any
|
||||
// necessary for protocol upgrades, such as for websockets.
|
||||
if reqUpType != "" {
|
||||
diff --git a/src/net/http/httputil/reverseproxy_test.go b/src/net/http/httputil/reverseproxy_test.go
|
||||
index 764939fb0f..1f2dfb9867 100644
|
||||
--- a/src/net/http/httputil/reverseproxy_test.go
|
||||
+++ b/src/net/http/httputil/reverseproxy_test.go
|
||||
@@ -91,8 +91,9 @@ func TestReverseProxy(t *testing.T) {
|
||||
|
||||
getReq, _ := http.NewRequest("GET", frontend.URL, nil)
|
||||
getReq.Host = "some-name"
|
||||
- getReq.Header.Set("Connection", "close")
|
||||
- getReq.Header.Set("Te", "trailers")
|
||||
+ getReq.Header.Set("Connection", "close, TE")
|
||||
+ getReq.Header.Add("Te", "foo")
|
||||
+ getReq.Header.Add("Te", "bar, trailers")
|
||||
getReq.Header.Set("Proxy-Connection", "should be deleted")
|
||||
getReq.Header.Set("Upgrade", "foo")
|
||||
getReq.Close = true
|
||||
@@ -236,6 +237,64 @@ func TestReverseProxyStripHeadersPresentInConnection(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
+func TestReverseProxyStripEmptyConnection(t *testing.T) {
|
||||
+ // See Issue 46313.
|
||||
+ const backendResponse = "I am the backend"
|
||||
+
|
||||
+ // someConnHeader is some arbitrary header to be declared as a hop-by-hop header
|
||||
+ // in the Request's Connection header.
|
||||
+ const someConnHeader = "X-Some-Conn-Header"
|
||||
+
|
||||
+ backend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
+ if c := r.Header.Values("Connection"); len(c) != 0 {
|
||||
+ t.Errorf("handler got header %q = %v; want empty", "Connection", c)
|
||||
+ }
|
||||
+ if c := r.Header.Get(someConnHeader); c != "" {
|
||||
+ t.Errorf("handler got header %q = %q; want empty", someConnHeader, c)
|
||||
+ }
|
||||
+ w.Header().Add("Connection", "")
|
||||
+ w.Header().Add("Connection", someConnHeader)
|
||||
+ w.Header().Set(someConnHeader, "should be deleted")
|
||||
+ io.WriteString(w, backendResponse)
|
||||
+ }))
|
||||
+ defer backend.Close()
|
||||
+ backendURL, err := url.Parse(backend.URL)
|
||||
+ if err != nil {
|
||||
+ t.Fatal(err)
|
||||
+ }
|
||||
+ proxyHandler := NewSingleHostReverseProxy(backendURL)
|
||||
+ frontend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
+ proxyHandler.ServeHTTP(w, r)
|
||||
+ if c := r.Header.Get(someConnHeader); c != "should be deleted" {
|
||||
+ t.Errorf("handler modified header %q = %q; want %q", someConnHeader, c, "should be deleted")
|
||||
+ }
|
||||
+ }))
|
||||
+ defer frontend.Close()
|
||||
+
|
||||
+ getReq, _ := http.NewRequest("GET", frontend.URL, nil)
|
||||
+ getReq.Header.Add("Connection", "")
|
||||
+ getReq.Header.Add("Connection", someConnHeader)
|
||||
+ getReq.Header.Set(someConnHeader, "should be deleted")
|
||||
+ res, err := frontend.Client().Do(getReq)
|
||||
+ if err != nil {
|
||||
+ t.Fatalf("Get: %v", err)
|
||||
+ }
|
||||
+ defer res.Body.Close()
|
||||
+ bodyBytes, err := ioutil.ReadAll(res.Body)
|
||||
+ if err != nil {
|
||||
+ t.Fatalf("reading body: %v", err)
|
||||
+ }
|
||||
+ if got, want := string(bodyBytes), backendResponse; got != want {
|
||||
+ t.Errorf("got body %q; want %q", got, want)
|
||||
+ }
|
||||
+ if c := res.Header.Get("Connection"); c != "" {
|
||||
+ t.Errorf("handler got header %q = %q; want empty", "Connection", c)
|
||||
+ }
|
||||
+ if c := res.Header.Get(someConnHeader); c != "" {
|
||||
+ t.Errorf("handler got header %q = %q; want empty", someConnHeader, c)
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
func TestXForwardedFor(t *testing.T) {
|
||||
const prevForwardedFor = "client ip"
|
||||
const backendResponse = "I am the backend"
|
||||
--
|
||||
2.27.0
|
||||
|
||||
114
0049-release-branch.go1.15-math-big-check-for-excessive-e.patch
Normal file
114
0049-release-branch.go1.15-math-big-check-for-excessive-e.patch
Normal file
@ -0,0 +1,114 @@
|
||||
From df9ce19db6df32d94eae8760927bdfbc595433c3 Mon Sep 17 00:00:00 2001
|
||||
From: Robert Griesemer <gri@golang.org>
|
||||
Date: Sun, 2 May 2021 11:27:03 -0700
|
||||
Subject: [PATCH] [release-branch.go1.15] math/big: check for excessive
|
||||
exponents in Rat.SetString
|
||||
|
||||
Found by OSS-Fuzz https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33284
|
||||
|
||||
Thanks to Emmanuel Odeke for reporting this issue.
|
||||
|
||||
Updates #45910
|
||||
Fixes #46305
|
||||
Fixes CVE-2021-33198
|
||||
|
||||
Change-Id: I61e7b04dbd80343420b57eede439e361c0f7b79c
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/316149
|
||||
Trust: Robert Griesemer <gri@golang.org>
|
||||
Trust: Katie Hockman <katie@golang.org>
|
||||
Run-TryBot: Robert Griesemer <gri@golang.org>
|
||||
TryBot-Result: Go Bot <gobot@golang.org>
|
||||
Reviewed-by: Katie Hockman <katie@golang.org>
|
||||
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
|
||||
(cherry picked from commit 6c591f79b0b5327549bd4e94970f7a279efb4ab0)
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/321831
|
||||
Run-TryBot: Katie Hockman <katie@golang.org>
|
||||
Reviewed-by: Roland Shoemaker <roland@golang.org>
|
||||
|
||||
Conflict:NA
|
||||
Reference:https://github.com/golang/go/commit/df9ce19db6df32d94eae8760927bdfbc595433c3
|
||||
|
||||
---
|
||||
src/math/big/ratconv.go | 15 ++++++++-------
|
||||
src/math/big/ratconv_test.go | 25 +++++++++++++++++++++++++
|
||||
2 files changed, 33 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/src/math/big/ratconv.go b/src/math/big/ratconv.go
|
||||
index 941139e72d..ac3c8bd11f 100644
|
||||
--- a/src/math/big/ratconv.go
|
||||
+++ b/src/math/big/ratconv.go
|
||||
@@ -51,7 +51,8 @@ func (z *Rat) Scan(s fmt.ScanState, ch rune) error {
|
||||
// An optional base-10 ``e'' or base-2 ``p'' (or their upper-case variants)
|
||||
// exponent may be provided as well, except for hexadecimal floats which
|
||||
// only accept an (optional) ``p'' exponent (because an ``e'' or ``E'' cannot
|
||||
-// be distinguished from a mantissa digit).
|
||||
+// be distinguished from a mantissa digit). If the exponent's absolute value
|
||||
+// is too large, the operation may fail.
|
||||
// The entire string, not just a prefix, must be valid for success. If the
|
||||
// operation failed, the value of z is undefined but the returned value is nil.
|
||||
func (z *Rat) SetString(s string) (*Rat, bool) {
|
||||
@@ -169,6 +170,9 @@ func (z *Rat) SetString(s string) (*Rat, bool) {
|
||||
if n < 0 {
|
||||
n = -n
|
||||
}
|
||||
+ if n > 1e6 {
|
||||
+ return nil, false // avoid excessively large exponents
|
||||
+ }
|
||||
pow5 := z.b.abs.expNN(natFive, nat(nil).setWord(Word(n)), nil) // use underlying array of z.b.abs
|
||||
if exp5 > 0 {
|
||||
z.a.abs = z.a.abs.mul(z.a.abs, pow5)
|
||||
@@ -181,15 +185,12 @@ func (z *Rat) SetString(s string) (*Rat, bool) {
|
||||
}
|
||||
|
||||
// apply exp2 contributions
|
||||
+ if exp2 < -1e7 || exp2 > 1e7 {
|
||||
+ return nil, false // avoid excessively large exponents
|
||||
+ }
|
||||
if exp2 > 0 {
|
||||
- if int64(uint(exp2)) != exp2 {
|
||||
- panic("exponent too large")
|
||||
- }
|
||||
z.a.abs = z.a.abs.shl(z.a.abs, uint(exp2))
|
||||
} else if exp2 < 0 {
|
||||
- if int64(uint(-exp2)) != -exp2 {
|
||||
- panic("exponent too large")
|
||||
- }
|
||||
z.b.abs = z.b.abs.shl(z.b.abs, uint(-exp2))
|
||||
}
|
||||
|
||||
diff --git a/src/math/big/ratconv_test.go b/src/math/big/ratconv_test.go
|
||||
index ba0d1ba9e1..15d206cb38 100644
|
||||
--- a/src/math/big/ratconv_test.go
|
||||
+++ b/src/math/big/ratconv_test.go
|
||||
@@ -589,3 +589,28 @@ func TestIssue31184(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
+
|
||||
+func TestIssue45910(t *testing.T) {
|
||||
+ var x Rat
|
||||
+ for _, test := range []struct {
|
||||
+ input string
|
||||
+ want bool
|
||||
+ }{
|
||||
+ {"1e-1000001", false},
|
||||
+ {"1e-1000000", true},
|
||||
+ {"1e+1000000", true},
|
||||
+ {"1e+1000001", false},
|
||||
+
|
||||
+ {"0p1000000000000", true},
|
||||
+ {"1p-10000001", false},
|
||||
+ {"1p-10000000", true},
|
||||
+ {"1p+10000000", true},
|
||||
+ {"1p+10000001", false},
|
||||
+ {"1.770p02041010010011001001", false}, // test case from issue
|
||||
+ } {
|
||||
+ _, got := x.SetString(test.input)
|
||||
+ if got != test.want {
|
||||
+ t.Errorf("SetString(%s) got ok = %v; want %v", test.input, got, test.want)
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -0,0 +1,53 @@
|
||||
From c77980bc077f3774276ab2deba78d8e6bfe4b3bd Mon Sep 17 00:00:00 2001
|
||||
From: Roland Shoemaker <roland@golang.org>
|
||||
Date: Wed, 9 Jun 2021 11:31:27 -0700
|
||||
Subject: [PATCH] [release-branch.go1.15] crypto/tls: test key type when
|
||||
casting
|
||||
|
||||
When casting the certificate public key in generateClientKeyExchange,
|
||||
check the type is appropriate. This prevents a panic when a server
|
||||
agrees to a RSA based key exchange, but then sends an ECDSA (or
|
||||
other) certificate.
|
||||
|
||||
Updates #47143
|
||||
Fixes #47144
|
||||
Fixes CVE-2021-34558
|
||||
|
||||
Thanks to Imre Rad for reporting this issue.
|
||||
|
||||
Change-Id: Iabccacca6052769a605cccefa1216a9f7b7f6aea
|
||||
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1116723
|
||||
Reviewed-by: Filippo Valsorda <valsorda@google.com>
|
||||
Reviewed-by: Katie Hockman <katiehockman@google.com>
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/334030
|
||||
Trust: Filippo Valsorda <filippo@golang.org>
|
||||
Run-TryBot: Filippo Valsorda <filippo@golang.org>
|
||||
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
|
||||
|
||||
Conflict:NA
|
||||
Reference:https://github.com/golang/go/commit/c77980bc077f3774276ab2deba78d8e6bfe4b3bd
|
||||
|
||||
---
|
||||
src/crypto/tls/key_agreement.go | 6 +++++-
|
||||
1 file changed, 5 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/crypto/tls/key_agreement.go b/src/crypto/tls/key_agreement.go
|
||||
index 7e6534bd46..22f1b2e1f2 100644
|
||||
--- a/src/crypto/tls/key_agreement.go
|
||||
+++ b/src/crypto/tls/key_agreement.go
|
||||
@@ -67,7 +67,11 @@ func (ka rsaKeyAgreement) generateClientKeyExchange(config *Config, clientHello
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
- encrypted, err := rsa.EncryptPKCS1v15(config.rand(), cert.PublicKey.(*rsa.PublicKey), preMasterSecret)
|
||||
+ rsaKey, ok := cert.PublicKey.(*rsa.PublicKey)
|
||||
+ if !ok {
|
||||
+ return nil, nil, errors.New("tls: server certificate contains incorrect key type for selected ciphersuite")
|
||||
+ }
|
||||
+ encrypted, err := rsa.EncryptPKCS1v15(config.rand(), rsaKey, preMasterSecret)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
--
|
||||
2.27.0
|
||||
|
||||
124
0051-net-reject-leading-zeros-in-IP-address-parsers.patch
Normal file
124
0051-net-reject-leading-zeros-in-IP-address-parsers.patch
Normal file
@ -0,0 +1,124 @@
|
||||
From d3e3d03666bbd8784007bbb78a75864aac786967 Mon Sep 17 00:00:00 2001
|
||||
From: Roland Shoemaker <roland@golang.org>
|
||||
Date: Mon, 7 Jun 2021 10:21:29 -0700
|
||||
Subject: [PATCH] net: reject leading zeros in IP address parsers
|
||||
|
||||
In both net.ParseIP and net.ParseCIDR reject leading zeros in the
|
||||
dot-decimal notation of IPv4 addresses.
|
||||
|
||||
Fixes #30999
|
||||
Fixes #43389
|
||||
|
||||
Change-Id: I2b6a31fe84db89ac828cf5ed03eaa586ee96ab68
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/325829
|
||||
Trust: Roland Shoemaker <roland@golang.org>
|
||||
Trust: Katie Hockman <katie@golang.org>
|
||||
Run-TryBot: Roland Shoemaker <roland@golang.org>
|
||||
Reviewed-by: Filippo Valsorda <filippo@golang.org>
|
||||
Reviewed-by: Katie Hockman <katie@golang.org>
|
||||
TryBot-Result: Go Bot <gobot@golang.org>
|
||||
|
||||
Conflict:NA
|
||||
Reference:https://github.com/golang/go/commit/d3e3d03666bbd8784007bbb78a75864aac786967
|
||||
|
||||
---
|
||||
src/net/hosts_test.go | 4 ++--
|
||||
src/net/ip.go | 4 ++++
|
||||
src/net/ip_test.go | 8 ++++++--
|
||||
src/net/testdata/ipv4-hosts | 8 ++------
|
||||
5 files changed, 24 insertions(+), 10 deletions(-)
|
||||
|
||||
|
||||
diff --git a/src/net/hosts_test.go b/src/net/hosts_test.go
|
||||
index f850e2fccf..19c43999f9 100644
|
||||
--- a/src/net/hosts_test.go
|
||||
+++ b/src/net/hosts_test.go
|
||||
@@ -36,7 +36,7 @@ var lookupStaticHostTests = []struct {
|
||||
},
|
||||
},
|
||||
{
|
||||
- "testdata/ipv4-hosts", // see golang.org/issue/8996
|
||||
+ "testdata/ipv4-hosts",
|
||||
[]staticHostEntry{
|
||||
{"localhost", []string{"127.0.0.1", "127.0.0.2", "127.0.0.3"}},
|
||||
{"localhost.localdomain", []string{"127.0.0.3"}},
|
||||
@@ -102,7 +102,7 @@ var lookupStaticAddrTests = []struct {
|
||||
},
|
||||
},
|
||||
{
|
||||
- "testdata/ipv4-hosts", // see golang.org/issue/8996
|
||||
+ "testdata/ipv4-hosts",
|
||||
[]staticHostEntry{
|
||||
{"127.0.0.1", []string{"localhost"}},
|
||||
{"127.0.0.2", []string{"localhost"}},
|
||||
diff --git a/src/net/ip.go b/src/net/ip.go
|
||||
index 0477269761..38e1aa2247 100644
|
||||
--- a/src/net/ip.go
|
||||
+++ b/src/net/ip.go
|
||||
@@ -574,6 +574,10 @@ func parseIPv4(s string) IP {
|
||||
if !ok || n > 0xFF {
|
||||
return nil
|
||||
}
|
||||
+ if c > 1 && s[0] == '0' {
|
||||
+ // Reject non-zero components with leading zeroes.
|
||||
+ return nil
|
||||
+ }
|
||||
s = s[c:]
|
||||
p[i] = byte(n)
|
||||
}
|
||||
diff --git a/src/net/ip_test.go b/src/net/ip_test.go
|
||||
index 3af5e41ceb..5bbda6024d 100644
|
||||
--- a/src/net/ip_test.go
|
||||
+++ b/src/net/ip_test.go
|
||||
@@ -21,9 +21,7 @@ var parseIPTests = []struct {
|
||||
}{
|
||||
{"127.0.1.2", IPv4(127, 0, 1, 2)},
|
||||
{"127.0.0.1", IPv4(127, 0, 0, 1)},
|
||||
- {"127.001.002.003", IPv4(127, 1, 2, 3)},
|
||||
{"::ffff:127.1.2.3", IPv4(127, 1, 2, 3)},
|
||||
- {"::ffff:127.001.002.003", IPv4(127, 1, 2, 3)},
|
||||
{"::ffff:7f01:0203", IPv4(127, 1, 2, 3)},
|
||||
{"0:0:0:0:0000:ffff:127.1.2.3", IPv4(127, 1, 2, 3)},
|
||||
{"0:0:0:0:000000:ffff:127.1.2.3", IPv4(127, 1, 2, 3)},
|
||||
@@ -43,6 +41,11 @@ var parseIPTests = []struct {
|
||||
{"fe80::1%911", nil},
|
||||
{"", nil},
|
||||
{"a1:a2:a3:a4::b1:b2:b3:b4", nil}, // Issue 6628
|
||||
+ {"127.001.002.003", nil},
|
||||
+ {"::ffff:127.001.002.003", nil},
|
||||
+ {"123.000.000.000", nil},
|
||||
+ {"1.2..4", nil},
|
||||
+ {"0123.0.0.1", nil},
|
||||
}
|
||||
|
||||
func TestParseIP(t *testing.T) {
|
||||
@@ -358,6 +361,7 @@ var parseCIDRTests = []struct {
|
||||
{"0.0.-2.0/32", nil, nil, &ParseError{Type: "CIDR address", Text: "0.0.-2.0/32"}},
|
||||
{"0.0.0.-3/32", nil, nil, &ParseError{Type: "CIDR address", Text: "0.0.0.-3/32"}},
|
||||
{"0.0.0.0/-0", nil, nil, &ParseError{Type: "CIDR address", Text: "0.0.0.0/-0"}},
|
||||
+ {"127.000.000.001/32", nil, nil, &ParseError{Type: "CIDR address", Text: "127.000.000.001/32"}},
|
||||
{"", nil, nil, &ParseError{Type: "CIDR address", Text: ""}},
|
||||
}
|
||||
|
||||
diff --git a/src/net/testdata/ipv4-hosts b/src/net/testdata/ipv4-hosts
|
||||
index 5208bb44ac..6b99675dfc 100644
|
||||
--- a/src/net/testdata/ipv4-hosts
|
||||
+++ b/src/net/testdata/ipv4-hosts
|
||||
@@ -1,12 +1,8 @@
|
||||
# See https://tools.ietf.org/html/rfc1123.
|
||||
-#
|
||||
-# The literal IPv4 address parser in the net package is a relaxed
|
||||
-# one. It may accept a literal IPv4 address in dotted-decimal notation
|
||||
-# with leading zeros such as "001.2.003.4".
|
||||
|
||||
# internet address and host name
|
||||
127.0.0.1 localhost # inline comment separated by tab
|
||||
-127.000.000.002 localhost # inline comment separated by space
|
||||
+127.0.0.2 localhost # inline comment separated by space
|
||||
|
||||
# internet address, host name and aliases
|
||||
-127.000.000.003 localhost localhost.localdomain
|
||||
+127.0.0.3 localhost localhost.localdomain
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -0,0 +1,89 @@
|
||||
From 4548fcc8dfd933c237f29bba6f90040a85922564 Mon Sep 17 00:00:00 2001
|
||||
From: Michael Knyszek <mknyszek@google.com>
|
||||
Date: Thu, 2 Sep 2021 16:51:59 -0400
|
||||
Subject: [PATCH] [release-branch.go1.16] misc/wasm, cmd/link: do not let
|
||||
command line args overwrite global data
|
||||
|
||||
On Wasm, wasm_exec.js puts command line arguments at the beginning
|
||||
of the linear memory (following the "zero page"). Currently there
|
||||
is no limit for this, and a very long command line can overwrite
|
||||
the program's data section. Prevent this by limiting the command
|
||||
line to 4096 bytes, and in the linker ensuring the data section
|
||||
starts at a high enough address (8192).
|
||||
|
||||
(Arguably our address assignment on Wasm is a bit confusing. This
|
||||
is the minimum fix I can come up with.)
|
||||
|
||||
Thanks to Ben Lubar for reporting this issue.
|
||||
|
||||
Change by Cherry Mui <cherryyz@google.com>.
|
||||
|
||||
For #48797
|
||||
Fixes #48799
|
||||
Fixes CVE-2021-38297
|
||||
|
||||
Change-Id: I0f50fbb2a5b6d0d047e3c134a88988d9133e4ab3
|
||||
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1205933
|
||||
Reviewed-by: Roland Shoemaker <bracewell@google.com>
|
||||
Reviewed-by: Than McIntosh <thanm@google.com>
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/354591
|
||||
Trust: Michael Knyszek <mknyszek@google.com>
|
||||
Reviewed-by: Heschi Kreinick <heschi@google.com>
|
||||
---
|
||||
misc/wasm/wasm_exec.js | 7 +++++++
|
||||
src/cmd/link/internal/ld/data.go | 11 ++++++++++-
|
||||
2 files changed, 17 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/misc/wasm/wasm_exec.js b/misc/wasm/wasm_exec.js
|
||||
index 82041e6bb9..a0a264278b 100644
|
||||
--- a/misc/wasm/wasm_exec.js
|
||||
+++ b/misc/wasm/wasm_exec.js
|
||||
@@ -564,6 +564,13 @@
|
||||
offset += 8;
|
||||
});
|
||||
|
||||
+ // The linker guarantees global data starts from at least wasmMinDataAddr.
|
||||
+ // Keep in sync with cmd/link/internal/ld/data.go:wasmMinDataAddr.
|
||||
+ const wasmMinDataAddr = 4096 + 4096;
|
||||
+ if (offset >= wasmMinDataAddr) {
|
||||
+ throw new Error("command line too long");
|
||||
+ }
|
||||
+
|
||||
this._inst.exports.run(argc, argv);
|
||||
if (this.exited) {
|
||||
this._resolveExitPromise();
|
||||
diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go
|
||||
index 52035e9630..54a1d188cd 100644
|
||||
--- a/src/cmd/link/internal/ld/data.go
|
||||
+++ b/src/cmd/link/internal/ld/data.go
|
||||
@@ -2330,6 +2330,11 @@ func assignAddress(ctxt *Link, sect *sym.Section, n int, s loader.Sym, va uint64
|
||||
return sect, n, va
|
||||
}
|
||||
|
||||
+// On Wasm, we reserve 4096 bytes for zero page, then 4096 bytes for wasm_exec.js
|
||||
+// to store command line args. Data sections starts from at least address 8192.
|
||||
+// Keep in sync with wasm_exec.js.
|
||||
+const wasmMinDataAddr = 4096 + 4096
|
||||
+
|
||||
// address assigns virtual addresses to all segments and sections and
|
||||
// returns all segments in file order.
|
||||
func (ctxt *Link) address() []*sym.Segment {
|
||||
@@ -2339,10 +2344,14 @@ func (ctxt *Link) address() []*sym.Segment {
|
||||
order = append(order, &Segtext)
|
||||
Segtext.Rwx = 05
|
||||
Segtext.Vaddr = va
|
||||
- for _, s := range Segtext.Sections {
|
||||
+ for i, s := range Segtext.Sections {
|
||||
va = uint64(Rnd(int64(va), int64(s.Align)))
|
||||
s.Vaddr = va
|
||||
va += s.Length
|
||||
+
|
||||
+ if ctxt.IsWasm() && i == 0 && va < wasmMinDataAddr {
|
||||
+ va = wasmMinDataAddr
|
||||
+ }
|
||||
}
|
||||
|
||||
Segtext.Length = va - uint64(*FlagTextAddr)
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
From b7a85e0003cedb1b48a1fd3ae5b746ec6330102e Mon Sep 17 00:00:00 2001
|
||||
From: Damien Neil <dneil@google.com>
|
||||
Date: Wed, 7 Jul 2021 16:34:34 -0700
|
||||
Subject: [PATCH] net/http/httputil: close incoming ReverseProxy request body
|
||||
|
||||
Reading from an incoming request body after the request handler aborts
|
||||
with a panic can cause a panic, becuse http.Server does not (contrary
|
||||
to its documentation) close the request body in this case.
|
||||
|
||||
Always close the incoming request body in ReverseProxy.ServeHTTP to
|
||||
ensure that any in-flight outgoing requests using the body do not
|
||||
read from it.
|
||||
|
||||
Updates #46866
|
||||
Fixes CVE-2021-36221
|
||||
|
||||
Change-Id: I310df269200ad8732c5d9f1a2b00de68725831df
|
||||
Reviewed-on: https://go-review.googlesource.com/c/go/+/333191
|
||||
Trust: Damien Neil <dneil@google.com>
|
||||
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
|
||||
Reviewed-by: Filippo Valsorda <filippo@golang.org>
|
||||
---
|
||||
src/net/http/httputil/reverseproxy.go | 9 +++++
|
||||
src/net/http/httputil/reverseproxy_test.go | 39 ++++++++++++++++++++++
|
||||
2 files changed, 48 insertions(+)
|
||||
|
||||
diff --git a/src/net/http/httputil/reverseproxy.go b/src/net/http/httputil/reverseproxy.go
|
||||
index 5d39955d62..8b63368386 100644
|
||||
--- a/src/net/http/httputil/reverseproxy.go
|
||||
+++ b/src/net/http/httputil/reverseproxy.go
|
||||
@@ -235,6 +235,15 @@ func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||
if req.ContentLength == 0 {
|
||||
outreq.Body = nil // Issue 16036: nil Body for http.Transport retries
|
||||
}
|
||||
+ if outreq.Body != nil {
|
||||
+ // Reading from the request body after returning from a handler is not
|
||||
+ // allowed, and the RoundTrip goroutine that reads the Body can outlive
|
||||
+ // this handler. This can lead to a crash if the handler panics (see
|
||||
+ // Issue 46866). Although calling Close doesn't guarantee there isn't
|
||||
+ // any Read in flight after the handle returns, in practice it's safe to
|
||||
+ // read after closing it.
|
||||
+ defer outreq.Body.Close()
|
||||
+ }
|
||||
if outreq.Header == nil {
|
||||
outreq.Header = make(http.Header) // Issue 33142: historical behavior was to always allocate
|
||||
}
|
||||
--
|
||||
2.27.0
|
||||
|
||||
13
golang.spec
13
golang.spec
@ -62,7 +62,7 @@
|
||||
|
||||
Name: golang
|
||||
Version: 1.15.7
|
||||
Release: 4
|
||||
Release: 5
|
||||
Summary: The Go Programming Language
|
||||
License: BSD and Public Domain
|
||||
URL: https://golang.org/
|
||||
@ -191,6 +191,14 @@ Patch6041: 0041-release-branch.go1.15-runtime-pprof-skip-tests-for-A.patch
|
||||
Patch6043: 0043-release-branch.go1.15-math-big-fix-TestShiftOverlap-.patch
|
||||
Patch6044: 0044-release-branch.go1.15-math-big-remove-the-s390x-asse.patch
|
||||
Patch6045: 0045-net-http-fix-hijack-hang-at-abortPendingRead.patch
|
||||
Patch6046: 0046-release-branch.go1.15-net-verify-results-from-Lookup.patch
|
||||
Patch6047: 0047-release-branch.go1.15-archive-zip-only-preallocate-F.patch
|
||||
Patch6048: 0048-release-branch.go1.15-net-http-httputil-always-remov.patch
|
||||
Patch6049: 0049-release-branch.go1.15-math-big-check-for-excessive-e.patch
|
||||
Patch6050: 0050-release-branch.go1.15-crypto-tls-test-key-type-when-.patch
|
||||
Patch6051: 0051-net-reject-leading-zeros-in-IP-address-parsers.patch
|
||||
Patch6052: 0052-release-branch.go1.16-misc-wasm-cmd-link-do-not-let-.patch
|
||||
Patch6053: 0053-net-http-httputil-close-incoming-ReverseProxy-reques.patch
|
||||
|
||||
Patch9001: 0001-drop-hard-code-cert.patch
|
||||
|
||||
@ -424,6 +432,9 @@ fi
|
||||
%files devel -f go-tests.list -f go-misc.list -f go-src.list
|
||||
|
||||
%changelog
|
||||
* Wed Oct 27 2021 chenjiankun <chenjiankun1@huawei.com> - 1.15.7-5
|
||||
- fix CVE-2021-33195,CVE-2021-33196,CVE-2021-33197,CVE-2021-33198,CVE-2021-34558,CVE-2021-29923,CVE-2021-38297,CVE-2021-36221
|
||||
|
||||
* Fri Jun 18 2021 chenjiankun <chenjiankun1@huawei.com> - 1.15.7-4
|
||||
- batch synchronization
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user