-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Pass root to chroot to for chroot Tar/Untar (CVE-2018-15664) #39292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
fyi, I still need to test this (to see if it actually fixes the CVE), but wanted to get this out to there for others to review. |
In my testing this does seem to fix expected part of this vulnerability (copy file to a container). |
dace5ed
to
6cb4c08
Compare
6cb4c08
to
d630c68
Compare
Codecov Report
@@ Coverage Diff @@
## master #39292 +/- ##
=========================================
Coverage ? 36.99%
=========================================
Files ? 612
Lines ? 45553
Branches ? 0
=========================================
Hits ? 16852
Misses ? 26413
Partials ? 2288 |
And now I have added a new command for |
be1219c
to
8978894
Compare
8978894
to
4e524ee
Compare
Ah missing a close, of course. |
From a cursory look, this does look like it should fix the issue. I'll close my PR in favour of this one. Though, we still need quite a few more drastic changes to |
So, seeing some "SUCCESS" on the read script need to figure out why. |
4e524ee
to
2d377c6
Compare
/cc @kolyshkin PTAL |
} | ||
|
||
// UntarUncompressed reads a stream of bytes from `archive`, parses it as a tar archive, | ||
// and unpacks it into the directory at `dest`. | ||
// The archive must be an uncompressed stream. | ||
func UntarUncompressed(tarArchive io.Reader, dest string, options *archive.TarOptions) error { | ||
return untarHandler(tarArchive, dest, options, false) | ||
return untarHandler(tarArchive, dest, options, false, dest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the 5th parameter is the same with 2nd parameter , both dest
. is it by purpose ?
it will make the chroot folder always as "/" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with Untar
-- is there a reason to have the old functions around given that they're broken?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just didn't want to make a bunch of changes to code that isn't affected by this.
In reality there are only a couple of places this is used, I think it's safe to go ahead just change the method signatures rather than introduce a new one.
c23a5dc
to
497dcff
Compare
Ok in my local testing this seems to be working well. Curious what others are seeing. @cyphar I'll push an additional commit which consolidates the Untar stuff to require a root to chroot to. |
Sorry if this isn’t the right place but will this fix be backported to 18.06? |
Docker 18.06 reached EOL, so no, no backport to that version. It will be backported to versions that are still actively maintained (Docker 18.09 and the upcoming 19.03, as well as Docker Enterprise versions (17.06 EE, 18.03 EE, 18.09 EE)) |
@justincormack I will run a test tomorrow morning, but I believe @cpuguy83 mentioned that he was running the symlink attack scripts I published to verify that the patch worked. |
@cyphar yes I believe he did but just wanted you to check too in case they were not exactly the same tests. |
This is useful for preventing CVE-2018-15664 where a malicious container process can take advantage of a race on symlink resolution/sanitization. Before this change chrootarchive would chroot to the destination directory which is attacker controlled. With this patch we always chroot to the container's root which is not attacker controlled. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Previously only unpack operations were supported with chroot. This adds chroot support for packing operations. This prevents potential breakouts when copying data from a container. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
497dcff
to
3029e76
Compare
Added unit tests. |
I believe we are good to go here. |
Hi, @cpuguy83, thank you to provide this fix. |
@panpan0000 all fixed |
@tonistiigi LGTY? |
From my quick testing, this LGTM. |
merging |
This is useful for preventing CVE-2018-15664 where a malicious container
process can take advantage of a race on symlink resolution/sanitization.
Before this change chrootarchive would chroot to the destination
directory which is attacker controlled. With this patch we always chroot
to the container's root which is not attacker controlled.
replaces #39252