-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refuse to process manifest / manifest list data that could possibly be interpreted as two different manifest formats, because differences in how those ambiguities are resolved could be used to bypass image verification or review mechanisms. Fixes CVE-2021-41190 / GHSA-77vh-xpmg-72qh . Signed-off-by: Miloslav Trmač <mitr@redhat.com>
- Loading branch information
Showing
12 changed files
with
294 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package manifest | ||
|
||
import ( | ||
"io/ioutil" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestSchema2ListFromManifest(t *testing.T) { | ||
validManifest, err := ioutil.ReadFile(filepath.Join("fixtures", "v2list.manifest.json")) | ||
require.NoError(t, err) | ||
|
||
parser := func(m []byte) error { | ||
_, err := Schema2ListFromManifest(m) | ||
return err | ||
} | ||
// Schema mismatch is rejected | ||
testManifestFixturesAreRejected(t, parser, []string{ | ||
"schema2-to-schema1-by-docker.json", | ||
"v2s2.manifest.json", | ||
"ociv1.manifest.json", | ||
// Not "ociv1.image.index.json" yet, without validating mediaType the two are too similar to tell the difference. | ||
}) | ||
// Extra fields are rejected | ||
testValidManifestWithExtraFieldsIsRejected(t, parser, validManifest, []string{"config", "fsLayers", "history", "layers"}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package manifest | ||
|
||
import ( | ||
"io/ioutil" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestOCI1IndexFromManifest(t *testing.T) { | ||
validManifest, err := ioutil.ReadFile(filepath.Join("fixtures", "ociv1.image.index.json")) | ||
require.NoError(t, err) | ||
|
||
parser := func(m []byte) error { | ||
_, err := OCI1IndexFromManifest(m) | ||
return err | ||
} | ||
// Schema mismatch is rejected | ||
testManifestFixturesAreRejected(t, parser, []string{ | ||
"schema2-to-schema1-by-docker.json", | ||
"v2s2.manifest.json", | ||
// Not "v2list.manifest.json" yet, without mediaType the two are too similar to tell the difference. | ||
"ociv1.manifest.json", | ||
}) | ||
// Extra fields are rejected | ||
testValidManifestWithExtraFieldsIsRejected(t, parser, validManifest, []string{"config", "fsLayers", "history", "layers"}) | ||
} |
Oops, something went wrong.