-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Have a security researcher audit Homebrew #18036
Comments
There are a few different topics that come to mind - from code signing and verification in a given Formula to transport security with SSL pinning. Basically any Formula has the ability to execute arbitrary code on the user's machine, so any insecurely fetched code on the system will allow the local network to pop a shell - so for an hg repo without https, nearly instant code exec. I pushed a fix for the golang hg --HEAD Formula for this exact reason, actually. I think there are lots of things to discuss - I'd also suggest that the primary authors of Homebrew look at the Update Framework, https://www.cs.arizona.edu/stork/packagemanagersecurity/ and https://www.cs.arizona.edu/people/jsamuel/papers/samuel-cappos-login-feb09.pdf as well as other related work by Justin Cappos. |
Good points, thanks. I'll check these links out. Any thoughts around our binary packages would be good too (we'll roll out a whole bunch more post-Kickstarter). The arbitrary code execution is one of the reasons we (unlike many package managers) don't use root. |
Where might I read about the binary package plans? |
I was looking at the well know one line install on the home page: Also - I think that it is majorly bad news that inside that there is a curl that uses |
The binary package plans are probably most public on the Kickstarter. Outside that you can see the implementation of a binary install by doing |
Curl also has an option to pin to a specific CA ( |
@MikeMcQuaid I'd probably spin up a vm for each build from Jenkins - when someone gets root on your build machine, the outcome will be bad news. I'd probably also try to approach building the way that Gitian suggests - to try to find out when build machines go bad and to catch it before Homebrew users get pwned. |
I think the |
We removed it from the one-line install on the homepage so it could be done in the script too. |
I think the effectiveness of that defense is overstated in the case of Homebrew. There seems to be a weak underlying assumption in Homebrew that it is going to be used on a Mac with a single user who is an administrator (see the recommended installation instructions & rationale, the fact that formulas like Postgres install under the current user even though they're in a shared prefix, etc.). However, in that case, avoiding root does not really buy you much. A compromised Homebrew can do anything to the current user: steal his data, plant malware (even in places like I think the single-user assumption should be removed. I run as a non-administrator user, personally, and I have previously raised the issue of shared Macs, lab machines etc.. But the security considerations are important, too. In my opinion, the ideal configuration would have Homebrew running as its own user, so that the system will actually prevent it from writing stuff outside the prefix. This means that, if there are two admins on a machine, they will run homebrew as a single Of course, programs installed by homebrew will still mostly run as whatever user calls them, so this is not a universal protection, but it adds security to the installation process while giving us proper multi-user support. |
The curl on the home page is still using the less specific curl command, isn't it? |
Yep but I've showed the necessary people this thread so just closing to decrease our "open" count rather than saying nothing else will be done :) |
That's not how issue tracking works. iPhone�$B$+$iAw?.�(B 02/mar/2013 03:34�$B!"�(BMike McQuaid [email protected] �$B$N%a%C%;!<%8�(B:
|
The main brew.sh website still does not have an HTTPS certificate (I raised this issue last year). I would like to again volunteer to help purchase one and set it up for you, if possible. The reason is that very important people at Google, TOR, and other organizations are using the awesome homebrew project. But, the initial installation instructions are displayed over the website using HTTP, without a security certificate. This means that if the FIVE EYES or other adversaries wanted to compromise the machine of someone first installing homebrew on their computer, the HTTP stream could be modified to change the instructions displayed to the user. Perhaps the FIVE EYES would alter the github URL to something similar but under their control like... ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew2/install/master/install)" ...instead of the actual real location like... ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" The change may be so slight like that so many people don't notice. Of course, only high valued targets would like be exploited this way. But, the impact could be devastating. If it were a Google employee or TOR core developer working on a major open source project, the developer would be compromised and easily able to be manipulated into inserting a backdoor into the software they are developing, without ever even knowing they got compromised. Adding a HTTPS certificate can make that harder, although still not fool-proof, as the FIVE EYES can easily create CA certificates that work in the browser and then DNS redirect the victim to a doppelganger site under their control, again with the same compromising outcome. However, HTTPS pinning might make this less feasible. Updating this conversation, I see @ioerror has raised similar concerns. Last year we discussed over email that you were potentially going to implement CloudFlare in front of http://brew.sh. We should also disable basic HTTP and / or ensure HSTS with CA preload pinning, so that even the first connect to brew.sh domain will be encrypted. Let me know if any progress was made toward that goal or if you need assistance. I also audited all the homebrew recipes for lack of sha256 / sha1 checks, etc and only found ~10 that were concerning. Like was pointed out earlier, plaintext hg, svn, cvs, and git were to blame there. Also realize that since all this code is open source, well positioned and well funded entities may also have the ability to create HASH COLLISIONS on the open source code binary builds, if they understand the build parameters / hardware / etc. This is why Tor signs their builds rather than using just a hash, since advanced attackers can take the open source code, implement the same build process, and brute force a hash that runs bad code, but still hashes to the same sum value. This is more an issue with SHA1 currently than SHA256 of course, but moving all recipes to SHA256 / SHA512 / SHA-3 -- or SKEIN -- at least and GPG checking (if supported by the release team) is preferable... I'd like to help, so let me know! :) |
We looked into this, extensively. There's a whole broad discussion in an issue some months ago. Essentially, we can't do it and remain on Github pages. So then there's hosting costs, and configuration, and SSL costs to deal with, and it adds up quickly. Maintaining a server to serve a single website is a pretty tedious maintenance process, from experience.
Meh. The entire CA system is screwed. Superfish, Fake certificates issued to Google domains that remain in place for weeks, an individual/group was issued a cert covering Microsoft Software Updates despite not proving they worked for Microsoft, not to mention huge CAs controlled essentially by countries' governments.
Cloudflare blocked us on this avenue.
There's nothing provably completely broken about SHA1, yet, but we've recently switched to SHA256 by default for all new formulae and are working on migrating existing ones regardless. All bottles produced by Homebrew from last week forwards are SHA256 checked rather than SHA1.
Also recently discussed, at least for Homebrew's binary packages, and potentially long-term for others as well. There's ongoing discussion about Homebrew publishing a GPG key for security communications and signing all the binary packages with it. The usage of the system OpenSSL has also been completely deprecated in the past ~6 months, and formula authors get big, ugly red warnings to switch to Homebrew's OpenSSL if a formulae taps OpenSSL. Homebrew also removed SSLv2 from OpenSSL, and discussions were had on removing SSLv3 once Debian Jessie lands stable and does the same. SSLv2 and SSLv3 were both removed from PolarSSL. Progress is being made on a lot of issues, but I'll shut up, the maintainers grow tired of hearing my virtual voice enough as it is 😅. |
@kristian-hermansen I'm working on getting SSL on the homepage but the combination of GitHub Pages, CloudFlare and DNSimple are making it more complicated than I want it to be. I'm not convinced the homepage is particularly exploitable as people who care about security aren't going to be piping in random Ruby scripts without inspecting the URL. I don't think GPG is a silver bullet as it relies on the secrecy of the private key. Your checksums exploit requires not just brute-forcing SHA-1 (or, as @DomT4 pointed out, increasingly SHA-256) and additionally hacking servers and replacing their checksums. The most helpful thing you can do is submit pull-requests to improve things. I've personal biases against members of the security member whose "help" in the past has involved telling us what we are doing wrong without writing any code to fix the problems. As a result I'm not really interested in having lots of discussion about this: let's work together on PRs. Thanks! |
Does homebrew still download some packages through insecure connection?
Also, can sourceforge be considered as trusted source after its drama with account stealing? |
Yes.
If you wish to avoid this please set
Unless they have found vulnerabilities in |
Hello me from 8 years ago! Just noticed this issue is linked in a few prominent places so wanted to chime in with a note that Homebrew was audited in 2020 and published a blog post and results about this in 2022. At the time of writing (July 2023): another security audit has begun. |
@ioerror said he would look into it.
Edit: hello me from 8 years ago! Just noticed this issue is linked in a few prominent places so wanted to chime in with a note that Homebrew was audited in 2020 and published a blog post and results about this in 2022. At the time of writing (July 2023): another security audit has begun.
The text was updated successfully, but these errors were encountered: