trailofbits / sinter

A user-mode application authorization system for MacOS written in Swift
https://blog.trailofbits.com/2020/08/12/sinter-new-user-mode-security-enforcement-for-macos/
GNU Affero General Public License v3.0
301 stars 15 forks source link

[Feature request] Prompt user when code signature has changed (might be problematic) #98

Open JayBrown opened 4 years ago

JayBrown commented 4 years ago

It's one thing to notify the user (or outright block a process launch) when a code signature is broken, but it would also be nice to notify the user, when the signature has changed (between launches, after updates, after developer account change, after re-signing etc.).

Reason: malware could (at least in theory) change an app, and before launching it, re-codesign the bundle, either ad-hoc or using a certificate that's bundled with the malware (incl. the private key). Then an infected app would have a signature that's "valid on disk" and "satifsfies its designated requirements", and would probably launch, especially if the malware also removes the quarantine XA.

Problem: you can't really use the SHA-256 hash of a certificate, because afaik those change every time a developer renews his Apple developer account (updated certificate).

However, what does not change to my knowledge, is the Subject Key Identifier (SKID). So as long as the developer account behind an app doesn't change, the SKID will remain the same.

Caveat: third-party signatures not issued by Apple (like those used by the Skim PDF reader) don't have SKID to begin with, and in those cases the SHA-256 should be used.

A functionality like this would need a protected local database, where Sinter stores the SKID, the SHA-256, and the notarized yes/no status, the commonName, the Team ID, the Bundle ID, the path to the app or executable… and other necessary info.

A warning prompt for the user would appear (for example) if:

Checks like these would probably slow down process launches, especially if the information needed for such a functionality isn't available from the Kernel/EndpointSecurity API. In the former case, it should be an opt-in functionality, and in the latter case, it wouldn't be possible anyway, unless Sinter offers the option to lauch a (shell) script, which can then be implemented with an individual solution by user, i.e. (1) Sinter halts process launch (SIGSTOP), (2) passes all relevant data (incl. PID) to user-defined shell script, (3) shell script performs additional checks, (4a) all OK > kill -s -CONT $pid, or (4b) problems > script will prompt user, and then kill -s KILL $pid or kill -s -CONT $pid (depending on user choice).