Skip to content

Regression in the GHSA-6689-q779-c33m fix: pkg `postinstall` reads a prefix-owned `.gitconfig` as root, and `core.hooksPath` does not cover config-specified programs

Moderate
MikeMcQuaid published GHSA-hqpg-hjr9-c7j8 Sep 5, 2026

Package

postinstall (shell)

Affected versions

>= 5.1.8

Patched versions

6.0.12

Description

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.

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v4 base metrics

Exploitability Metrics
Attack Vector Local
Attack Complexity Low
Attack Requirements Present
Privileges Required Low
User interaction Passive
Vulnerable System Impact Metrics
Confidentiality High
Integrity High
Availability High
Subsequent System Impact Metrics
Confidentiality None
Integrity None
Availability None

CVSS v4 base metrics

Exploitability Metrics
Attack Vector: This metric reflects the context by which vulnerability exploitation is possible. This metric value (and consequently the resulting severity) will be larger the more remote (logically, and physically) an attacker can be in order to exploit the vulnerable system. The assumption is that the number of potential attackers for a vulnerability that could be exploited from across a network is larger than the number of potential attackers that could exploit a vulnerability requiring physical access to a device, and therefore warrants a greater severity.
Attack Complexity: This metric captures measurable actions that must be taken by the attacker to actively evade or circumvent existing built-in security-enhancing conditions in order to obtain a working exploit. These are conditions whose primary purpose is to increase security and/or increase exploit engineering complexity. A vulnerability exploitable without a target-specific variable has a lower complexity than a vulnerability that would require non-trivial customization. This metric is meant to capture security mechanisms utilized by the vulnerable system.
Attack Requirements: This metric captures the prerequisite deployment and execution conditions or variables of the vulnerable system that enable the attack. These differ from security-enhancing techniques/technologies (ref Attack Complexity) as the primary purpose of these conditions is not to explicitly mitigate attacks, but rather, emerge naturally as a consequence of the deployment and execution of the vulnerable system.
Privileges Required: This metric describes the level of privileges an attacker must possess prior to successfully exploiting the vulnerability. The method by which the attacker obtains privileged credentials prior to the attack (e.g., free trial accounts), is outside the scope of this metric. Generally, self-service provisioned accounts do not constitute a privilege requirement if the attacker can grant themselves privileges as part of the attack.
User interaction: This metric captures the requirement for a human user, other than the attacker, to participate in the successful compromise of the vulnerable system. This metric determines whether the vulnerability can be exploited solely at the will of the attacker, or whether a separate user (or user-initiated process) must participate in some manner.
Vulnerable System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the VULNERABLE SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the VULNERABLE SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the VULNERABLE SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
Subsequent System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the SUBSEQUENT SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the SUBSEQUENT SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the SUBSEQUENT SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N

CVE ID

No known CVE

Weaknesses

No CWEs

Credits