Summary
The fix for GHSA-6689-q779-c33m introduced a regression. The commit immediately before it removed both .git/hooks and .gitconfig from the Homebrew directory before running privileged Git commands. The fix commit dropped .gitconfig from that removal and added a core.hooksPath=/dev/null wrapper instead. core.hooksPath does not cover configuration keys that name a program, so a .gitconfig planted by the prefix owner still yields root command execution during a signed .pkg install.
Details
Both commits touch package/scripts/postinstall:
9421ad1399 2026-04-25 pkg: clean Homebrew git state
+ rm -rf "${homebrew_directory}/.git/hooks" "${homebrew_directory}/.gitconfig"
d7ac00a722 2026-04-26 pkg: disable installer Git hooks <- the GHSA-6689 fix
- rm -rf "${homebrew_directory}/.git/hooks" "${homebrew_directory}/.gitconfig"
+ rm -rf "${homebrew_directory}/.git/hooks"
+ git_no_hooks() { git -c core.hooksPath=/dev/null "$@"; }
At main the ordering is:
:39 export HOME="${homebrew_directory}", so Git reads ${prefix}/.gitconfig as its global config
:47 rm -rf "${homebrew_directory}/.git/hooks" — hooks only
:48 git config --global --add safe.directory ... — appends to the attacker's file if one is present
:49–:52 four privileged Git calls (tag --list, checkout --force, reset --hard, clean -f -d)
:53 rm -f "${homebrew_directory}/.gitconfig" — after the Git calls, so too late
The /usr/local/Homebrew path repeats the same pattern at :64–:69.
core.hooksPath=/dev/null blocks .git/hooks, but not core.fsmonitor, core.pager, core.editor, core.sshCommand, diff.external or the other keys whose values Git executes.
The regression guard added by the same fix, .github/workflows/release.yml:149 ("Check installer Git safety"), asserts only that privileged Git calls go through git_no_hooks. It has no assertion about .gitconfig, which is why the regression was not caught.
The reporter recommends restoring .gitconfig to the rm -rf that precedes the Git calls, for both paths, and extending that CI check so hooks and config cannot drift apart again. export GIT_CONFIG_GLOBAL=/dev/null would be stronger but conflicts with the script's own use of git config --global --add safe.directory, so it needs a small rework. A tested patch is available on request. Final severity and remediation are the PSRT's to decide.
PoC
Unprivileged, synthetic, temporary directory. Replaying postinstall lines 39–52 against a prefix containing a planted .gitconfig with core.fsmonitor set, on git 2.55.0:
unfixed ordering (main): core.fsmonitor EXECUTED
fixed ordering (branch): no execution
In the real script these commands run as root. The proposed CI assertion was also checked in both directions: it fails on current main, passes on the fixed version, and passes on 9421ad1399 from before the regression, so it would have caught d7ac00a722 at the time.
Impact
A local user who can write the Homebrew prefix — which Homebrew intentionally leaves writable by the install user — obtains command execution as root the next time an administrator or MDM installs or upgrades via the official .pkg. This is the same impact class as the parent advisory, reached through configuration rather than hooks.
Preconditions, stated plainly: it needs the .pkg channel rather than the default installer, an attacker who already owns the prefix, and a later privileged install driven by a different principal. In the ordinary case where an administrator installs for themselves, the beneficiary is someone who could already reach root, so there is no privilege gain. It is realistic in the enterprise and MDM deployments the package exists to serve.
CWE-94 (Improper Control of Generation of Code), CWE-426 (Untrusted Search Path).
AI/LLM use disclosure
This finding was researched with AI/LLM assistance. The reporter verified it against the source and the recorded runs and takes responsibility for it.
- How: an AI agent system (Anthropic Claude, via Claude Code) surfaced the candidate and ran an adversarial verification pass. The reporter then confirmed the git history personally with
git show on both commits, and reproduced the config-execution primitive personally and unprivileged on git 2.55.0, plus the CI-guard behaviour in both directions. Nothing in this advisory is agent-only.
- When: 2026-09-01 to 2026-09-02, against
main 66e8d3d36dc2afbfeaa23182174eef5d4e5bfee8 (brew 6.0.21-10).
- Where: in discovery, in PoC construction, in the fix, and in drafting this write-up.
- Environment: local checkout only, synthetic inputs, temporary directories, nothing run as root, no network access beyond loopback.
Full agent logs and recorded stdout are available to the PSRT on request.
Summary
The fix for GHSA-6689-q779-c33m introduced a regression. The commit immediately before it removed both
.git/hooksand.gitconfigfrom the Homebrew directory before running privileged Git commands. The fix commit dropped.gitconfigfrom that removal and added acore.hooksPath=/dev/nullwrapper instead.core.hooksPathdoes not cover configuration keys that name a program, so a.gitconfigplanted by the prefix owner still yields root command execution during a signed.pkginstall.Details
Both commits touch
package/scripts/postinstall:At
mainthe ordering is::39export HOME="${homebrew_directory}", so Git reads${prefix}/.gitconfigas its global config:47rm -rf "${homebrew_directory}/.git/hooks"— hooks only:48git config --global --add safe.directory ...— appends to the attacker's file if one is present:49–:52four privileged Git calls (tag --list,checkout --force,reset --hard,clean -f -d):53rm -f "${homebrew_directory}/.gitconfig"— after the Git calls, so too lateThe
/usr/local/Homebrewpath repeats the same pattern at:64–:69.core.hooksPath=/dev/nullblocks.git/hooks, but notcore.fsmonitor,core.pager,core.editor,core.sshCommand,diff.externalor the other keys whose values Git executes.The regression guard added by the same fix,
.github/workflows/release.yml:149("Check installer Git safety"), asserts only that privileged Git calls go throughgit_no_hooks. It has no assertion about.gitconfig, which is why the regression was not caught.The reporter recommends restoring
.gitconfigto therm -rfthat precedes the Git calls, for both paths, and extending that CI check so hooks and config cannot drift apart again.export GIT_CONFIG_GLOBAL=/dev/nullwould be stronger but conflicts with the script's own use ofgit config --global --add safe.directory, so it needs a small rework. A tested patch is available on request. Final severity and remediation are the PSRT's to decide.PoC
Unprivileged, synthetic, temporary directory. Replaying
postinstalllines 39–52 against a prefix containing a planted.gitconfigwithcore.fsmonitorset, on git 2.55.0:In the real script these commands run as root. The proposed CI assertion was also checked in both directions: it fails on current
main, passes on the fixed version, and passes on9421ad1399from before the regression, so it would have caughtd7ac00a722at the time.Impact
A local user who can write the Homebrew prefix — which Homebrew intentionally leaves writable by the install user — obtains command execution as root the next time an administrator or MDM installs or upgrades via the official
.pkg. This is the same impact class as the parent advisory, reached through configuration rather than hooks.Preconditions, stated plainly: it needs the
.pkgchannel rather than the default installer, an attacker who already owns the prefix, and a later privileged install driven by a different principal. In the ordinary case where an administrator installs for themselves, the beneficiary is someone who could already reach root, so there is no privilege gain. It is realistic in the enterprise and MDM deployments the package exists to serve.CWE-94 (Improper Control of Generation of Code), CWE-426 (Untrusted Search Path).
AI/LLM use disclosure
This finding was researched with AI/LLM assistance. The reporter verified it against the source and the recorded runs and takes responsibility for it.
git showon both commits, and reproduced the config-execution primitive personally and unprivileged on git 2.55.0, plus the CI-guard behaviour in both directions. Nothing in this advisory is agent-only.main66e8d3d36dc2afbfeaa23182174eef5d4e5bfee8(brew 6.0.21-10).Full agent logs and recorded stdout are available to the PSRT on request.