-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
Enable GPG verification for Casks. #4120
Conversation
@@ -18,7 +18,7 @@ def initialize(cask, downloaded_path) | |||
|
|||
def verify | |||
return unless self.class.me?(cask) | |||
ohai "Verifying checksum for Cask #{cask}" | |||
ohai "Verifying SHA256 checksum for Cask “#{cask}”." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using left and right double quotes isn't consistent with other cask messages.
end | ||
|
||
def verify | ||
return unless available? && cask.gpg.signature != :embedded | ||
unless available? | ||
ohai "GPG is not installed, skipping verification of GPG signature for Cask “#{cask}”." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'gnupg' formula is not installed
|
||
@command.run!("gpg", | ||
@command.run!(Formula["gnupg"].opt_bin/"gpg", | ||
args: ["--verify", sig, downloaded_path], | ||
print_stdout: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this printing to stdout.
d100a49
to
47f370f
Compare
df18de0
to
01f161e
Compare
Should we be adding keys to the users default keyring? |
We aren't auto-trusting the keys, so I think it's fine to use the default keyring. |
Yeah, but the only way to avoid having keys added to the default keyring is to uninstall Homebrew/Cask doesn't modify "user config" type files (usually ignoring them or overriding them with our own config) so it feels weird that we're kind of doing the opposite with this. |
01f161e
to
072dc0d
Compare
Ok, changed it to use a custom |
Tried this in a clean VM, the error is reproducible with all the Casks I've tried so far.
|
GPG has to be somehow initialized, I added |
end | ||
homebrew_keyring_args = ["--no-default-keyring", "--keyring", homebrew_keyring_path] | ||
|
||
# Ensure GPG intallation is initialized. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
Does the embedded gpg verification need to be updated to use the |
d65c16f
to
e9a670c
Compare
Having |
e9a670c
to
4a20a4c
Compare
Let's do that if it actually becomes an issue. |
c89f523
to
f0d8ba7
Compare
f0d8ba7
to
c89f523
Compare
c89f523
to
103b93e
Compare
Just as a heads up: I probably won’t get around to reviewing this until July 8. |
103b93e
to
9020880
Compare
9020880
to
0cd3a9c
Compare
@reitermarkus What's the latest here? |
Waiting on a review from @claui since she seems to know some things about GPG. |
A number of issues I see with the approach that is proposed here (and already partially implemented before this PR):
With all that in mind, I tend to lean towards what @vitorgalvao said in Homebrew/homebrew-cask#48862 (comment) on the topic of package authenticity:
In fact, I like this quote a lot because it basically summarizes all of node-forward/discussions#29. So my suggestion would be to put this PR on hold, at least until someone comes up with an acceptable solution to the package authentication problem, UX-wise. But that’s only my two cents. Maybe I’m entirely wrong, and there’s a reasonably good compromise hidden somewhere that I’ve missed. Thoughts/opinions? |
@claui Good points. Personally I think GPG is only a good solution for things like this if users are going to manage what they trust and what they don't explicitly. I don't think that really works when the granularity is per-package.
For formula: between using SHA-256 package checksums, requiring 2FA for anyone who can merge commits and a CDN that doesn't allow republishing old packages: I think that's as good as you can get. Personally I think SHA256 for Casks is as good as you're going to get in terms of a balance between security and usability (and even then they may need disabled by default on some casks where there's an unversioned upstream tarball but you could make it easier for users to submit a PR to update this). |
or the artifact could be mirrored to a CDN with a versioned url |
Regarding casks, I see SHA256 (and this has been my view for as long as I can remember) as being a feature that provides an integrity check after a download, not a security feature. Relying on SHA256 for security (for casks) is ineffective and takes a huge toll on usability, due to the amount of legitimate in-place changes developers make upstream. Users and contributors alike are understandably frustrated at the process of verifying SHA-only changes that can make casks unusable for weeks. Homebrew/homebrew-cask#48862 (comment) already makes all these points. In my view, the best we’re going to get for casks is to get a way to quarantine downloads (efforts already in progress) and let macOS’ security model take over. |
👍 |
Then I'd say let's remove GPG support completely. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
brew style
with your changes locally?brew tests
with your changes locally?