Jeremy NguyenJeremy Nguyen

Enabling `--require-sha` on all checksum-verifiable Homebrew casks

Require SHA-256 hash on Homebrew casks when it's available

  • By Jeremy Nguyen
shell
homebrew
View on GitHub

You may want to set --require-sha as a default option in your Homebrew casks for extra security, either with the environment variable HOMEBREW_CASK_OPTS="--require-sha"1 or by adding cask_args require_sha: true to your Brewfile.2

As Homebrew itself has noted, casks, which use prebuilt binaries from an upstream source, have a different security model compared to formulae built by Homebrew. At the very least, enabling --require-sha will guarantee that the downloaded cask has not changed since it was last reviewed by a Homebrew maintainer.3

The thing is: many Homebrew casks do not have a SHA-256 checksum because their download link is not versionable.4 The top ten casks in Homebrew/homebrew-cask that have "no_check" set for their SHA-256 according to their JSON analytics data as of August 7, 2026 are the following:5

CaskPlaceInstall Events (365 days)%
google-chrome#6449,4271.81%
spotify#4897,7160.39%
chromium#8357,7900.23%
steam#10646,6660.19%
google-drive#11939,6900.16%
logi-options+#12039,5320.16%
font-source-code-pro#18719,7840.08%
anydesk#20018,7140.08%
termius#23315,2400.06%
onyx#24014,8070.06%
google-gemini#27611,8950.05%

For more information on this concern, see the following issue on GitHub: Homebrew/homebrew-cask#147305. Hence, enabling --require-sha with any of the above casks installed will lead to this error:6

...
==> Verifying checksum for '89947a18e10d5bbda8e2b5d15a60b6823353f019ea1a4b74e3d9c4f91248776e--chromium.rb'
==> Checking cask has checksum
Error: Cask 'chromium' does not have a sha256 checksum defined and was not installed.
This means you have the --require-sha option set, perhaps in your HOMEBREW_CASK_OPTS.
/opt/homebrew/Library/Homebrew/cask/installer.rb:177:in `verify_has_sha'
...

Hopefully, in the future, a feature like pnpm's no-downgrade could be added, where a cask cannot be installed if it now lacks a SHA-256 checksum when it had one previously. A feature such as the aforementioned request for a per-cask option could also prevent this issue.

For now, to quickly enable SHA-256 checksum verification for the casks in your Brewfile that have one available, run the following command:

brew info --cask --quiet --json=v2 $(brew bundle --global list --cask --quiet) | jq --raw-output '
  .casks[]
  | if .sha256 == "no_check" then
      "cask \"\(.token)\" # See Homebrew/homebrew-cask#147305"
    else
      "cask \"\(.token)\", args: { require_sha: true }"
    end
'

This will output the casks portion of the Brewfile (minus pinning, extra arguments, etc.) into stdout and enable require_sha only on the casks that have a SHA-256 checksum.

PreviousWorking with files/blobs in TanStack React QueryNextPassing callback functions as a className in Base UI

Comments

There are currently zero comments. Leave a comment on Mastodon or any Fediverse-compatible instance.