archive: add link breakout checks and tests#1208
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1208 +/- ##
=======================================
Coverage 28.09% 28.09%
=======================================
Files 28 28
Lines 2833 2833
=======================================
Hits 796 796
Misses 1888 1888
Partials 149 149Continue to review full report at Codecov.
|
There was a problem hiding this comment.
I assumed he meant bounding as in a bounding box that won't allow links outside of root
There was a problem hiding this comment.
Probably, bounding, as we are adding a limitation, rather than associating to context.
There was a problem hiding this comment.
Perhaps, this argument order needs to be reversed, as this is operating as a join.
Ensure symlinks cannot be used to breakout of unpack directory. Evaluate absolute symlinks as scoped to unpack directory. Allow symlinks which point outside the root to be created. Scope all resolution of symlinks to the unpack directory. Signed-off-by: Derek McGowan <[email protected]>
|
Updated |
|
LGTM |
Replace cases where a tar specified name is joined to a directory with root path to bound name to path. Signed-off-by: Derek McGowan <[email protected]>
|
@tonistiigi PTAL |
| } | ||
| return walkLinks(root, dir[:len(dir)-1], linksWalked) | ||
| } | ||
| newpath, _, err := walkLink(root, dir, linksWalked) |
There was a problem hiding this comment.
I am not entirely sure how to reach this case, I was matching the cases in EvalSymlinks, it doesn't seem possible though as I would think the previous case would catch this. It does seem appropriate to handle it the same as dir == "" though rather than panic.
|
LGTM |
Ensure symlinks cannot be used to breakout of unpack directory. Evaluate absolute symlinks as scoped to unpack directory. Allow symlinks which point outside the root to be created. Scope all resolution of symlinks to the unpack directory.
Note: The tar writer could be generally useful and split out into a separate tar test or tar creation package. Also the
rootPathmethod might be good as part of the continuity path driver since it is designed to act as a secure way to dochroot-likefilepath.Join.