Sub topic 18
Homebrew casks as an alternative source
This chapter assumes you have read the earlier chapters on code signing, notarization, quarantine and Gatekeeper. It also assumes you can open Terminal and run commands, and that Homebrew is already installed. It does not cover installing Homebrew. Homebrew's official site gives the install command, and you should vet that page the way the web-source chapter describes.
What a cask is
Homebrew is a package manager for macOS. Most of its packages ("formulae") are command-line tools. A cask is a different kind of package: a small recipe that tells Homebrew how to download and install a graphical Mac app, such as a .dmg, .zip or .pkg that the developer publishes.
A cask does not repackage the app. Homebrew downloads the developer's own file from the developer's own URL, then runs the same steps you would run by hand. It mounts the disk image, copies the app into /Applications (or runs the installer package), and records what it installed.
Where casks sit in the trust model
A cask adds a layer to the web-download path. It does not replace any layer.
| Question | Mac App Store | Direct web download | Homebrew cask |
|---|---|---|---|
| Who reviews the app? | Apple | Nobody, apart from notarization's automated scan | Nobody for the app itself |
| Who reviews the install recipe? | Not applicable | Not applicable | Homebrew maintainers, through pull requests on GitHub |
| Is the app sandboxed? | Required | Optional | Optional |
| Where does the file come from? | Apple's servers | The site you chose | The developer's URL named in the cask |
| Is the file hash checked? | Handled by the App Store | Only if you do it | Yes, when the cask lists a `sha256` |
| Does Gatekeeper check it? | Yes | Yes | Yes |
The main gain is that someone has already decided which URL is the official one. That removes the risk of landing on a fake download site from a search result. The main limit is that the app is exactly as trustworthy as the developer's own build. Maintainers review the recipe, not the app's behavior.
The trust chain for a cask install
Two checks happen before macOS is involved. The first is the choice of URL, which comes from the cask. The second is the hash comparison. Gatekeeper then runs as usual.
Everyday commands
# Search for a cask by name
brew search --cask firefox
# Read its description, homepage, version and install details
brew info --cask firefox
# Install it
brew install --cask firefox
# List casks you installed
brew list --caskbrew info --cask shows the homepage. Compare it with the developer's official site before you install.
Reading a cask before you trust it
You can print any cask's source and read it:
brew cat --cask firefoxA cask is a short Ruby file. Look at these fields:
url: where the file downloads from. It should usehttpsand a domain that belongs to the developer.sha256: the expected hash of the download. Some casks of apps that publish a "latest" file usesha256 :no_check. Then Homebrew cannot verify the file, and you depend on code signing and Gatekeeper alone.homepage: the official site.pkgorappstanzas: what gets installed. Apkgstanza runs an installer, which can ask for your administrator password and write outside/Applications.uninstallandzapstanzas: how Homebrew removes the app and its leftover files.
# Download and verify the file without installing it
brew fetch --cask firefoxbrew fetch downloads the file into Homebrew's cache and checks the hash. It is a cheap way to see the hash check work.
Quarantine and Gatekeeper still apply
Homebrew downloads with its own tools, but by default it applies the quarantine attribute to the app, as a browser would. You can see it on the installed app:
xattr -l /Applications/Firefox.appOn first launch, Gatekeeper runs its normal checks. A cask can therefore install an app that macOS then blocks, and the blocked-apps chapter tells you what to do in that case.
Older Homebrew versions offered a --no-quarantine option that skipped this attribute and so bypassed Gatekeeper. Homebrew has been phasing it out, so do not rely on it. Casks for apps that fail Gatekeeper are also being removed from the official tap.
Third-party taps
A tap is a repository of formulae and casks. The default homebrew/cask tap is public and maintained by the Homebrew project. You can add others:
brew tap someuser/sometapA third-party tap is a recipe collection that anyone can publish. Its maintainer decides which URL and which hash a cask uses. Installing from one means trusting that person as much as you would trust a developer's website. Use a tap only when you know and trust its owner, and read the cask with brew cat first.
Updating and removing
# Show casks with newer versions
brew outdated --cask
# Upgrade all outdated casks
brew upgrade --cask
# Upgrade one cask
brew upgrade --cask firefoxMany apps update themselves. Homebrew skips those by default, because the app's own updater handles them. The --greedy option includes them in the check:
brew outdated --cask --greedyHomebrew only updates when you run these commands. It does not run in the background. The chapter on keeping apps updated explains why unpatched apps are a risk, so put the commands on a regular schedule.
For removal:
# Remove the app
brew uninstall --cask firefox
# Remove the app and the leftover files listed in the cask's zap stanza
brew uninstall --cask --zap firefox--zap deletes preferences and caches that the cask author lists. Zap can delete data you wanted to keep, so read the zap stanza in brew cat first.
Common errors
- Hash mismatch. The developer replaced the file but the cask is out of date, or the download was altered. Do not force the install. Run
brew updateand try again. If the error persists, check the project's issue tracker. - An app already in /Applications. Homebrew refuses to overwrite an app it did not install. Remove the manual copy first, or follow Homebrew's message about adopting it.
- Admin prompts. Casks that use
pkginstallers need your password. That is normal. An unexpected password prompt from a cask that should only copy an app is a reason to stop and read the cask. - The app disagrees with the Store. If you install the same app from the App Store and from a cask, you get two copies that update separately. Pick one source for each app.
When to choose a cask
Use a cask when the app is only distributed on the web, you want one command to install and update many apps, or you rebuild Macs often and want a repeatable list. Prefer the Mac App Store when the app is available there and sandboxing matters to you. Neither source replaces your own checks: read the cask, keep Gatekeeper on, and review the privacy permissions the app asks for.
Exercise
A cask's source contains sha256 :no_check and a pkg stanza. Name two checks that still protect you when you install it, and one extra step you should take before installing.
Show answer
Code signing and Gatekeeper's notarization check still apply, because Homebrew leaves quarantine set, and the HTTPS URL still points at the developer's domain. Before installing, read the cask with brew cat --cask name. Confirm the URL belongs to the developer, then download the file with brew fetch --cask name and run pkgutil --check-signature on it. This is worth doing because the pkg runs an installer with administrator rights and no hash is checked.
Exercise
You run brew install --cask exampleapp and the app is blocked at first launch. A forum post suggests reinstalling with a flag that skips quarantine. What should you do instead?
Show answer
Do not skip quarantine. Run codesign --verify --deep --strict --verbose=2 and spctl --assess --type execute --verbose=4 on the app to see why it failed. Compare the Team ID from codesign -dv with the developer's published details. If the app is unsigned or not notarized, or the checks fail, remove it with brew uninstall --cask exampleapp and look for the developer's official release or a different source.