Skip to content

sandbox: allow Keychain trust evaluation on macOS - #24120

Merged
MikeMcQuaid merged 2 commits into
Homebrew:mainfrom
gritse:sandbox-trust-evaluation-agent
Sep 29, 2026
Merged

MikeMcQuaid merged 2 commits into
Homebrew:mainfrom
gritse:sandbox-trust-evaluation-agent

Conversation

@gritse

@gritse gritse commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

AI was used: Claude Code (Claude Opus 5.5) helped investigate the failure, find the missing service and draft the change and this description. I verified it as described below.


What

Adds com.apple.TrustEvaluationAgent to the mach-lookup allowlist in the macOS sandbox profile, next to com.apple.trustd.agent.

Why

Since #24038 (c9bfdc3, "Extend sandboxing to package processing"), which first shipped in 7.0.7, Git downloads run under sandbox-exec. The system Git (/usr/bin/git, Apple Git) checks certificates against /etc/ssl/cert.pem first. For a certificate authority that's only trusted in the macOS Keychain (private or corporate CAs, TLS-inspecting proxies), it falls back to com.apple.TrustEvaluationAgent. The sandbox denies that lookup, so cloning from such a host fails:

Error: Cloning into '/Users/<user>/Library/Caches/Homebrew/hello-repro--git'...
fatal: unable to access 'https://git.example.internal/me/repo.git/': SSL certificate problem: unable to get local issuer certificate

The same git clone works outside the sandbox and on 7.0.6. Hosts with public CAs aren't affected.

I found the service by bisecting the mach-lookup allowlist: with the current profile, adding only (global-name "com.apple.TrustEvaluationAgent") makes the clone succeed; com.apple.trustd, com.apple.securityd.xpc and other Security services alone do not.

Reproduction

Requires an HTTPS Git server whose certificate chains to a CA trusted only in the System Keychain (sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ca.pem).

brew tap-new --no-git repro/local
cat > "$(brew --repo repro/local)/Formula/hello-repro.rb" <<'EOS'
class HelloRepro < Formula
  desc "Repro"
  homepage "https://git.example.internal/me/repo"
  url "https://git.example.internal/me/repo.git", tag: "v0.1.1", revision: "<sha>"
  version "0.1.1"

  def install
    bin.install "bin/hello-repro"
  end
end
EOS
brew install repro/local/hello-repro

Verification

With the CA trusted in the System Keychain, on macOS 15.7.7 (VM) and macOS 27.0.1:

Homebrew brew install repro/local/hello-repro
7.0.6 succeeds
7.0.7 fails as above
main (47b6582) fails as above
main + this change succeeds

brew lgtm passes on the macOS 15.7.7 VM. The updated spec fails without the sandbox.rb change.

Copilot AI lite review requested due to automatic review settings September 29, 2026 15:29
@gritse
gritse requested a review from a team as a code owner September 29, 2026 15:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

馃煝 Approval recommended

The requested sandbox permission and corresponding test updates are complete.

Review effort: Lite
Findings: None

What changed in this PR

Adds macOS sandbox access to com.apple.TrustEvaluationAgent, enabling Git certificate validation for Keychain-trusted CAs.

Changes:

  • Adds the service to the macOS mach-lookup allowlist.
  • Updates sandbox specs to verify the permission.
File Description
Library/鈥婬omebrew/鈥媡est/鈥媠andbox_spec.rb Verifies the service in the generated sandbox profile.
Library/鈥婬omebrew/鈥媏xtend/鈥媜s/鈥媘ac/鈥媠andbox.rb Allows TrustEvaluationAgent lookup.

馃挕 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

gritse and others added 2 commits September 29, 2026 16:53
Git downloads now run in the sandbox. The system Git falls back to
`com.apple.TrustEvaluationAgent` to trust certificate authorities that
are only trusted in the macOS Keychain (e.g. private or corporate CAs).
With that service denied, cloning from such hosts fails with
"SSL certificate problem: unable to get local issuer certificate".
- Gate `com.apple.TrustEvaluationAgent` on network access because trust
  evaluation can fetch certificates and revocation data.
- Keep offline sandboxes restricted, including local socket exceptions,
  and cover both cases with regression tests.
@MikeMcQuaid
MikeMcQuaid force-pushed the sandbox-trust-evaluation-agent branch from b78c778 to 23b3637 Compare September 29, 2026 15:53

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Have adjusted to ensure that this is only allowed when network access permitted rather than unconditionally.

@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Sep 29, 2026
Merged via the queue into Homebrew:main with commit 7ad3b36 Sep 29, 2026
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants