-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
support sha check in download, require during Pkg.build #26683
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
Conversation
…n Pkg.build contexts
Is really too difficult?
Or the SHA.jl package that we have as a standard library?
Should be in a different PR imo. |
|
Whoops, I didn't notice that we have an SHA package in the stdlib! I can switch to using this if that is preferred. Though I don't know if it is possible for Base to depend on a stdlib package without moving most of the package into Base? Calling mbedtls is < 30 lines of code here, which is a lot more lightweight than moving all of SHA.jl into Base. Doing the SHA as a separate step makes it impossible to enforce that |
Sure, but I don't think we should be doing that. |
Why not? The |
|
It seems that using something like Anyway, I think having the build-thing as a separate PR would make it easier to focus on the implementation of the check here, and whether it should warn during build time in the other PR: |
|
The Updating BinDeps is a separate issue. It looks like there are about 3 dozen registered packages that use |
|
@KristofferC, you still haven't explained your objection to enforcing hash validation for |
The number of lines doesn't really matter, it is the effect it has and the type of discussion it will produce, no? If you feel this should be enforced for registered packages then adding that as a rule to METADATA seems more appropriate. |
|
Okay, so what is your objection to "the effect it has and the type of discussion it will produce"? Why would it be better to enforce this only for registered packages, rather than everywhere? I feel like you keep giving meta-objections. My reason for combining that change into this PR is precisely for the discussion — it is impossible to evaluate the merits of including a |
|
Being able to conveniently check a hash in the download function is convenient in itself, but it is true that it is very easy already.
Because maybe I don't care about the hash in my own package. Maybe I have my own registry of packages that only download from my local server. Maybe I want to use some other hash than SHA512. A security choice like this has to be adopted (and enforced) on the community level. Saying that the combination of exactly build-time and exactly the Base |
We don't actually require MbedTLS currently, we support using libgit2 with the system's SSL library. See JuliaLang/MbedTLS.jl#123 (comment). |
You are going too far. Requiring some cryptographically strong hash validation (in the context where binaries/source are most often downloaded) is more secure than requiring no hash (in any context). Additional hash types can always be added later just by adding additional
I don't know if three dozen is "very few". Also, the next step is to deprecate |
Yes, and that is done by making that a rule for the community that provides those packages, e.g. METADATA or your own company's registry (which might have even stronger security requirements).
The next step is to move to BinaryBuilder.jl (which does do hash checking). |
The goal here is not to prevent people from intentionally circumventing security measures. That is very very hard to stop, even with "community rules". The goal is to provide automatic notification for a common security issue coupled with an easy fix (not "rewrite your package's build system from scratch"). It's not fair to describe this as doing "absolutely zero for security."
No. Switching to BinaryBuilder may be a long-term goal, but for security concerns you need to have an easy upgrade path that requires minimal changes to packages. Otherwise it will be years (if ever) before some packages go to the trouble of upgrading. |
|
If you want to convince the BinDeps maintainers that they should print a warning if they are downloading things without checking a hash and add a hash field then sure go ahead with that. We should not be printing a warning like this from Base when we have no idea about the context We could make a |
Being called from Can you give any real examples of a build script that is calling |
|
In the context of JuliaPackaging/WinRPM.jl#144 I'd really like to see the most simple |
|
@phlavenk, why would it be an undue burden for WinRPM users to provide an SHA hash to check, even it happens to be on Windows Server? Why would you be downloading huge scientific images for processing during |
|
I was originally in favor of this but I've changed my mind. It's fairly arbitrary to support just one hash function for this and it feels like an ad hoc attempt to fix a larger problem. Instead, I feel that we should move all package and artifact delivery to a solution where we serve them ourselves from servers that we control that support content-addressed URLs, e.g. There are many benefits to this:
Having one particular hashing mechanism built into the |
|
@stevengj My point was only to keep With the case of huge file download - I missed the idea and thought it is mandatory to always calculate SHA. Opt-in in this PR is the good behavior. |
|
@StefanKarpinski, it still seems like you'd want to verify the SHA after download, for end-to-end security. |
Yes, of course. But that would be part of the mechanism for acquiring a content-addressed artifact, not for downloading an arbitrary URL. Also, baking in support for one hashing function seems weird. |
It sounds better if you spell it "providing a reasonable default" rather than "baking in". We can easily design the API to make it more hash-agnostic. e.g. would you be happier with |
|
I think we should have |
|
Triage consensus is against this. |
|
Okay, will close. Without a deprecation, though, probably it will take a long time for the existing download calls to be updated to use a hash and/or a secure server, unless there is some femtocleaner-like automatic-update tool. |
This PR adds an optional
sha="...."keyword argument todownload(vialibmbedtls), to make it easier for people to add SHA-256 validation to downloads. Furthermore, a deprecation warning is emitted for non-validateddownloadcalls duringPkg.buildorPkg3.build.Fixes #26680. (Does not affect #17958, which is about the Julia build itself.)
I intentionally kept the SHA hashing functionality here minimal; a more full-featured SHA interface is exposed by packages like MbedTLS.jl (update: or SHA.jl).
(It's all well and good to say that people should use BinaryProvider or whatever, but I think it would be better to build security directly into the
downloadfunction to make sure that it has a wider reach.)Question: are there other contexts in which we should deprecate non-validated
downloadcalls? Module loading, for instance? Would be very easy to add this constraint to precompiling orPkg.test, for example, if that is desired.