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