Require trust for automatic tap migration installs - #23662
Merged
Conversation
Contributor
|
Thanks for your pull request. This has been closed because it appears to be missing the pull request template, perhaps because this was written by an AI not a human. We require humans to read and fill in these templates. Please edit this pull request to fill in the current pull request template. This workflow will reopen this pull request automatically once the template is complete. Do not open a new pull request for this. |
MikeMcQuaid
approved these changes
Aug 26, 2026
MikeMcQuaid
left a comment
Member
There was a problem hiding this comment.
Great idea and implementation. Makes a lot of sense. Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Require the exact formula or cask migration target to be trusted before brew update installs it automatically. Untrusted targets are now skipped with explicit brew trust and brew install instructions.
Why
An installed but untrusted third-party tap can provide
tap_migrations.json. For deleted casks, Reporter#migrate_tap_migration checks only whether Caskroom/ exists. It does not verify that the installed cask originated from the tap being updated.A compromised dormant tap can therefore:
brew installpasses fully qualified names to Trust.trust_fully_qualified_items!, so the new formula becomes trusted before its Ruby is evaluated.A plausible scenario that could happen is:
So the user installed something (that is not yet compromised), and uninstalled it after a while (
abcis still not compromised). The main problem here is that uninstallingabconly removes its item-specific trust but leavesabc/toolstapped. If that dormant tap is compromised months later, it can target an unrelated installed cask such as:The victim then only needs to run this any point in time:
and now is compromised.
Reproduction
I prepared a dependency-free Python PoC as gist.
Fix
Both automatic migration-install branches now require
Homebrew::Trust.trusted?for the exact destination type and fully qualified name. Official taps and explicitly trusted targets continue to migrate automatically. Untrusted targets receive commands for completing the migration deliberately. A test case covers refusal of an untrusted migration target.Verification
brew benchmarkresults.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?I used no AI to assist with investigating the issue, developing and testing the fix, and drafting this description. I reviewed the resulting changes, reproduced the vulnerability and fix, and ran
brew lgtm --onlinesuccessfully. I will answer maintainer questions and review comments myself without AI/LLM.