Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

change untar to use unpack instead of unpack_in #19216

Merged
merged 9 commits into from
Aug 18, 2021

Conversation

jeffwashington
Copy link
Contributor

@jeffwashington jeffwashington commented Aug 12, 2021

Problem

tar crate changed its behavior as part of a security update. An internal call in unpack_in call was changed from:
fs::create_dir_all(...) // does NOT return error if path already exists
to
fs::create_dir(...) // returns error if path already exists

The goal was to fix a security hole where items could be unpacked in folders outside the destination folder.

There are possibly concerns with how we unpack to several configurable directories, which may be on different drives completely. That would seem to also trigger an error.

This pr switches from using unpack_in to unpack so that we control sanitizing.

#19175
tar crate change
PR by @CriesofCarrots against tar crate

Summary of Changes

Closes #19230

@jeffwashington
Copy link
Contributor Author

@mvines @CriesofCarrots

@jeffwashington jeffwashington changed the title change untar to use unpack instead of unpack_in wip: change untar to use unpack instead of unpack_in Aug 12, 2021
@jeffwashington jeffwashington force-pushed the untar branch 3 times, most recently from 7366e5c to 434100c Compare August 16, 2021 13:29
@codecov
Copy link

codecov bot commented Aug 16, 2021

Codecov Report

Merging #19216 (e6972c7) into master (f8f8c19) will decrease coverage by 0.0%.
The diff coverage is 75.0%.

@@            Coverage Diff            @@
##           master   #19216     +/-   ##
=========================================
- Coverage    82.9%    82.9%   -0.1%     
=========================================
  Files         455      455             
  Lines      129382   129417     +35     
=========================================
+ Hits       107322   107346     +24     
- Misses      22060    22071     +11     

@jeffwashington
Copy link
Contributor Author

@CriesofCarrots
I haven't cleaned this up yet, but it passes. I guess I should rebase it off the new security update.

dependabot bot and others added 2 commits August 16, 2021 13:12
Bumps [tar](https://github.com/alexcrichton/tar-rs) from 0.4.35 to 0.4.37.
- [Release notes](https://github.com/alexcrichton/tar-rs/releases)
- [Commits](alexcrichton/tar-rs@0.4.35...0.4.37)

---
updated-dependencies:
- dependency-name: tar
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
@jeffwashington
Copy link
Contributor Author

#19216

@CriesofCarrots
Copy link
Contributor

Passed ✅ Is it ready for a close look?

@jeffwashington jeffwashington marked this pull request as ready for review August 17, 2021 03:36
@jeffwashington
Copy link
Contributor Author

I'm not confident in the sanitization partial port that I did. This has been a side project. Having someone else look at it would be swell.

@jeffwashington
Copy link
Contributor Author

@jeffwashington jeffwashington changed the title wip: change untar to use unpack instead of unpack_in change untar to use unpack instead of unpack_in Aug 17, 2021
@jeffwashington jeffwashington requested a review from mvines August 17, 2021 15:32
CriesofCarrots
CriesofCarrots previously approved these changes Aug 17, 2021
Copy link
Contributor

@CriesofCarrots CriesofCarrots left a comment

Choose a reason for hiding this comment

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

Thanks for taking this @jeffwashington . Implementation looks good to me; one nit and a couple ideas about more explicit documentation

Co-authored-by: Tyera Eulberg <[email protected]>
@mergify mergify bot dismissed CriesofCarrots’s stale review August 17, 2021 16:20

Pull request has been modified.

Copy link
Contributor

@t-nelson t-nelson left a comment

Choose a reason for hiding this comment

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

lgtm!

Copy link
Contributor

@CriesofCarrots CriesofCarrots left a comment

Choose a reason for hiding this comment

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

:shipit:

@jeffwashington jeffwashington merged commit 89a31ff into solana-labs:master Aug 18, 2021
mergify bot pushed a commit that referenced this pull request Aug 20, 2021
* change untar to use unpack instead of unpack_in

* hacky, but maybe passes tests

* chore: bump tar from 0.4.35 to 0.4.37

Bumps [tar](https://github.com/alexcrichton/tar-rs) from 0.4.35 to 0.4.37.
- [Release notes](https://github.com/alexcrichton/tar-rs/releases)
- [Commits](alexcrichton/tar-rs@0.4.35...0.4.37)

---
updated-dependencies:
- dependency-name: tar
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* [auto-commit] Update all Cargo lock files

* cleanup

* cleanup, add validate_inside_dst

* collapse use

Co-authored-by: Tyera Eulberg <[email protected]>

* delete comment line

* add comments

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot-buildkite <[email protected]>
Co-authored-by: Tyera Eulberg <[email protected]>
(cherry picked from commit 89a31ff)

# Conflicts:
#	Cargo.lock
#	download-utils/Cargo.toml
#	install/Cargo.toml
#	programs/bpf/Cargo.lock
#	runtime/Cargo.toml
#	sdk/cargo-build-bpf/Cargo.toml
mergify bot added a commit that referenced this pull request Aug 20, 2021
…9340)

* change untar to use unpack instead of unpack_in (#19216)

* change untar to use unpack instead of unpack_in

* hacky, but maybe passes tests

* chore: bump tar from 0.4.35 to 0.4.37

Bumps [tar](https://github.com/alexcrichton/tar-rs) from 0.4.35 to 0.4.37.
- [Release notes](https://github.com/alexcrichton/tar-rs/releases)
- [Commits](alexcrichton/tar-rs@0.4.35...0.4.37)

---
updated-dependencies:
- dependency-name: tar
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* [auto-commit] Update all Cargo lock files

* cleanup

* cleanup, add validate_inside_dst

* collapse use

Co-authored-by: Tyera Eulberg <[email protected]>

* delete comment line

* add comments

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot-buildkite <[email protected]>
Co-authored-by: Tyera Eulberg <[email protected]>
(cherry picked from commit 89a31ff)

# Conflicts:
#	Cargo.lock
#	download-utils/Cargo.toml
#	install/Cargo.toml
#	programs/bpf/Cargo.lock
#	runtime/Cargo.toml
#	sdk/cargo-build-bpf/Cargo.toml

* Fix conflicts

Co-authored-by: Jeff Washington (jwash) <[email protected]>
Co-authored-by: Tyera Eulberg <[email protected]>
@brooksprumo brooksprumo mentioned this pull request Aug 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants