Skip to content

archive: add link breakout checks and tests#1208

Merged
estesp merged 2 commits intocontainerd:masterfrom
dmcgowan:tar-test
Jul 19, 2017
Merged

archive: add link breakout checks and tests#1208
estesp merged 2 commits intocontainerd:masterfrom
dmcgowan:tar-test

Conversation

@dmcgowan
Copy link
Copy Markdown
Member

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 rootPath method might be good as part of the continuity path driver since it is designed to act as a secure way to do chroot-like filepath.Join.

@dmcgowan dmcgowan changed the title Add link breakout checks and tests archive: add link breakout checks and tests Jul 18, 2017
@codecov-io
Copy link
Copy Markdown

codecov-io commented Jul 18, 2017

Codecov Report

Merging #1208 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1208   +/-   ##
=======================================
  Coverage   28.09%   28.09%           
=======================================
  Files          28       28           
  Lines        2833     2833           
=======================================
  Hits          796      796           
  Misses       1888     1888           
  Partials      149      149

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 805654a...6079245. Read the comment docs.

Comment thread archive/path.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

binding?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assumed he meant bounding as in a bounding box that won't allow links outside of root

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, bounding, as we are adding a limitation, rather than associating to context.

Comment thread archive/path_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a mkdirall?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is

Comment thread archive/path.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps, this argument order needs to be reversed, as this is operating as a join.

Comment thread archive/path.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

root, path here, as well.

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]>
@dmcgowan
Copy link
Copy Markdown
Member Author

Updated

@stevvooe
Copy link
Copy Markdown
Member

LGTM

@stevvooe stevvooe added this to the containerd alpha1 milestone Jul 19, 2017
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]>
@stevvooe
Copy link
Copy Markdown
Member

@tonistiigi PTAL

Comment thread archive/path.go
}
return walkLinks(root, dir[:len(dir)-1], linksWalked)
}
newpath, _, err := walkLink(root, dir, linksWalked)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is this case reached?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tonistiigi
Copy link
Copy Markdown
Member

LGTM

Copy link
Copy Markdown
Member

@estesp estesp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@estesp estesp merged commit 0600753 into containerd:master Jul 19, 2017
@dmcgowan dmcgowan deleted the tar-test branch September 10, 2019 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants