|
|
e1f920 |
From 840e7dad513b86f454573ad415701c0199f78d30 Mon Sep 17 00:00:00 2001
|
|
|
e1f920 |
From: TomSweeneyRedHat <tsweeney@redhat.com>
|
|
|
e1f920 |
Date: Tue, 24 Mar 2020 20:10:22 -0400
|
|
|
e1f920 |
Subject: [PATCH] Fix potential CVE in tarfile w/ symlink
|
|
|
e1f920 |
|
|
|
e1f920 |
Stealing @nalind 's workaround to avoid refetching
|
|
|
e1f920 |
content after a file read failure. Under the right
|
|
|
e1f920 |
circumstances that could be a symlink to a file meant
|
|
|
e1f920 |
to overwrite a good file with bad data.
|
|
|
e1f920 |
|
|
|
e1f920 |
Testing:
|
|
|
e1f920 |
```
|
|
|
e1f920 |
goodstuff
|
|
|
e1f920 |
|
|
|
e1f920 |
[1] 14901
|
|
|
e1f920 |
|
|
|
e1f920 |
127.0.0.1 - - [24/Mar/2020 20:15:50] "GET / HTTP/1.1" 200 -
|
|
|
e1f920 |
127.0.0.1 - - [24/Mar/2020 20:15:50] "GET / HTTP/1.1" 200 -
|
|
|
e1f920 |
no FROM statement found
|
|
|
e1f920 |
|
|
|
e1f920 |
goodstuff
|
|
|
e1f920 |
```
|
|
|
e1f920 |
|
|
|
e1f920 |
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
|
|
|
e1f920 |
---
|
|
|
e1f920 |
imagebuildah/util.go | 5 +++--
|
|
|
e1f920 |
1 file changed, 3 insertions(+), 2 deletions(-)
|
|
|
e1f920 |
|
|
|
e1f920 |
diff -up a/imagebuildah/util.go.CVE-2020-10696 b/imagebuildah/util.go
|
|
|
e1f920 |
--- a/imagebuildah/util.go.CVE-2020-10696
|
|
|
e1f920 |
+++ b/imagebuildah/util.go
|
|
|
e1f920 |
@@ -12,6 +12,7 @@ import (
|
|
|
e1f920 |
|
|
|
e1f920 |
"github.com/containers/buildah"
|
|
|
e1f920 |
"github.com/containers/storage/pkg/chrootarchive"
|
|
|
e1f920 |
+ "github.com/containers/storage/pkg/ioutils"
|
|
|
e1f920 |
"github.com/pkg/errors"
|
|
|
e1f920 |
"github.com/sirupsen/logrus"
|
|
|
e1f920 |
)
|
|
|
e1f920 |
@@ -47,7 +48,7 @@ func downloadToDirectory(url, dir string
|
|
|
e1f920 |
}
|
|
|
e1f920 |
dockerfile := filepath.Join(dir, "Dockerfile")
|
|
|
e1f920 |
// Assume this is a Dockerfile
|
|
|
e1f920 |
- if err := ioutil.WriteFile(dockerfile, body, 0600); err != nil {
|
|
|
e1f920 |
+ if err := ioutils.AtomicWriteFile(dockerfile, body, 0600); err != nil {
|
|
|
e1f920 |
return errors.Wrapf(err, "Failed to write %q to %q", url, dockerfile)
|
|
|
e1f920 |
}
|
|
|
e1f920 |
}
|