|
|
b22ff0 |
From be1eb6f70fb40e45096b69aeb048d54c526a4a8f Mon Sep 17 00:00:00 2001
|
|
|
b22ff0 |
From: Valentin Rothberg <rothberg@redhat.com>
|
|
|
b22ff0 |
Date: Thu, 6 Feb 2020 09:49:15 +0100
|
|
|
b22ff0 |
Subject: [PATCH] [1.11-rhel] update github.com/containers/image
|
|
|
b22ff0 |
|
|
|
b22ff0 |
Note that this includes fixes for
|
|
|
b22ff0 |
https://access.redhat.com/security/cve/CVE-2020-1702.
|
|
|
b22ff0 |
|
|
|
b22ff0 |
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
|
|
|
b22ff0 |
---
|
|
|
b22ff0 |
go.mod | 2 +-
|
|
|
b22ff0 |
go.sum | 2 +
|
|
|
b22ff0 |
.../image/v5/docker/docker_client.go | 6 +-
|
|
|
b22ff0 |
.../image/v5/docker/docker_image_dest.go | 3 +-
|
|
|
b22ff0 |
.../image/v5/docker/docker_image_src.go | 10 ++--
|
|
|
b22ff0 |
.../image/v5/docker/tarfile/dest.go | 3 +-
|
|
|
b22ff0 |
.../containers/image/v5/docker/tarfile/src.go | 9 +--
|
|
|
b22ff0 |
.../image/v5/image/docker_schema2.go | 4 +-
|
|
|
b22ff0 |
.../containers/image/v5/image/oci.go | 4 +-
|
|
|
b22ff0 |
.../image/v5/internal/iolimits/iolimits.go | 60 +++++++++++++++++++
|
|
|
b22ff0 |
.../image/v5/openshift/openshift.go | 4 +-
|
|
|
b22ff0 |
vendor/modules.txt | 3 +-
|
|
|
b22ff0 |
12 files changed, 89 insertions(+), 21 deletions(-)
|
|
|
b22ff0 |
create mode 100644 vendor/github.com/containers/image/v5/internal/iolimits/iolimits.go
|
|
|
b22ff0 |
|
|
|
b22ff0 |
diff --git a/go.mod b/go.mod
|
|
|
b22ff0 |
index 684b00ff5..b94792238 100644
|
|
|
b22ff0 |
--- a/go.mod
|
|
|
b22ff0 |
+++ b/go.mod
|
|
|
b22ff0 |
@@ -5,7 +5,7 @@ go 1.12
|
|
|
b22ff0 |
require (
|
|
|
b22ff0 |
github.com/blang/semver v3.5.0+incompatible // indirect
|
|
|
b22ff0 |
github.com/containernetworking/cni v0.7.1
|
|
|
b22ff0 |
- github.com/containers/image/v5 v5.0.0
|
|
|
b22ff0 |
+ github.com/containers/image/v5 v5.0.1-0.20200205124631-82291c45f2b0
|
|
|
b22ff0 |
github.com/containers/storage v1.14.0
|
|
|
b22ff0 |
github.com/cyphar/filepath-securejoin v0.2.2
|
|
|
b22ff0 |
github.com/docker/distribution v2.7.1+incompatible
|
|
|
b22ff0 |
diff --git a/go.sum b/go.sum
|
|
|
b22ff0 |
index 1cce3ff7e..ef8729952 100644
|
|
|
b22ff0 |
--- a/go.sum
|
|
|
b22ff0 |
+++ b/go.sum
|
|
|
b22ff0 |
@@ -54,6 +54,8 @@ github.com/containers/image/v4 v4.0.1 h1:idNGHChj0Pyv3vLrxul2oSVMZLeFqpoq3CjLeVg
|
|
|
b22ff0 |
github.com/containers/image/v4 v4.0.1/go.mod h1:0ASJH1YgJiX/eqFZObqepgsvIA4XjCgpyfwn9pDGafA=
|
|
|
b22ff0 |
github.com/containers/image/v5 v5.0.0 h1:arnXgbt1ucsC/ndtSpiQY87rA0UjhF+/xQnPzqdBDn4=
|
|
|
b22ff0 |
github.com/containers/image/v5 v5.0.0/go.mod h1:MgiLzCfIeo8lrHi+4Lb8HP+rh513sm0Mlk6RrhjFOLY=
|
|
|
b22ff0 |
+github.com/containers/image/v5 v5.0.1-0.20200205124631-82291c45f2b0 h1:iV4aHKRoPcHp5BISsuiPMyaCjGJfLKp/FUMAG1NeqvE=
|
|
|
b22ff0 |
+github.com/containers/image/v5 v5.0.1-0.20200205124631-82291c45f2b0/go.mod h1:MgiLzCfIeo8lrHi+4Lb8HP+rh513sm0Mlk6RrhjFOLY=
|
|
|
b22ff0 |
github.com/containers/libtrust v0.0.0-20190913040956-14b96171aa3b h1:Q8ePgVfHDplZ7U33NwHZkrVELsZP5fYj9pM5WBZB2GE=
|
|
|
b22ff0 |
github.com/containers/libtrust v0.0.0-20190913040956-14b96171aa3b/go.mod h1:9rfv8iPl1ZP7aqh9YA68wnZv2NUDbXdcdPHVz0pFbPY=
|
|
|
b22ff0 |
github.com/containers/storage v1.13.4 h1:j0bBaJDKbUHtAW1MXPFnwXJtqcH+foWeuXK1YaBV5GA=
|
|
|
b22ff0 |
diff --git a/vendor/github.com/containers/image/v5/docker/docker_client.go b/vendor/github.com/containers/image/v5/docker/docker_client.go
|
|
|
b22ff0 |
index 0b012c703..bff077a40 100644
|
|
|
b22ff0 |
--- a/vendor/github.com/containers/image/v5/docker/docker_client.go
|
|
|
b22ff0 |
+++ b/vendor/github.com/containers/image/v5/docker/docker_client.go
|
|
|
b22ff0 |
@@ -6,7 +6,6 @@ import (
|
|
|
b22ff0 |
"encoding/json"
|
|
|
b22ff0 |
"fmt"
|
|
|
b22ff0 |
"io"
|
|
|
b22ff0 |
- "io/ioutil"
|
|
|
b22ff0 |
"net/http"
|
|
|
b22ff0 |
"net/url"
|
|
|
b22ff0 |
"os"
|
|
|
b22ff0 |
@@ -17,6 +16,7 @@ import (
|
|
|
b22ff0 |
"time"
|
|
|
b22ff0 |
|
|
|
b22ff0 |
"github.com/containers/image/v5/docker/reference"
|
|
|
b22ff0 |
+ "github.com/containers/image/v5/internal/iolimits"
|
|
|
b22ff0 |
"github.com/containers/image/v5/pkg/docker/config"
|
|
|
b22ff0 |
"github.com/containers/image/v5/pkg/sysregistriesv2"
|
|
|
b22ff0 |
"github.com/containers/image/v5/pkg/tlsclientconfig"
|
|
|
b22ff0 |
@@ -597,7 +597,7 @@ func (c *dockerClient) getBearerToken(ctx context.Context, challenge challenge,
|
|
|
b22ff0 |
default:
|
|
|
b22ff0 |
return nil, errors.Errorf("unexpected http code: %d (%s), URL: %s", res.StatusCode, http.StatusText(res.StatusCode), authReq.URL)
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
- tokenBlob, err := ioutil.ReadAll(res.Body)
|
|
|
b22ff0 |
+ tokenBlob, err := iolimits.ReadAtMost(res.Body, iolimits.MaxAuthTokenBodySize)
|
|
|
b22ff0 |
if err != nil {
|
|
|
b22ff0 |
return nil, err
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
@@ -690,7 +690,7 @@ func (c *dockerClient) getExtensionsSignatures(ctx context.Context, ref dockerRe
|
|
|
b22ff0 |
return nil, errors.Wrapf(clientLib.HandleErrorResponse(res), "Error downloading signatures for %s in %s", manifestDigest, ref.ref.Name())
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
|
|
|
b22ff0 |
- body, err := ioutil.ReadAll(res.Body)
|
|
|
b22ff0 |
+ body, err := iolimits.ReadAtMost(res.Body, iolimits.MaxSignatureListBodySize)
|
|
|
b22ff0 |
if err != nil {
|
|
|
b22ff0 |
return nil, err
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
diff --git a/vendor/github.com/containers/image/v5/docker/docker_image_dest.go b/vendor/github.com/containers/image/v5/docker/docker_image_dest.go
|
|
|
b22ff0 |
index 417d97aec..ce8a1f357 100644
|
|
|
b22ff0 |
--- a/vendor/github.com/containers/image/v5/docker/docker_image_dest.go
|
|
|
b22ff0 |
+++ b/vendor/github.com/containers/image/v5/docker/docker_image_dest.go
|
|
|
b22ff0 |
@@ -15,6 +15,7 @@ import (
|
|
|
b22ff0 |
"strings"
|
|
|
b22ff0 |
|
|
|
b22ff0 |
"github.com/containers/image/v5/docker/reference"
|
|
|
b22ff0 |
+ "github.com/containers/image/v5/internal/iolimits"
|
|
|
b22ff0 |
"github.com/containers/image/v5/manifest"
|
|
|
b22ff0 |
"github.com/containers/image/v5/pkg/blobinfocache/none"
|
|
|
b22ff0 |
"github.com/containers/image/v5/types"
|
|
|
b22ff0 |
@@ -620,7 +621,7 @@ sigExists:
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
defer res.Body.Close()
|
|
|
b22ff0 |
if res.StatusCode != http.StatusCreated {
|
|
|
b22ff0 |
- body, err := ioutil.ReadAll(res.Body)
|
|
|
b22ff0 |
+ body, err := iolimits.ReadAtMost(res.Body, iolimits.MaxErrorBodySize)
|
|
|
b22ff0 |
if err == nil {
|
|
|
b22ff0 |
logrus.Debugf("Error body %s", string(body))
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
diff --git a/vendor/github.com/containers/image/v5/docker/docker_image_src.go b/vendor/github.com/containers/image/v5/docker/docker_image_src.go
|
|
|
b22ff0 |
index 35beb30e5..5436d9b7d 100644
|
|
|
b22ff0 |
--- a/vendor/github.com/containers/image/v5/docker/docker_image_src.go
|
|
|
b22ff0 |
+++ b/vendor/github.com/containers/image/v5/docker/docker_image_src.go
|
|
|
b22ff0 |
@@ -12,6 +12,7 @@ import (
|
|
|
b22ff0 |
"strconv"
|
|
|
b22ff0 |
|
|
|
b22ff0 |
"github.com/containers/image/v5/docker/reference"
|
|
|
b22ff0 |
+ "github.com/containers/image/v5/internal/iolimits"
|
|
|
b22ff0 |
"github.com/containers/image/v5/manifest"
|
|
|
b22ff0 |
"github.com/containers/image/v5/pkg/sysregistriesv2"
|
|
|
b22ff0 |
"github.com/containers/image/v5/types"
|
|
|
b22ff0 |
@@ -156,7 +157,8 @@ func (s *dockerImageSource) fetchManifest(ctx context.Context, tagOrDigest strin
|
|
|
b22ff0 |
if res.StatusCode != http.StatusOK {
|
|
|
b22ff0 |
return nil, "", errors.Wrapf(client.HandleErrorResponse(res), "Error reading manifest %s in %s", tagOrDigest, s.ref.ref.Name())
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
- manblob, err := ioutil.ReadAll(res.Body)
|
|
|
b22ff0 |
+
|
|
|
b22ff0 |
+ manblob, err := iolimits.ReadAtMost(res.Body, iolimits.MaxManifestBodySize)
|
|
|
b22ff0 |
if err != nil {
|
|
|
b22ff0 |
return nil, "", err
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
@@ -342,7 +344,7 @@ func (s *dockerImageSource) getOneSignature(ctx context.Context, url *url.URL) (
|
|
|
b22ff0 |
} else if res.StatusCode != http.StatusOK {
|
|
|
b22ff0 |
return nil, false, errors.Errorf("Error reading signature from %s: status %d (%s)", url.String(), res.StatusCode, http.StatusText(res.StatusCode))
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
- sig, err := ioutil.ReadAll(res.Body)
|
|
|
b22ff0 |
+ sig, err := iolimits.ReadAtMost(res.Body, iolimits.MaxSignatureBodySize)
|
|
|
b22ff0 |
if err != nil {
|
|
|
b22ff0 |
return nil, false, err
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
@@ -401,7 +403,7 @@ func deleteImage(ctx context.Context, sys *types.SystemContext, ref dockerRefere
|
|
|
b22ff0 |
return err
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
defer get.Body.Close()
|
|
|
b22ff0 |
- manifestBody, err := ioutil.ReadAll(get.Body)
|
|
|
b22ff0 |
+ manifestBody, err := iolimits.ReadAtMost(get.Body, iolimits.MaxManifestBodySize)
|
|
|
b22ff0 |
if err != nil {
|
|
|
b22ff0 |
return err
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
@@ -424,7 +426,7 @@ func deleteImage(ctx context.Context, sys *types.SystemContext, ref dockerRefere
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
defer delete.Body.Close()
|
|
|
b22ff0 |
|
|
|
b22ff0 |
- body, err := ioutil.ReadAll(delete.Body)
|
|
|
b22ff0 |
+ body, err := iolimits.ReadAtMost(delete.Body, iolimits.MaxErrorBodySize)
|
|
|
b22ff0 |
if err != nil {
|
|
|
b22ff0 |
return err
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
diff --git a/vendor/github.com/containers/image/v5/docker/tarfile/dest.go b/vendor/github.com/containers/image/v5/docker/tarfile/dest.go
|
|
|
b22ff0 |
index b02c60bb3..9748ca112 100644
|
|
|
b22ff0 |
--- a/vendor/github.com/containers/image/v5/docker/tarfile/dest.go
|
|
|
b22ff0 |
+++ b/vendor/github.com/containers/image/v5/docker/tarfile/dest.go
|
|
|
b22ff0 |
@@ -13,6 +13,7 @@ import (
|
|
|
b22ff0 |
"time"
|
|
|
b22ff0 |
|
|
|
b22ff0 |
"github.com/containers/image/v5/docker/reference"
|
|
|
b22ff0 |
+ "github.com/containers/image/v5/internal/iolimits"
|
|
|
b22ff0 |
"github.com/containers/image/v5/internal/tmpdir"
|
|
|
b22ff0 |
"github.com/containers/image/v5/manifest"
|
|
|
b22ff0 |
"github.com/containers/image/v5/types"
|
|
|
b22ff0 |
@@ -135,7 +136,7 @@ func (d *Destination) PutBlob(ctx context.Context, stream io.Reader, inputInfo t
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
|
|
|
b22ff0 |
if isConfig {
|
|
|
b22ff0 |
- buf, err := ioutil.ReadAll(stream)
|
|
|
b22ff0 |
+ buf, err := iolimits.ReadAtMost(stream, iolimits.MaxConfigBodySize)
|
|
|
b22ff0 |
if err != nil {
|
|
|
b22ff0 |
return types.BlobInfo{}, errors.Wrap(err, "Error reading Config file stream")
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
diff --git a/vendor/github.com/containers/image/v5/docker/tarfile/src.go b/vendor/github.com/containers/image/v5/docker/tarfile/src.go
|
|
|
b22ff0 |
index ad0a3d2cb..bbf604da6 100644
|
|
|
b22ff0 |
--- a/vendor/github.com/containers/image/v5/docker/tarfile/src.go
|
|
|
b22ff0 |
+++ b/vendor/github.com/containers/image/v5/docker/tarfile/src.go
|
|
|
b22ff0 |
@@ -11,6 +11,7 @@ import (
|
|
|
b22ff0 |
"path"
|
|
|
b22ff0 |
"sync"
|
|
|
b22ff0 |
|
|
|
b22ff0 |
+ "github.com/containers/image/v5/internal/iolimits"
|
|
|
b22ff0 |
"github.com/containers/image/v5/internal/tmpdir"
|
|
|
b22ff0 |
"github.com/containers/image/v5/manifest"
|
|
|
b22ff0 |
"github.com/containers/image/v5/pkg/compression"
|
|
|
b22ff0 |
@@ -187,13 +188,13 @@ func findTarComponent(inputFile io.Reader, path string) (*tar.Reader, *tar.Heade
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
|
|
|
b22ff0 |
// readTarComponent returns full contents of componentPath.
|
|
|
b22ff0 |
-func (s *Source) readTarComponent(path string) ([]byte, error) {
|
|
|
b22ff0 |
+func (s *Source) readTarComponent(path string, limit int) ([]byte, error) {
|
|
|
b22ff0 |
file, err := s.openTarComponent(path)
|
|
|
b22ff0 |
if err != nil {
|
|
|
b22ff0 |
return nil, errors.Wrapf(err, "Error loading tar component %s", path)
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
defer file.Close()
|
|
|
b22ff0 |
- bytes, err := ioutil.ReadAll(file)
|
|
|
b22ff0 |
+ bytes, err := iolimits.ReadAtMost(file, limit)
|
|
|
b22ff0 |
if err != nil {
|
|
|
b22ff0 |
return nil, err
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
@@ -224,7 +225,7 @@ func (s *Source) ensureCachedDataIsPresentPrivate() error {
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
|
|
|
b22ff0 |
// Read and parse config.
|
|
|
b22ff0 |
- configBytes, err := s.readTarComponent(tarManifest[0].Config)
|
|
|
b22ff0 |
+ configBytes, err := s.readTarComponent(tarManifest[0].Config, iolimits.MaxConfigBodySize)
|
|
|
b22ff0 |
if err != nil {
|
|
|
b22ff0 |
return err
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
@@ -250,7 +251,7 @@ func (s *Source) ensureCachedDataIsPresentPrivate() error {
|
|
|
b22ff0 |
// loadTarManifest loads and decodes the manifest.json.
|
|
|
b22ff0 |
func (s *Source) loadTarManifest() ([]ManifestItem, error) {
|
|
|
b22ff0 |
// FIXME? Do we need to deal with the legacy format?
|
|
|
b22ff0 |
- bytes, err := s.readTarComponent(manifestFileName)
|
|
|
b22ff0 |
+ bytes, err := s.readTarComponent(manifestFileName, iolimits.MaxTarFileManifestSize)
|
|
|
b22ff0 |
if err != nil {
|
|
|
b22ff0 |
return nil, err
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
diff --git a/vendor/github.com/containers/image/v5/image/docker_schema2.go b/vendor/github.com/containers/image/v5/image/docker_schema2.go
|
|
|
b22ff0 |
index 254c13f78..29c5047d7 100644
|
|
|
b22ff0 |
--- a/vendor/github.com/containers/image/v5/image/docker_schema2.go
|
|
|
b22ff0 |
+++ b/vendor/github.com/containers/image/v5/image/docker_schema2.go
|
|
|
b22ff0 |
@@ -7,10 +7,10 @@ import (
|
|
|
b22ff0 |
"encoding/hex"
|
|
|
b22ff0 |
"encoding/json"
|
|
|
b22ff0 |
"fmt"
|
|
|
b22ff0 |
- "io/ioutil"
|
|
|
b22ff0 |
"strings"
|
|
|
b22ff0 |
|
|
|
b22ff0 |
"github.com/containers/image/v5/docker/reference"
|
|
|
b22ff0 |
+ "github.com/containers/image/v5/internal/iolimits"
|
|
|
b22ff0 |
"github.com/containers/image/v5/manifest"
|
|
|
b22ff0 |
"github.com/containers/image/v5/pkg/blobinfocache/none"
|
|
|
b22ff0 |
"github.com/containers/image/v5/types"
|
|
|
b22ff0 |
@@ -102,7 +102,7 @@ func (m *manifestSchema2) ConfigBlob(ctx context.Context) ([]byte, error) {
|
|
|
b22ff0 |
return nil, err
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
defer stream.Close()
|
|
|
b22ff0 |
- blob, err := ioutil.ReadAll(stream)
|
|
|
b22ff0 |
+ blob, err := iolimits.ReadAtMost(stream, iolimits.MaxConfigBodySize)
|
|
|
b22ff0 |
if err != nil {
|
|
|
b22ff0 |
return nil, err
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
diff --git a/vendor/github.com/containers/image/v5/image/oci.go b/vendor/github.com/containers/image/v5/image/oci.go
|
|
|
b22ff0 |
index 18a38d463..406da262f 100644
|
|
|
b22ff0 |
--- a/vendor/github.com/containers/image/v5/image/oci.go
|
|
|
b22ff0 |
+++ b/vendor/github.com/containers/image/v5/image/oci.go
|
|
|
b22ff0 |
@@ -4,9 +4,9 @@ import (
|
|
|
b22ff0 |
"context"
|
|
|
b22ff0 |
"encoding/json"
|
|
|
b22ff0 |
"fmt"
|
|
|
b22ff0 |
- "io/ioutil"
|
|
|
b22ff0 |
|
|
|
b22ff0 |
"github.com/containers/image/v5/docker/reference"
|
|
|
b22ff0 |
+ "github.com/containers/image/v5/internal/iolimits"
|
|
|
b22ff0 |
"github.com/containers/image/v5/manifest"
|
|
|
b22ff0 |
"github.com/containers/image/v5/pkg/blobinfocache/none"
|
|
|
b22ff0 |
"github.com/containers/image/v5/types"
|
|
|
b22ff0 |
@@ -67,7 +67,7 @@ func (m *manifestOCI1) ConfigBlob(ctx context.Context) ([]byte, error) {
|
|
|
b22ff0 |
return nil, err
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
defer stream.Close()
|
|
|
b22ff0 |
- blob, err := ioutil.ReadAll(stream)
|
|
|
b22ff0 |
+ blob, err := iolimits.ReadAtMost(stream, iolimits.MaxConfigBodySize)
|
|
|
b22ff0 |
if err != nil {
|
|
|
b22ff0 |
return nil, err
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
diff --git a/vendor/github.com/containers/image/v5/internal/iolimits/iolimits.go b/vendor/github.com/containers/image/v5/internal/iolimits/iolimits.go
|
|
|
b22ff0 |
new file mode 100644
|
|
|
b22ff0 |
index 000000000..3fed1995c
|
|
|
b22ff0 |
--- /dev/null
|
|
|
b22ff0 |
+++ b/vendor/github.com/containers/image/v5/internal/iolimits/iolimits.go
|
|
|
b22ff0 |
@@ -0,0 +1,60 @@
|
|
|
b22ff0 |
+package iolimits
|
|
|
b22ff0 |
+
|
|
|
b22ff0 |
+import (
|
|
|
b22ff0 |
+ "io"
|
|
|
b22ff0 |
+ "io/ioutil"
|
|
|
b22ff0 |
+
|
|
|
b22ff0 |
+ "github.com/pkg/errors"
|
|
|
b22ff0 |
+)
|
|
|
b22ff0 |
+
|
|
|
b22ff0 |
+// All constants below are intended to be used as limits for `ReadAtMost`. The
|
|
|
b22ff0 |
+// immediate use-case for limiting the size of in-memory copied data is to
|
|
|
b22ff0 |
+// protect against OOM DOS attacks as described inCVE-2020-1702. Instead of
|
|
|
b22ff0 |
+// copying data until running out of memory, we error out after hitting the
|
|
|
b22ff0 |
+// specified limit.
|
|
|
b22ff0 |
+const (
|
|
|
b22ff0 |
+ // megaByte denotes one megabyte and is intended to be used as a limit in
|
|
|
b22ff0 |
+ // `ReadAtMost`.
|
|
|
b22ff0 |
+ megaByte = 1 << 20
|
|
|
b22ff0 |
+ // MaxManifestBodySize is the maximum allowed size of a manifest. The limit
|
|
|
b22ff0 |
+ // of 4 MB aligns with the one of a Docker registry:
|
|
|
b22ff0 |
+ // https://github.com/docker/distribution/blob/a8371794149d1d95f1e846744b05c87f2f825e5a/registry/handlers/manifests.go#L30
|
|
|
b22ff0 |
+ MaxManifestBodySize = 4 * megaByte
|
|
|
b22ff0 |
+ // MaxAuthTokenBodySize is the maximum allowed size of an auth token.
|
|
|
b22ff0 |
+ // The limit of 1 MB is considered to be greatly sufficient.
|
|
|
b22ff0 |
+ MaxAuthTokenBodySize = megaByte
|
|
|
b22ff0 |
+ // MaxSignatureListBodySize is the maximum allowed size of a signature list.
|
|
|
b22ff0 |
+ // The limit of 4 MB is considered to be greatly sufficient.
|
|
|
b22ff0 |
+ MaxSignatureListBodySize = 4 * megaByte
|
|
|
b22ff0 |
+ // MaxSignatureBodySize is the maximum allowed size of a signature.
|
|
|
b22ff0 |
+ // The limit of 4 MB is considered to be greatly sufficient.
|
|
|
b22ff0 |
+ MaxSignatureBodySize = 4 * megaByte
|
|
|
b22ff0 |
+ // MaxErrorBodySize is the maximum allowed size of an error-response body.
|
|
|
b22ff0 |
+ // The limit of 1 MB is considered to be greatly sufficient.
|
|
|
b22ff0 |
+ MaxErrorBodySize = megaByte
|
|
|
b22ff0 |
+ // MaxConfigBodySize is the maximum allowed size of a config blob.
|
|
|
b22ff0 |
+ // The limit of 4 MB is considered to be greatly sufficient.
|
|
|
b22ff0 |
+ MaxConfigBodySize = 4 * megaByte
|
|
|
b22ff0 |
+ // MaxOpenShiftStatusBody is the maximum allowed size of an OpenShift status body.
|
|
|
b22ff0 |
+ // The limit of 4 MB is considered to be greatly sufficient.
|
|
|
b22ff0 |
+ MaxOpenShiftStatusBody = 4 * megaByte
|
|
|
b22ff0 |
+ // MaxTarFileManifestSize is the maximum allowed size of a (docker save)-like manifest (which may contain multiple images)
|
|
|
b22ff0 |
+ // The limit of 1 MB is considered to be greatly sufficient.
|
|
|
b22ff0 |
+ MaxTarFileManifestSize = megaByte
|
|
|
b22ff0 |
+)
|
|
|
b22ff0 |
+
|
|
|
b22ff0 |
+// ReadAtMost reads from reader and errors out if the specified limit (in bytes) is exceeded.
|
|
|
b22ff0 |
+func ReadAtMost(reader io.Reader, limit int) ([]byte, error) {
|
|
|
b22ff0 |
+ limitedReader := io.LimitReader(reader, int64(limit+1))
|
|
|
b22ff0 |
+
|
|
|
b22ff0 |
+ res, err := ioutil.ReadAll(limitedReader)
|
|
|
b22ff0 |
+ if err != nil {
|
|
|
b22ff0 |
+ return nil, err
|
|
|
b22ff0 |
+ }
|
|
|
b22ff0 |
+
|
|
|
b22ff0 |
+ if len(res) > limit {
|
|
|
b22ff0 |
+ return nil, errors.Errorf("exceeded maximum allowed size of %d bytes", limit)
|
|
|
b22ff0 |
+ }
|
|
|
b22ff0 |
+
|
|
|
b22ff0 |
+ return res, nil
|
|
|
b22ff0 |
+}
|
|
|
b22ff0 |
diff --git a/vendor/github.com/containers/image/v5/openshift/openshift.go b/vendor/github.com/containers/image/v5/openshift/openshift.go
|
|
|
b22ff0 |
index 016de4803..c37e1b751 100644
|
|
|
b22ff0 |
--- a/vendor/github.com/containers/image/v5/openshift/openshift.go
|
|
|
b22ff0 |
+++ b/vendor/github.com/containers/image/v5/openshift/openshift.go
|
|
|
b22ff0 |
@@ -7,13 +7,13 @@ import (
|
|
|
b22ff0 |
"encoding/json"
|
|
|
b22ff0 |
"fmt"
|
|
|
b22ff0 |
"io"
|
|
|
b22ff0 |
- "io/ioutil"
|
|
|
b22ff0 |
"net/http"
|
|
|
b22ff0 |
"net/url"
|
|
|
b22ff0 |
"strings"
|
|
|
b22ff0 |
|
|
|
b22ff0 |
"github.com/containers/image/v5/docker"
|
|
|
b22ff0 |
"github.com/containers/image/v5/docker/reference"
|
|
|
b22ff0 |
+ "github.com/containers/image/v5/internal/iolimits"
|
|
|
b22ff0 |
"github.com/containers/image/v5/manifest"
|
|
|
b22ff0 |
"github.com/containers/image/v5/types"
|
|
|
b22ff0 |
"github.com/containers/image/v5/version"
|
|
|
b22ff0 |
@@ -102,7 +102,7 @@ func (c *openshiftClient) doRequest(ctx context.Context, method, path string, re
|
|
|
b22ff0 |
return nil, err
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
defer res.Body.Close()
|
|
|
b22ff0 |
- body, err := ioutil.ReadAll(res.Body)
|
|
|
b22ff0 |
+ body, err := iolimits.ReadAtMost(res.Body, iolimits.MaxOpenShiftStatusBody)
|
|
|
b22ff0 |
if err != nil {
|
|
|
b22ff0 |
return nil, err
|
|
|
b22ff0 |
}
|
|
|
b22ff0 |
diff --git a/vendor/modules.txt b/vendor/modules.txt
|
|
|
b22ff0 |
index 840dae067..3f72f3f34 100644
|
|
|
b22ff0 |
--- a/vendor/modules.txt
|
|
|
b22ff0 |
+++ b/vendor/modules.txt
|
|
|
b22ff0 |
@@ -48,7 +48,7 @@ github.com/containernetworking/cni/pkg/types
|
|
|
b22ff0 |
github.com/containernetworking/cni/pkg/types/020
|
|
|
b22ff0 |
github.com/containernetworking/cni/pkg/types/current
|
|
|
b22ff0 |
github.com/containernetworking/cni/pkg/version
|
|
|
b22ff0 |
-# github.com/containers/image/v5 v5.0.0
|
|
|
b22ff0 |
+# github.com/containers/image/v5 v5.0.1-0.20200205124631-82291c45f2b0
|
|
|
b22ff0 |
github.com/containers/image/v5/copy
|
|
|
b22ff0 |
github.com/containers/image/v5/directory
|
|
|
b22ff0 |
github.com/containers/image/v5/directory/explicitfilepath
|
|
|
b22ff0 |
@@ -59,6 +59,7 @@ github.com/containers/image/v5/docker/policyconfiguration
|
|
|
b22ff0 |
github.com/containers/image/v5/docker/reference
|
|
|
b22ff0 |
github.com/containers/image/v5/docker/tarfile
|
|
|
b22ff0 |
github.com/containers/image/v5/image
|
|
|
b22ff0 |
+github.com/containers/image/v5/internal/iolimits
|
|
|
b22ff0 |
github.com/containers/image/v5/internal/pkg/keyctl
|
|
|
b22ff0 |
github.com/containers/image/v5/internal/tmpdir
|
|
|
b22ff0 |
github.com/containers/image/v5/manifest
|