Our Audit of Homebrew
Trail of Bits audited Homebrew, identifying non-critical security issues like sandbox escapes and unauthorized modifications. Risks in CI/CD workflows could expose credentials, highlighting the need for improved security practices.
Read original articleTrail of Bits conducted an audit of Homebrew, focusing on its core components and CI/CD processes. The audit revealed several non-critical security issues that could potentially allow attackers to execute code unexpectedly, undermining Homebrew's integrity. Key findings included vulnerabilities that could enable sandbox escapes, privilege escalations, and unauthorized modifications to binary builds. Specific issues identified were related to string injection, the use of a collision-prone hash function, and the ability to load formulae from remote URLs without proper validation.
The audit also highlighted risks within Homebrew's CI/CD workflows, such as the use of pull_request_target triggers that could allow third-party code execution in the context of Homebrew's repository, leading to credential exposure or tampering. Additionally, unsanitized inputs in workflow_dispatch could facilitate shell injection, allowing less-privileged users to gain higher privileges.
Overall, while Homebrew's CI/CD is effective, it relies on complex patterns that may be misused by lower-privileged insiders. The audit emphasized the challenges of securing a package management ecosystem that inherently executes third-party code. The findings underscore the importance of maintaining robust security practices to protect the integrity of Homebrew and its extensive user base, which relies on it for critical software installations. The audit was sponsored by the Open Tech Fund, aiming to enhance the security of essential internet infrastructure.
Related
3M iOS and macOS apps were exposed to potent supply-chain attacks
Vulnerabilities in CocoaPods server exposed 3 million apps to supply-chain attacks for a decade. Flaws allowed hackers to inject malicious code, compromising sensitive user data. Developers urged to prioritize security measures.
'Almost every Apple device' vulnerable to CocoaPods
Security researchers found vulnerabilities in CocoaPods, allowing malicious code insertion and remote code execution. Pod owners were at risk of a zero-click takeover. CocoaPods issued patches, emphasizing the need for secure software development practices.
After 15 years, the maintainer of Homebrew plans to make a living
Mike McQuaid plans to transition Homebrew into a sustainable project after 15 years, co-founding Workbrew to support enterprise needs while maintaining Homebrew's community-driven, open-source principles.
Workbrew
Workbrew is a management tool for organizations using Homebrew, offering features for monitoring macOS devices, enhancing security, and streamlining onboarding. It supports remote control and compliance, available via subscription.
After 15 years, the maintainer of Homebrew plans to make a living
Mike McQuaid, after 15 years with Homebrew, has founded Workbrew to address corporate IT needs while maintaining open-source values. Homebrew will remain community-driven as it evolves.
- Users express appreciation for the audit but raise questions about the adequacy of vetting processes for new packages and potential security risks.
- There are discussions about the implications of using GitHub URLs for ad-hoc packages, with concerns about malicious contributions.
- Some commenters suggest that the audit findings may also apply to other package managers like MacPorts and Nix.
- Several users advocate for better funding and support for Homebrew from Apple, highlighting the value it brings to the ecosystem.
- There is a general sentiment that security should not be compromised for convenience in package management.
If you're having trouble finding the audit itself (it's linked indirectly), I'm linking a copy here as well[1].
[1]: https://github.com/trailofbits/publications/blob/eb9344f2261...
I know it’s not the focus of a code review like this, but I’m interested to hear your views on the general supply chain lifecycle problems inherent to open-source package management platforms. Principally, are vetting processes appropriate to ensure that new formulas refer to the correct source? How does the user gain confidence that their brew update is still referencing a trusted source? What happens when a domain is taken over? How quickly can the team respond to untrusted sources from formulas?
I know these aren’t all Homebrew problems to solve, but they’re important ecosystem considerations.
(These problems also exist in the winget and choco platforms, but less so in commercially supported repos like apt and yum. For me, and many other admins, they are a major concern when it comes to the Windows Store.)
Edit: lastly, in case the homebrew team are watching: an npm-style vulnerability notice would be awesome
In any case, I'd be interested in seeing an audit of Nix on Mac OS. Especially if there is a flaw in how `nix develop` and related commands work.
Homebrew maintainers mostly do not sign commits/packages, do not sign reviews/merges, do not verify author/reviewer sigs at compile time, do not reproduce builds in separately controlled CI, do not enforce hardware 2FA on Github.
Every user of brew is only as secure as whichever of hundreds of brew maintainers has the worst opsec today.
Also since dependabot automatically makes commits, you could get a malicious commit into an external project you control, wait for dependabot to make a commit to homebrew to upgrade it, then merge it yourself (as becoming a homebrew maintainer has almost no vetting, just fix a few easy bugs)
You could also just take over one of the expired email domains of a maintainer and send a password reset email to yourself and take over an account of someone on vacation or hiatus.
Can likely get thousands of companies compromised before anyone notices.
Honestly I would never allow Brew on any company machines I have authority over. It is giving hundreds of randos, (and anyone that takes advantage of their poor opsec) the ability to execute any code on user systems.
Major Linux package managers do not go nearly far enough with things like review signing, but most at -least- do author-level package signing, human review, and independent reproduction for most packages.
Given how many high value targets like corporate sysadmins allow brew on their computers, Brew is on track to overshadow Crowdstrike any day now for most harm caused by insufficient supply chain management.
Homebrew is great and the formulae are maintained really well but the simplicity of PKGBUILDS, the fast syncing, and lack of cognitive burden of recalling multiple arguments/flags for package managers make me wish pacman just worked on macs.
Edit: Oh, it's "Trail Of Bits - homeBREW". But probably still yes.
> Homebrew's maintainers are […long list of names…] William Woodruff […]
[1]: https://github.com/Homebrew/brew
Is there any reason this is not mentioned in the blog post? I don’t think it would make a difference, but just to clarify things.
It abstracts Nix in a way you don't have to know or learn anything about the Nix language.
I wrote a few words on how I use it instead of Homebrew [1].
[1] https://mootoday.com/blog/i-replaced-homebrew-with-devbox
They pointed me to an example program that would break if not run this way: Facebook's Watchman[1].
It bizarrely (to me) has hard coded paths compiled into it, which force you to run it from specific directories.
Would love to understand what's going on here and why you would ever make software work this way. I feel I'm missing a fairly obvious Chesterton's Fence.
[0]: https://github.com/orgs/Homebrew/discussions/5371
[1]: https://facebook.github.io/watchman/docs/install#prebuilt-bi...
> Since 2012, Trail of Bits has helped secure some of the world’s most targeted organizations and products. We combine high-end security research with a real world attacker mentality to reduce risk and fortify code.
It's interesting that I don't see any analysis referencing OpenBSD (either as a product or as an alternative to something else they have done research on).Related
3M iOS and macOS apps were exposed to potent supply-chain attacks
Vulnerabilities in CocoaPods server exposed 3 million apps to supply-chain attacks for a decade. Flaws allowed hackers to inject malicious code, compromising sensitive user data. Developers urged to prioritize security measures.
'Almost every Apple device' vulnerable to CocoaPods
Security researchers found vulnerabilities in CocoaPods, allowing malicious code insertion and remote code execution. Pod owners were at risk of a zero-click takeover. CocoaPods issued patches, emphasizing the need for secure software development practices.
After 15 years, the maintainer of Homebrew plans to make a living
Mike McQuaid plans to transition Homebrew into a sustainable project after 15 years, co-founding Workbrew to support enterprise needs while maintaining Homebrew's community-driven, open-source principles.
Workbrew
Workbrew is a management tool for organizations using Homebrew, offering features for monitoring macOS devices, enhancing security, and streamlining onboarding. It supports remote control and compliance, available via subscription.
After 15 years, the maintainer of Homebrew plans to make a living
Mike McQuaid, after 15 years with Homebrew, has founded Workbrew to address corporate IT needs while maintaining open-source values. Homebrew will remain community-driven as it evolves.