spctl

On this page 7

spctl is the macOS command-line tool for the security assessment policy subsystem, better known as Gatekeeper. It lets administrators and developers check whether an application, installer package or disk image would be allowed to run or open, report whether assessments are enabled, and change parts of the policy from Terminal.

The name stands for system policy control. In the Terminal & scripting toolbox, spctl sits next to codesign, which signs and inspects code, and xattr, which manages the quarantine attribute that triggers Gatekeeper in the first place. Together these three tools explain most of what happens when a downloaded app is blocked.

How spctl evaluates software

spctl does not make decisions on its own; it is a client of the syspolicyd daemon, which holds the Gatekeeper policy and performs the actual assessment. When asked to assess an item, spctl sends the path to the daemon, which checks the code signature, the signing certificate chain and, for Developer ID software, the notarization ticket issued by Apple.

The result is either accepted or rejected, together with a source that explains why. Typical sources are Apple System for built-in software, Mac App Store for store apps, Notarized Developer ID for signed and notarized third-party apps, and no usable signature for unsigned code.

Gatekeeper normally runs only for files that carry the com.apple.quarantine extended attribute, which browsers and mail clients add to downloads. spctl, however, can assess any path on demand, which makes it a reliable way to predict Gatekeeper behavior before distribution.

Core spctl commands and options

Most daily use involves a small set of options. The table lists the commands administrators and developers reach for most often.

CommandPurposeNotes
spctl --statusShows whether assessments are enabledPrints assessments enabled or disabled
spctl --assess -vv App.appAssesses an app for executionVerbose output shows source and origin
spctl -a -t install pkgAssesses an installer packageThe install type is required for packages
spctl -a -t open --context context:primary-signatureAssesses a disk image or documentUsed for signed DMG files
spctl --global-disableRequests that Gatekeeper be turned offRecent releases require confirmation in System Settings
spctl developer-mode enable-terminalShows Terminal under Developer ToolsLets approved tools skip some checks
Frequently used spctl commands

The assessment type matters. The default type is execute, which suits applications; packages need the install type, and disk images or other documents need the open type. Using the wrong type produces misleading rejections that have nothing to do with the actual signature.

Reading spctl output

Verbose output is short but dense. The table below interprets the most common results and what they imply for the user experience.

Result and sourceMeaningWhat the user sees
Accepted, Notarized Developer IDSigned with Developer ID and notarizedA brief confirmation on first launch
Accepted, Mac App StoreDistributed through the App StoreOpens normally
Rejected, Unnotarized Developer IDSigned but not notarizedA block that requires manual approval
Rejected, no usable signatureUnsigned or damaged codeA block or a report that the app is damaged
Accepted, Apple SystemSoftware shipped by AppleOpens normally
Common assessment results

The command also returns an exit status of zero for accepted items and a nonzero value for rejected ones, so scripts can branch on the result without parsing text. This is useful in build pipelines that must fail when a release is not notarized.

Several macOS commands touch code security, and each answers a different question. The comparison clarifies where spctl fits.

ToolQuestion it answersTypical command
spctlWould Gatekeeper allow this itemspctl -a -vv App.app
codesignIs the signature present and validcodesign --verify --deep --strict App.app
xattrIs the item quarantinedxattr -l App.app
staplerIs a notarization ticket attachedxcrun stapler validate App.app
csrutilIs System Integrity Protection enabledcsrutil status
Related command-line security tools

A valid signature alone is not enough. An app can pass codesign verification and still be rejected by spctl because it lacks notarization or uses a certificate type that Gatekeeper does not trust for distribution.

Changes across macOS releases

Apple has steadily narrowed what spctl can change while keeping its assessment role intact. Older releases allowed custom rules with labels and priorities through options such as --add and --list, and allowed Gatekeeper to be switched off silently with a master-disable option.

  • Rule management has been deprecated, and custom rules are no longer a supported way to approve software; managed Macs use configuration profiles instead.
  • Disabling Gatekeeper from Terminal now only exposes an extra choice in Privacy & Security settings, where the user must confirm the change with administrator credentials.
  • Notarization became mandatory for Developer ID software, so spctl output shifted from simply signed toward notarized or not.

The practical lesson is to treat spctl as a diagnostic and verification tool first. Switching off Gatekeeper system-wide removes an important layer of protection against malware and should be avoided; approving a single trusted app in Privacy & Security is the safer choice.

In simple terms

A Mac has a security guard called Gatekeeper. It checks new apps before they run. It looks for a valid signature and a stamp from Apple.

spctl is a way to ask the guard questions by typing commands. A user can ask whether the guard is on. A user can also ask whether a certain app would be let in, and why.

Developers use it to check their apps before sharing them. That way, customers do not see a scary warning when they open the app for the first time.

A practical example

A small software team prepares a new release of its desktop app for customers who download it from the company website. Before publishing, a developer runs spctl -a -vv on the finished app bundle on a test Mac.

The output reads rejected with the source Unnotarized Developer ID. The signature is valid, but the notarization step failed silently in the build script. The developer resubmits the app to Apple’s notary service, staples the ticket with xcrun stapler staple, and runs spctl again, which now reports accepted with Notarized Developer ID.

The team then adds the same spctl check to its automated release pipeline, so the build stops whenever the exit status is nonzero. Customers receive an app that opens with only the standard first-launch confirmation, and support requests about blocked downloads drop sharply.