Finder won't open quarantined files with custom "Open with" setting

Originator:cerulean
Number:rdar://50305685 Date Originated:April 29, 2019
Status:Open Resolved:
Product:macOS Product Version:macOS 10.14.4 (18E226)
Classification:bug Reproducible:always
 
Area:
Finder

Summary:
If you adjust the "Open with" settings for a file (so it opens in a non-default app for its file extension) the Finder can incorrectly prevent it from opening. The user is instead incorrectly told that the app is from an "unidentified developer".

This seems to be a bug in the way the quarantine and OpenWith xattrs interact. Files saved by a sandboxed app have a "com.apple.quarantine" attribute attached by the system. Once the Finder also sets the "com.apple.LaunchServices.OpenWith" attribute, the user can no longer open the file. 

This is probably an overzealous security check gone awry? Either way it leaves a novice user with no way to open their file.


Steps to Reproduce:
1. Launch any *sandboxed* document-based application. For this example I'll use my own app (Nisus Writer Pro).
2. Create a new document and save it to disk. I saved a file "Test.rtf" to my Desktop. Close the document in the app.
3. Go to the Finder and use "Get Info" on the saved RTF file.
4. Change the file's "open with" settings from one version of the app to another copy of the app on disk.
5. Double-click the file in the Finder to open it.

Expected Results:
The file should open in the app the user selected in step #4 above.

Actual Results:
The Finder shows an alert warning that the file is from an unidentified developer (see screenshot). That is not true. The apps are signed using Developer ID.

If you remove the quarantine attribute from the saved file it will open correctly. I'll attach output from the xattr command that shows before and after.

Version/Build:
macOS 10.14.4 (18E226)

Comments

You can get the test files here: https://github.com/aonez/Keka/issues/403#issuecomment-489988988

By aone.jga at May 7, 2019, 8:39 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!