Skip to content

Server-supplied git redirect silently retargets a tap's origin to an attacker on a routine brew update (HOMEBREW_ALLOWED_TAPS bypass)

Low
MikeMcQuaid published GHSA-r9gp-p4vv-f93x Jul 4, 2026

Package

brew (homebrew)

Affected versions

commit 1717af5d68

Patched versions

6.0.6

Description

Summary

On a routine brew update, a previously-installed tap whose git remote is plain-HTTP / MITM-able / attacker-influenced can have its persistent origin silently rewritten to an attacker URL, and the same update fetches, pulls, and rebases the tap onto the attacker's commits — with no user action and no prompt. The HOMEBREW_ALLOWED_TAPS allowlist is not re-validated against the redirected remote, so it does not prevent this. Formula/cask code is then executed from the attacker's content on subsequent operations.

Details

When git emits redirecting to <url> to stderr during a tap fetch, Homebrew rewrites the tap's origin:

  • Library/Homebrew/cmd/update.sh (~:923) writes <tap_path>\t<redirected_remote> to .git/REDIRECTED_REMOTES.
  • Library/Homebrew/cmd/update-report.rb:79 consumes it and calls tap.apply_redirected_remote! (.git/REDIRECTED_REMOTES is unlinked at :92 after applying).
  • Library/Homebrew/tap.rb:574: safe_system "git", "-C", path, "remote", "set-url", "origin", redirected_remote — the rewrite, with no re-check.

allowed_by_env? / forbidden_by_env? are evaluated once, against the requested remote, before the clone/fetch — never against the post-redirect remote. So a server-supplied redirect both (a) moves the tap's trusted origin to an attacker host and (b) defeats the HOMEBREW_ALLOWED_TAPS mitigation shipped alongside this code. The retarget also fires on the explicit brew tap <name> <url> path.

I recommends re-evaluating allowed_by_env?/forbidden_by_env? against the redirected remote before git remote set-url, on both the apply_redirected_remote! path and the update-report.rb consumption of .git/REDIRECTED_REMOTES, and/or requiring explicit confirmation for a cross-host retarget. Independently, passing -- before the value at tap.rb:574 would close a bounded option-injection sub-case. Final severity and remediation are the PSRT's to decide.

PoC

Loopback, synthetic — no public hosts. Two loopback git-HTTP servers: an "origin" that first serves a tap cleanly, then (flag-flipped) returns a 301 redirect to an "attacker" repo one commit ahead.

  1. brew tap poc/example http://127.0.0.1:<ORIGIN>/repo.gitgit -C <tap> remote get-url origin = ORIGIN (clean).
  2. Flip the origin server to redirect; run brew update.
  3. Observed: ==> Redirected tap poc/example remote to http://127.0.0.1:<ATTACKER>/repo.git/; git -C <tap> remote get-url origin = ATTACKER; tap HEAD = the attacker commit (pulled+rebased). With HOMEBREW_ALLOWED_TAPS set to allow only ORIGIN, the retarget to the off-allowlist ATTACKER still succeeds.

(Full recorded stdout + the loopback server script are available on request / in the private review bundle.)

Impact

Silent, persistent takeover of an installed tap's source of truth on a routine, no-interaction brew update, with the documented HOMEBREW_ALLOWED_TAPS mitigation bypassed — leading to execution of attacker-controlled formula/cask code. Who is impacted: any user with a tap whose remote is reachable over a channel an attacker can redirect (a plain-HTTP remote, or an on-path/MITM position).

AI/LLM use disclosure

This finding was researched and validated with AI/LLM assistance; the reporter verified its correctness against the source and the recorded run, and takes full responsibility for it.

  • How: an AI agent system (Anthropic Claude, via Claude Code) performed native source-code review to surface the candidate, then orchestrated a live PoC on a disposable, isolated Linux VM (loopback servers, synthetic inputs only). AI output was treated as a fallible first draft; the sink, reachability, and PoC result were human-verified before reporting.
  • When: 2026-06-26 – 2026-06-27, against master HEAD c0ed315.
  • Where: in the research (discovery + PoC validation) and in drafting this write-up.
  • Prompts: operative instruction — "find every 0-day from the latest HEAD; every finding must have a PoC/wire-proof with recorded reachability stdout; conform with the security model and vuln-filing conventions; use disposable VMs within policy to fan out."

For this finding: stand up a loopback git-HTTP origin that serves a tap cleanly then 301-redirects to an attacker repo, run brew update, and assert whether origin is silently retargeted and whether HOMEBREW_ALLOWED_TAPS is bypassed. Full prompt/agent logs available to the PSRT on request.

Severity

Low

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 Network
Attack Complexity Low
Attack Requirements Present
Privileges Required None
User interaction Active
Vulnerable System Impact Metrics
Confidentiality None
Integrity Low
Availability None
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:N/AC:L/AT:P/PR:N/UI:A/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N

CVE ID

No known CVE

Weaknesses

Origin Validation Error

The product does not properly verify that the source of data or communication is valid. Learn more on MITRE.

Download of Code Without Integrity Check

The product downloads source code or an executable from a remote location and executes the code without sufficiently verifying the origin and integrity of the code. Learn more on MITRE.

Credits