Skip to content

Conversation

alexcrichton
Copy link
Member

Otherwise they could accidentally overwrite other packages!

alexcrichton and others added 3 commits September 13, 2017 17:45
Ideally we'd just stream to S3 but they're all small enough (< 10MB) and we'll
want to perform post-validation on them so we need the contents.
For now the only verification check we perform is that all entries in the
tarball are contained in the correct path, which is a directory namespaced by
the name of a crate and the version of a crate. Historical Cargo implementations
don't verify this and could cause packages to overwrite one another's contents
if custom tarballs were uploaded to crates.io
// upload a tarball that contains both `foo-0.1.0/` source code as well
// as `bar-0.1.0/` source code, and this could overwrite other crates in
// the registry!
if !entry.path()?.starts_with(&prefix) {
Copy link

Choose a reason for hiding this comment

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

Do you need a trailing '/', or is this looking at a whole directory entry?

Copy link

Choose a reason for hiding this comment

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

Can you add checks if any of the entries are: '..' or non-file/directories?

Copy link
Member Author

Choose a reason for hiding this comment

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

The trailing / isn't necessary due to the way Path works, entries like .. are tested in tar itself, and non-file/directory entries are a feature, not a bug, but have extra handling in tar.

@carols10cents carols10cents merged commit 00c6c96 into rust-lang:master Sep 14, 2017
alexcrichton added a commit to alexcrichton/crates.io that referenced this pull request Sep 14, 2017
bors-voyager bot added a commit that referenced this pull request Sep 14, 2017
1055: Fix HTTP tests and test bad tarballs are rejected r=carols10cents

Continuation of #1054
bors-voyager bot added a commit that referenced this pull request Sep 14, 2017
1055: Fix HTTP tests and test bad tarballs are rejected r=carols10cents

Continuation of #1054
bors added a commit to rust-lang/cargo that referenced this pull request Sep 17, 2017
Verify tarballs don't extract into other directories

Continuation of rust-lang/crates.io#1054 except support on the Cargo side of things
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.

3 participants