Skip to content
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

Make sure rustup.sh is safe from truncation errors #19168

Closed
erickt opened this issue Nov 21, 2014 · 1 comment · Fixed by #19170
Closed

Make sure rustup.sh is safe from truncation errors #19168

erickt opened this issue Nov 21, 2014 · 1 comment · Fixed by #19170
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@erickt
Copy link
Contributor

erickt commented Nov 21, 2014

Someone on hacker news pointed out that bad things could potentially happen if the running of curl https://static.rust-lang.org/rust.sh | sh gets truncated on a bad line. We should audit the code to make sure that can't happen. Maybe we could write the actual rustup.sh and verify it with a checksum before we execute it?

@huonw
Copy link
Member

huonw commented Nov 21, 2014

This would theoretically be resolved by putting the whole script into a function that then gets executed at the very end, so nothing happens until that is reached, e.g.

f() {
    rm -Rf "${TMP_DIR}"
    need_ok "failed to remove temporary installation directory"

    mkdir -p "${TMP_DIR}"
    need_ok "failed to create create temporary installation directory"

    ...
    rm -Rf "${TMP_DIR}"
    need_ok "couldn't rm temporary installation directory"
}

f

(Tagging as E-easy due to this, I believe the file is available in src/etc.)

@huonw huonw added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Nov 21, 2014
erickt added a commit to erickt/rust that referenced this issue Dec 3, 2014
This closes rust-lang#19168. It's possible that if the downloading of `rustup.sh`
is interrupted, bad things could happen, such as running a naked
"rm -rf /" instead of "rm -rf /path/to/tmpdir". This wraps rustup.sh's
functionality in a function that gets called at the last time that should
protect us from these truncation errors.
bors added a commit that referenced this issue Dec 4, 2014
This closes #19168.

Please be careful reviewing this since this gets used all over the place. I've tested all the options and everything appears to be working though.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants