Skip to content

Deferred `HOMEBREW_` secret in a download header is re-sent to an attacker host on a cross-host download redirect

Low
MikeMcQuaid published GHSA-3m5g-jfx7-3p65 Jul 6, 2026

Package

brew (Homebrew)

Affected versions

validated at c0ed315adb

Patched versions

6.0.7

Description

Summary

A formula/cask download header: carrying a HOMEBREW_* secret (the deferred-secret feature, used for private taps/registries) is re-sent to a server-supplied cross-host redirect target, leaking the secret to an attacker host. The cross-host header-drop is decided only from the HEAD preflight, while both the preflight and the GET follow redirects with --location.

Details

  • Library/Homebrew/download_strategy/curl_download_strategy.rb:80-82 drops headers cross-host only when the HEAD-preflight result (is_redirection) shows a host change.
  • :289 (_curl_args) re-adds --header with the expanded HOMEBREW_ secret for Homebrew-controlled curl strategies; Library/Homebrew/utils/curl.rb follows redirects with --location on both the --head preflight and the real GET.
  • Two leak windows result:
    • A (GET-time TOCTOU): the HEAD preflight returns a same-host 200, so the drop never runs; the subsequent GET then follows a cross-host 301 with the secret header attached.
    • B (HEAD-preflight --location): the preflight itself follows a cross-host redirect and re-sends the header.
  • The recent fix cf46c16827 ("Expand deferred env in curl URLs", PR #22886, Fixes #22879, merged 2026-06-26) was checked against this report and does not close it. That change gates secret expansion behind a HOMEBREW_CONTROLLED_STRATEGIES allowlist to stop untrusted/custom-formula code from expanding secrets — a different vector. The default CurlDownloadStrategy / CurlGitHubPackagesDownloadStrategy are in that allowlist, so on the normal private-download path the secret is still expanded into --header; the drop logic and utils/curl.rb are unchanged, so both windows remain. (The same commit now also expands deferred env into curl URLs/argv for controlled strategies, which widens local process-listing exposure of the secret — not a new cross-host leak, but the reporter notes it for completeness.)

The reporter recommends dropping custom non-Authorization headers (and the deferred secret) on any cross-host redirect of the actual transfer and of the preflight, rather than from a HEAD-preflight-time decision. Final severity and remediation are the PSRT's to decide.

PoC

Loopback, synthetic. Two loopback listeners: an "origin" that returns a same-host 200 on the HEAD preflight then a cross-host 301 on GET, and an "attacker" listener that logs request headers. A formula sets header "PRIVATE-TOKEN: #{ENV["HOMEBREW_FOO"]}" (synthetic token) and a url to the origin; brew fetch. Observed: the synthetic PRIVATE-TOKEN value lands in the attacker listener's captured headers, via both windows. Negative control: a same-host redirect leaks nothing. (Full recorded stdout available on request / in the private review bundle.)

Impact

Exfiltration of a private token/credential carried in a download header to an attacker-controlled host. Who is impacted: a user who installs a formula/cask that uses a HOMEBREW_-secret header, when an attacker can influence/MITM a cross-host redirect on the download URL. CWE-200 (Exposure of Sensitive Information), CWE-601 (URL Redirection to Untrusted Site).

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 proof-of-concept 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 c0ed315adb.
  • Where: in the research (discovery + PoC validation) and in drafting this write-up.
  • Prompts: the operative instruction was — "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 two loopback listeners (origin returns same-host 200 on HEAD then cross-host 301 on GET; attacker logs headers), install a formula with a HOMEBREW_-secret header, brew fetch, and assert whether the synthetic token reaches the attacker host. Full prompt/agent logs are 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 High
Attack Requirements Present
Privileges Required None
User interaction Active
Vulnerable System Impact Metrics
Confidentiality Low
Integrity None
Availability None
Subsequent System Impact Metrics
Confidentiality Low
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:H/AT:P/PR:N/UI:A/VC:L/VI:N/VA:N/SC:L/SI:N/SA:N

CVE ID

No known CVE

Weaknesses

Exposure of Sensitive Information to an Unauthorized Actor

The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. Learn more on MITRE.

URL Redirection to Untrusted Site ('Open Redirect')

The web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a redirect. Learn more on MITRE.

Credits