Sub topic 6
Code signing and Developer ID
This chapter assumes you can open Terminal and run a command, and that you know an app is a folder (a bundle) of files in /Applications. It covers what a code signature proves and what it doesn't. It also covers how Developer ID fits in and how to read a signature yourself. Notarization, quarantine and Gatekeeper get their own chapters.
What code signing is
Code signing attaches a cryptographic signature to an app. The signature does two jobs:
- Identity: it says which developer account produced the app.
- Integrity: it says the app has not changed since that developer signed it.
The developer signs with a private key that belongs to a certificate issued by Apple. When you run the app, macOS checks the signature against the certificate and against the files on disk.
Integrity works through hashes. During signing, codesign computes a hash of each file in the app bundle and stores the list in Contents/_CodeSignature/CodeResources. It then signs that list. If malware patches the executable, swaps a framework or adds a file, the hashes no longer match and verification fails.
Certificate types
Apple issues different certificates depending on how the developer distributes the software.
| Certificate | Used for |
|---|---|
| Apple Development | Building and testing on the developer's own devices |
| Apple Distribution | Submitting apps to the Mac App Store |
| Developer ID Application | Signing apps distributed outside the App Store |
| Developer ID Installer | Signing `.pkg` installers distributed outside the App Store |
Developer ID is the program for software shared on the web. A developer joins the Apple Developer Program, requests a Developer ID certificate, and signs apps and installers with it. The certificate name contains the developer's name and a Team ID, for example Developer ID Application: Example Inc (ABCDE12345).
The Team ID is a 10-character identifier tied to the developer's account. It stays the same across that developer's apps, so it is the best value to compare against what the developer publishes. The display name is weaker evidence, because many companies have similar names.
Reading a signature in Terminal
Two commands cover most checks. The first verifies integrity:
codesign --verify --deep --strict --verbose=2 /Applications/Example.appIf the signature is valid, the command prints lines like valid on disk and satisfies its Designated Requirement. If something is wrong, it prints an error such as a sealed resource is missing or invalid and exits with a non-zero status. --deep also checks nested code such as helper tools and frameworks. --strict applies stricter rules about what counts as a valid bundle.
The second command shows who signed the app:
codesign -dv --verbose=4 /Applications/Example.app 2>&1 | grep -E 'Authority|TeamIdentifier'codesign -d writes its report to standard error. The 2>&1 redirect sends it through the pipe so grep can filter it. A Developer ID app typically prints something like this:
Authority=Developer ID Application: Example Inc (ABCDE12345)
Authority=Developer ID Certification Authority
Authority=Apple Root CA
TeamIdentifier=ABCDE12345Read the Authority lines from top to bottom as a chain of trust. The first is the developer's certificate. The second is Apple's intermediate authority that issued it. The last is Apple's root, which macOS already trusts. A Mac App Store app shows a different chain, and a build signed only for development shows Apple Development. An app with no Authority lines may be unsigned or ad hoc signed.
What a valid signature does not tell you
A signature proves who and unchanged. It does not prove safe. Keep these points in mind:
- Anyone can enroll. A malicious developer can pay for a Developer ID and sign malware. The signature will be valid. This is why Apple added notarization, covered in the next chapter.
- Signed by the wrong party. A valid signature from
Unknown Corpon an app that claims to be a well-known browser is a red flag. Compare the Team ID with what the real developer publishes. - Signing happens before distribution. If an attacker modifies a signed app, the signature breaks. If an attacker modifies the developer's website to host a different, validly signed app, the signature does not help you. Pair signature checks with the vetting steps from earlier chapters.
- Ad hoc signatures carry no identity. Apple silicon Macs require all executable code to be signed, so build tools often apply an ad hoc signature (the identity
-). It detects tampering but names no developer, and Gatekeeper treats such an app as unidentified.
Revocation and expiry
Apple can revoke a Developer ID certificate if it is abused or the private key leaks. Revocation lets macOS stop trusting everything signed with that certificate, including apps that were previously fine. Apple can also act on a specific app's signature without revoking the whole certificate.
Certificates also expire. Developers normally add a secure timestamp when they sign. A timestamp proves the signature was made while the certificate was valid, so the app continues to verify after the certificate's expiry date. Apps signed without a timestamp can start failing once the certificate expires. Notarization requires a timestamp.
The hardened runtime
Developer ID apps meant for notarization are signed with the hardened runtime. This setting limits what the running process can do. For example, it blocks injection of unsigned code and unrestricted memory tricks. A developer who needs an exception must declare it as an entitlement, which is a named permission embedded in the signature. You can list a signed app's entitlements:
codesign -d --entitlements - /Applications/Example.appEntitlements are part of the signed data, so changing them breaks the signature. Unexpected powerful entitlements in a small utility are worth questioning.
Checking the signature on installers
Installer packages have their own signature, made with a Developer ID Installer certificate. Inspect it before running the installer:
pkgutil --check-signature ~/Downloads/Example.pkgThe output says whether the package is signed and shows the certificate chain. A package that reports no signature is not necessarily malicious, but it deserves extra scrutiny, because anyone could have changed it in transit.
Practical routine
- Run
codesign --verify --deep --strict --verbose=2on the app. Stop if it fails. - Read the
AuthorityandTeamIdentifierlines. - Compare the Team ID with the developer's official documentation or website.
- Treat a valid signature as one input. Combine it with a checksum, the source of the download, and the Gatekeeper result.
Exercise
You run codesign --verify --deep --strict --verbose=2 on a downloaded app and it succeeds. The Authority line shows Developer ID Application: Fast Tools Ltd (QWERTY1234), but the app claims to be made by a well-known company with a different Team ID. Is the app safe to run? Explain what the successful verification does and does not show.
Show answer
Not safe to assume. The successful verification shows the files have not changed since Fast Tools Ltd signed them, and that the certificate chains to Apple's root. It does not show the app is harmless, and it does not show that it comes from the company it claims to be. The Team ID mismatch means the signer is a different developer, so the download is likely a repackaged or fake app. Do not run it, and get the app from the developer's official site or the Mac App Store instead.